******************************************************************************* * * Two-stage stochastic programming example illustrating EVPI and VSS. * * Farm problem from * Birge and Louveaux, Introduction to Stochastic Programming, * Springer, 1997, Chapter 1.1. * * Gams model written by Anders Forsgren, November 8 2000. * ******************************************************************************* set crop Crop / wheat corn sugar-beet /; set scenario Stochastic scenarios / above normal below /; parameter meanyield(crop) Mean yield in T per acre / wheat 2.5 corn 3 sugar-beet 20 /; parameter fraction(scenario) Fraction of change in yield for the scenarios / above 0.2 normal 0 below -0.2 /; parameter yield(crop,scenario) Yield for the scenarios; yield(crop,scenario) = (1+fraction(scenario))*meanyield(crop); parameter prob(scenario) Probability for the scenarios; prob(scenario) = 1/3; parameter plantcost(crop) Planting cost in dollars per acre / wheat 150 corn 230 sugar-beet 260 /; parameter sellprice(crop) Selling price in dollars per T / wheat 170 corn 150 sugar-beet 36 /; parameter xsellprice(crop) Selling price for excess sugar-beet / sugar-beet 10 /; parameter purchprice(crop) Purchase price in dollars per T / wheat 238 corn 210 /; parameter minreq(crop) Minimum requirement in T / wheat 200 corn 240 /; scalar land Available land (acres) / 500 /; scalar maxbeet Maximum quantity of beets to be sold at regular price / 6000 /; ******************************************************************************* * * Set up the recourse model. * variables surface(crop) Amount of land sales(crop,scenario) Sales xsales(crop,scenario) Excess sales of sugar beets purchase(crop,scenario) Purchase totcost Total cost; positive variables surface, sales, xsales, purchase; sales.up("sugar-beet",scenario) = maxbeet; equations totobj Objective function maxland Land restriction minlvl(crop,scenario) Minimum level of crop; totobj .. sum(crop,plantcost(crop)*surface(crop)) - sum((crop,scenario), prob(scenario)*sellprice(crop)*sales(crop,scenario)) - sum((crop,scenario)$xsellprice(crop), prob(scenario)*xsellprice(crop)*xsales(crop,scenario)) + sum((crop,scenario)$purchprice(crop), prob(scenario)*purchprice(crop)*purchase(crop,scenario)) - totcost =e= 0; maxland .. sum(crop,surface(crop)) =l= land; minlvl(crop,scenario) .. yield(crop,scenario)*surface(crop) + purchase(crop,scenario)$purchprice(crop) =g= sales(crop,scenario) + xsales(crop,scenario)$xsellprice(crop) + minreq(crop); model farm / totobj, maxland, minlvl /; solve farm using lp minimizing totcost; parameter RP Optimal value of recourse problem; RP = totcost.l; ******************************************************************************* * * To illustrate EVPI and VSS, set up the model where each scenario is solved * individially * * Use suffix "sc" to denote scenario variables surfacesc(crop) Amount of land salessc(crop) Sales xsalessc(crop) Excess sales of sugar beets purchasesc(crop) Purchase costsc Cost for each scenario positive variables surfacesc, salessc, xsalessc, purchasesc; salessc.up("sugar-beet") = maxbeet; parameter yieldsc(crop); equations objsc Objective function for each scenario maxlandsc Land restriction minlvlsc(crop) Minimum level of crop; objsc .. sum(crop,plantcost(crop)*surfacesc(crop)) - sum(crop,sellprice(crop)*salessc(crop)) - sum(crop$xsellprice(crop),xsellprice(crop)*xsalessc(crop)) + sum(crop$purchprice(crop),purchprice(crop)*purchasesc(crop)) - costsc =e= 0; maxlandsc .. sum(crop,surfacesc(crop)) =l= land; minlvlsc(crop) .. yieldsc(crop)*surfacesc(crop) + purchasesc(crop)$purchprice(crop) =g= salessc(crop) + xsalessc(crop)$xsellprice(crop) + minreq(crop); model farmsc / objsc, maxlandsc, minlvlsc /; scalar totcostsc / 0 /; * Parameters for collecting the optimal solutions for each scenario parameter surfacep(crop,scenario) Amount of land; parameter salesp(crop,scenario) Sales; parameter xsalesp(crop,scenario) Excess sales of sugar beets; parameter purchasep(crop,scenario) Purchase; loop(scenario, * Give the correct yield for the scenario in question yieldsc(crop) = yield(crop,scenario); solve farmsc using lp minimizing costsc; totcostsc = totcostsc + prob(scenario)*costsc.l; * Insert the optimal values for the scenario in question surfacep(crop,scenario) = surfacesc.l(crop); salesp(crop,scenario) = salessc.l(crop); xsalesp(crop,scenario) = xsalessc.l(crop); purchasep(crop,scenario) = purchasesc.l(crop); ); parameter WS Optimal value of the wait-and-see problem; WS = totcostsc; display surfacep, salesp, xsalesp, purchasep; ******************************************************************************* * * Calculate the value of perfect informaion. * parameter EVPI Expected value of perfect information; EVPI = RP - WS; display RP, WS, EVPI; ******************************************************************************* * * Calulate the value of the stochastic solution * * The optimal value of the expected-value problem is known (from "normal") surface.fx(crop) = surfacep(crop,"normal"); * Resolve the problem with the surface variables fixed. solve farm using lp minimizing totcost; parameter EEV Value of the expected value solution; EEV = totcost.l; parameter VSS Value of the stochastic solution; VSS = EEV - RP; display EEV, RP, VSS; *******************************************************************************