13 static readonly String PROPERTIES_FILE =
"test.properties";
15 static Logger logger = LogManager.GetCurrentClassLogger();
23 static readonly String MODEL =
25 " i canning plants / seattle, san-diego / \n" +
26 " j markets / new-york, chicago, topeka / ; \n" +
29 " a(i) capacity of plant i in cases \n" +
31 " san-diego 600 / \n" +
33 " b(j) demand at market j in cases \n" +
34 " / new-york 325 \n" +
36 " topeka 275 / ; \n" +
38 "Table d(i,j) distance in thousands of miles \n" +
39 " new-york chicago topeka \n" +
40 "seattle 2.5 1.7 1.8 \n" +
41 "san-diego 2.5 1.8 1.4 ; \n" +
43 "Scalar f freight in dollars per case per thousand miles /90/ ; \n" +
44 "Scalar bmult demand multiplier /1/; \n" +
46 "Parameter c(i,j) transport cost in thousands of dollars per case ; \n" +
47 " c(i,j) = f * d(i,j) / 1000 ; \n" +
50 " x(i,j) shipment quantities in cases \n" +
51 " z total transportation costs in thousands of dollars ; \n" +
53 "Positive Variable x ; \n" +
56 " cost define objective function \n" +
57 " supply(i) observe supply limit at plant i \n" +
58 " demand(j) satisfy demand at market j ; \n" +
60 " cost .. z =e= sum((i,j), c(i,j)*x(i,j)) ; \n" +
62 " supply(i) .. sum(j, x(i,j)) =l= a(i) ; \n" +
64 " demand(j) .. sum(i, x(i,j)) =g= bmult*b(j) ; \n" +
66 "Model transport /all/ ; \n" +
70 public static void OneTimeSetUp()
72 logger.Debug(
"entering TestGAMSModelInstance | SetUpBeforeClass");
74 logger.Info(
"Housekeeper task initialized");
79 logger.Debug(
"exiting TestGAMSModelInstance | SetUpBeforeClass");
83 public static void TearDown()
113 public void testAddModelInstanceInstantiateAndSolve()
115 logger.Debug(
"entering TestGAMSModelInstance | testAddModelInstanceInstantiateAndSolve");
119 Assert.That(cp !=
null,
"do not expect cp as null");
120 StringAssert.AreEqualIgnoringCase(
new FileInfo(ws.
WorkingDirectory).FullName,
122 "expect [" + ws.
WorkingDirectory +
"] as a checkpoint's working directory.");
124 Assert.NotNull(job,
"do not expect a null job");
133 Assert.NotNull(mi,
"do not expect a null mi");
134 Assert.NotNull(mi.
SyncDB,
"do not expect a null syncDB");
141 Assert.NotNull(bmult,
"do not expect a null bmult");
144 Assert.AreEqual(0, bmult.
NumberRecords,
"expect empty records");
148 Assert.AreEqual(1, bmult.
NumberRecords,
"expect one record in bmult");
157 Assert.AreEqual(
ModelStat.InfeasibleGlobal, mi.
ModelStatus,
"expect ModelStatus:INFEASIBLE_GLOBAL");
167 logger.Debug(
"exiting TestGAMSModelInstance | testAddModelInstanceInstantiateAndSolve");
171 public void testCopyModelInstanceAndSolve()
173 logger.Debug(
"entering TestGAMSModelInstance | testAddModelInstanceInstantiateAndSolve");
192 Assert.NotNull(copy,
"do not expect a null copy");
197 logger.Debug(
"exiting TestGAMSModelInstance | testCopyModelInstanceAndSolve");
201 public void testCallingInstantiateForSecondTime()
203 logger.Debug(
"entering TestGAMSModelInstance | testCallingInstantiateForSecondTime");
220 logger.Debug(
"exiting TestGAMSModelInstance | testCallingInstantiateForSecondTime");
224 public void testInstantiateWithNullModelDefinition()
226 logger.Debug(
"entering TestGAMSModelInstnace | testInstantiateWithNullModelDefinition");
240 logger.Debug(
"exiting TestGAMSModelInstnace | testInstantiateWithNullModelDefinition");
244 public void testInstantiateWithNullModifier1()
246 logger.Debug(
"entering TestGAMSModelInstance | testInstantiateWithNullModifier1");
259 logger.Debug(
"exiting TestGAMSModelInstance | testInstantiateWithNullModifier1");
263 public void testInstantiateWithNullModifier2()
265 logger.Debug(
"entering TestGAMSModelInstance | testInstantiateWithNullModifier2");
278 logger.Debug(
"exiting TestGAMSModelInstance | testInstantiateWithNullModifier2");
281 public void testCopyModelInstanceBeforeInstantiated()
283 logger.Debug(
"entering TestGAMSModelInstance | testCopyModelInstanceBeforeInstantiated");
294 logger.Debug(
"exiting TestGAMSModelInstance | testCopyModelInstanceBeforeInstantiated");
void Instantiate(string modelDefinition, params GAMSModifier[] modifiers)
new GAMSParameterRecord AddRecord(params string[] keys)
GAMSCheckpoint AddCheckpoint(string checkpointName=null)
static void initializeTestFrom(String filename, String subdir)
initialize class properties from fileName and prepare directory subdir
GAMSParameter GetParameter(string parameterIdentifier)
GAMSModelInstance CopyModelinstance(string modelInstanceName=null)
GAMSOptions AddOptions(GAMSOptions optFrom=null)
GAMSModelInstance AddModelInstance(string modelInstanceName=null)
new GAMSParameterRecord FirstRecord()
GAMSJob AddJobFromString(string gamsSource, GAMSCheckpoint checkpoint=null, string jobName=null)
void Solve(SymbolUpdateType updateType=SymbolUpdateType.BaseCase, TextWriter output=null, GAMSModelInstanceOpt miOpt=null)
GAMSParameter AddParameter(string identifier, int dimension, string explanatoryText="")
void Run(GAMSOptions gamsOptions=null, GAMSCheckpoint checkpoint=null, TextWriter output=null, Boolean createOutDB=true)