Description
This model implements the well known transport problem and submits the generation and solution of the model to GAMS Engine. For that GAMS exports the workfile just before the solve and executes via embedded code Python the solve statement on Engine using the Python Control API with its method run_engine. The results come back in a GDX point file and the solution is imported back into GAMS. The model attributes, e.g transport.modelStat and transport.solveStat, need to be transferred explicitly. In order to see the independence of this asynchronous solve with GAMS Engine from a particular model and data, the logic to submit and collect models has been moved to a batInlude file engine_solve.gms. Contributor: Michael Bussieck, November 2023 The model requires environment variables set to work properly: ENGINE_URL, ENGINE_USER, ENGINE_PASSWORD ENGINE_NAMESPACE
Category : GAMS Data Utilities library
Main file : EngineSolve.gms includes : EngineSolve.gms engine_solve.gms
$title Demonstrate how to submit just a solve statement to Engine (ENGINESOLVE,SEQ=149)
$onText
This model implements the well known transport problem and submits
the generation and solution of the model to GAMS Engine. For that
GAMS exports the workfile just before the solve and executes via
embedded code Python the solve statement on Engine using the Python
Control API with its method run_engine. The results come back in a
GDX point file and the solution is imported back into GAMS. The
model attributes, e.g transport.modelStat and
transport.solveStat, need to be transferred explicitly.
In order to see the independence of this asynchronous solve with GAMS
Engine from a particular model and data, the logic to submit and
collect models has been moved to a batInlude file engine_solve.gms.
Contributor: Michael Bussieck, November 2023
$offText
* The model requires environment variables set to work properly:
* ENGINE_URL, ENGINE_USER, ENGINE_PASSWORD ENGINE_NAMESPACE
$if not setEnv ENGINE_URL $abort.noError Environment variables for GAMS Engine are not set
Set
i 'canning plants' / seattle, san-diego /
j 'markets' / new-york, chicago, topeka /;
Parameter
a(i) 'capacity of plant i in cases'
/ seattle 350
san-diego 600 /
b(j) 'demand at market j in cases'
/ new-york 325
chicago 300
topeka 275 /;
Table d(i,j) 'distance in thousands of miles'
new-york chicago topeka
seattle 2.5 1.7 1.8
san-diego 2.5 1.8 1.4;
Scalar f 'freight in dollars per case per thousand miles' / 90 /;
Parameter c(i,j) 'transport cost in thousands of dollars per case';
c(i,j) = f*d(i,j)/1000;
Variable
x(i,j) 'shipment quantities in cases'
z 'total transportation costs in thousands of dollars';
Positive Variable x;
Equation
cost 'define objective function'
supply(i) 'observe supply limit at plant i'
demand(j) 'satisfy demand at market j';
cost.. z =e= sum((i,j), c(i,j)*x(i,j));
supply(i).. sum(j, x(i,j)) =l= a(i);
demand(j).. sum(i, x(i,j)) =g= b(j);
Model transport / all /;
$batInclude engine_solve transport minimizing z using lp
$onImplicitAssign
display transport.modelStat, transport.solveStat, transport.nodUsd, x.l, z.l;