2using System.Collections.Generic;
6using System.Threading.Tasks;
21 static void Main(
string[] args)
24 bool useLock = Array.Exists(args, arg =>
string.Equals(arg,
"--UseLock", StringComparison.OrdinalIgnoreCase));
26 double[] bmultlist =
new double[] { 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3 };
28 Parallel.ForEach(bmultlist, delegate (
double bmult)
30 Console.WriteLine(
"Scenario bmult=" + bmult +
", Obj:" + optim.solve(bmult));
38 private readonly
bool _useLock;
44 if (Environment.GetCommandLineArgs().Length > 1 && !Environment.GetCommandLineArgs()[1].StartsWith(
"-"))
45 ws =
new GAMSWorkspace(systemDirectory: Environment.GetCommandLineArgs()[1]);
52 private static readonly
object ProcessStartLock =
new object();
54 public double solve(
double mult)
65 gOption.
Defines.Add(
"gdxincname", gdxPath);
78 lock (ProcessStartLock)
80 gModJob.
Run(gOption, gDb);
85 gModJob.
Run(gOption, gDb);
92 private String GetModelText()
96 i canning plants / seattle, san-diego /
97 j markets / new-york, chicago, topeka / ;
101 a(i) capacity of plant i in cases
105 b(j) demand at market j in cases
110 Table d(i,j) distance in thousands of miles
111 new-york chicago topeka
113 san-diego 2.5 1.8 1.4 ;
115 Scalar f freight in dollars per case per thousand miles;
117$if not set gdxincname $abort 'no include file name for data file provided'
122 Parameter c(i,j) transport cost in thousands of dollars per case ;
124 c(i,j) = f * d(i,j) / 1000 ;
127 x(i,j) shipment quantities in cases
128 z total transportation costs in thousands of dollars ;
130 Positive Variable x ;
133 cost define objective function
134 supply(i) observe supply limit at plant i
135 demand(j) satisfy demand at market j ;
137 cost .. z =e= sum((i,j), c(i,j)*x(i,j)) ;
139 supply(i) .. sum(j, x(i,j)) =l= a(i) ;
141 demand(j) .. sum(i, x(i,j)) =g= b(j) ;
143 Model transport /all/ ;
145 Solve transport using lp minimizing z ;
GAMSVariable GetVariable(string variableIdentifier)
GAMSParameter AddParameter(string identifier, int dimension, string explanatoryText="")
void Run(GAMSOptions gamsOptions=null, GAMSCheckpoint checkpoint=null, TextWriter output=null, Boolean createOutDB=true)
Dictionary< string, string > Defines
new GAMSParameterRecord AddRecord(params string[] keys)
new GAMSVariableRecord FirstRecord()
GAMSJob AddJobFromString(string gamsSource, GAMSCheckpoint checkpoint=null, string jobName=null)
GAMSDatabase AddDatabase(string databaseName=null, string inModelName=null)
GAMSOptions AddOptions(GAMSOptions optFrom=null)
This is the 14th model in a series of tutorial examples. Here we show: How to run multiple GAMSJobs i...