$title Test GUSS Option ReportLastScen (SCNESOL7,SEQ=737) $onText There are choices for what to report back to GAMS in case of a GUSS run: 1) Nothing (skipBaseCase=1, reportLastScen=0), 2) The Base Case (skipBaseCase=0, reportLastScen=0), 3) The last scenario solved (reportLastScen=1) This model tests the different alternatives. Contributor: Michael Bussieck, September 2017 $offText Sets i canning plants / seattle, san-diego / j markets / new-york, chicago, topeka / ; Parameters 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.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 ; Variables x(i,j) shipment quantities in cases z total transportation costs in thousands of dollars ; Positive Variable x ; Equations 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), f * d(i,j) / 1000 *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/ ; set ScenariosToRun scenarios / base, run1, run2 / Table newsupply(ScenariosToRun,i) updater for a seattle san-diego base 350 600 run1 300 650 run2 400 550 ; Table newdemand(ScenariosToRun,j) updater for b new-york chicago topeka base 325 300 275 run1 325 300 275 run2 350 300 250 ; Set mattrib / system.GUSSModelAttributes /; Parameter resultantx(ScenariosToRun,i,j) collector for level of x srep(ScenariosToRun, mattrib) model attibutes like modelstat etc o(*) GUSS options / skipBaseCase 1 / Set dict / ScenariosToRun.scenario.'' o. opt .srep a. param .newsupply b. param .newdemand x. level .resultantx / Solve transport using lp minimizing z scenario dict; Set Error(scenariostorun) Empty solution; Error(scenariostorun) = sum((i,j),resultantx(scenariostorun,i,j)) = 0; Abort$card(error) 'Missing solution for some scenarios', error; * Make sure we get 'Normal completion' and 'No Solution' (skipBaseCase is 1) abort$(transport.modelstat <> %modelStat.noSolutionReturned% or transport.solvestat <> %solveStat.normalCompletion%) 'wrong status (14/1)', transport.modelstat, transport.solvestat; * With base case: o('skipBaseCase') = 0; Solve transport using lp minimizing z scenario dict; * Make sure we get 'Normal completion' and 'Optimal' (skipBaseCase is 0) abort$(transport.modelstat <> %modelStat.optimal% or transport.solvestat <> %solveStat.normalCompletion%) 'wrong status (1/1)', transport.modelstat, transport.solvestat; abort$(abs(107.775-transport.objval)>1e-6) 'wrong objval (107.775)', transport.objval; * With base case but reporting the last solved scenario: o('skipBaseCase') = 0; o('reportLastScen') = 1; Solve transport using lp minimizing z scenario dict; * Make sure we get 'Normal completion' and 'Optimal' (skipBaseCase is 0) abort$(transport.modelstat <> %modelStat.optimal% or transport.solvestat <> %solveStat.normalCompletion%) 'wrong status (1/1)', transport.modelstat, transport.solvestat; abort$(abs(110.25-transport.objval)>1e-6) 'wrong objval (110.25)', transport.objval; * Without base case but reporting the last solved scenario: o('skipBaseCase') = 1; o('reportLastScen') = 1; Solve transport using lp minimizing z scenario dict; * Make sure we get 'Normal completion' and 'Optimal' (skipBaseCase is 0) abort$(transport.modelstat <> %modelStat.optimal% or transport.solvestat <> %solveStat.normalCompletion%) 'wrong status (1/1)', transport.modelstat, transport.solvestat; abort$(abs(110.25-transport.objval)>1e-6) 'wrong objval (110.25)', transport.objval;