solver and modelling support for stochastic programming h.i. gassmann, dalhousie university happy...
TRANSCRIPT
Solver and modelling support for stochastic programming
H.I. Gassmann, Dalhousie University
Happy Birthday András, November 2009
© 2009 H.I. Gassmann
Agenda• Stochastic programs• An Example• Algebraic modelling languages
– GAMS– MPL– AMPL
• Frontline Systems• SMI (Stochastic modelling interface)• Optimization Services• Other software
© 2009 H.I. Gassmann
Stochastic programs• Two-stage recourse problems• Multistage recourse problems• Chance-constrained problems• Continuous distributions
© 2009 H.I. Gassmann
An Example (Ferguson & Dantzig)
0,,
,,1,
,,1,s.t.
Emin,
jjij
jjji
ijij
ij
ij
jjj
jiijij
zyx
Jjzyxd
Iiax
zpxc
d
d
xij = # aircraft of type i assigned to route j
yj = # empty seats on route j
zj = # lost sales on route j
In the original formulation, d is defined by marginals
© 2009 H.I. Gassmann
Words to ponder…• “Simple recourse is so previous millennium”• “Always build your scenario tree prior to calling
the solver”• “No need to bother with special algorithms ―
Cplex on the deterministic equivalent is best”• “Robust optimization is irrelevant”
© 2009 H.I. Gassmann
GAMSSET equip := (E1, E2, E3, E4); route := (R1, R2, R3, R4, R5); scen := (S1*S720);
DATA avail[equip] := (E1,10, E2,19, E3,25, E4,15); price[route] := (R1,13, R2,13, R3, 7, R4, 7, R5, 1); capac[equip,route] := (...); cost [equip,route] := (...); demand[route,scen] := (...); prob[scen] := (...);
DECISION VARIABLES Assign[equip,route]; Empty[route,scen]; LostSales[route,scen];
MODEL MIN totalcost = SUM(equip,route: cost*Assign) + SUM(route,scen: prob*price*LostSales);
SUBJECT TO availability[equip]: SUM(route: Assign) <= avail;
passengers[route,scen]: SUM(equip: capac*Assign) – Empty + LostSales = demand;
© 2009 H.I. Gassmann
GAMS• Solve deterministic equivalent • Two-stage problems can use DECIS• Discrete scenarios only
© 2009 H.I. Gassmann
MPLINDEX aircraft : = (A,B,C,D);
STOCHASTIC
INDEP route := (NL1, NL2, ND0, ND1, NB0) -> (r1,r2,r3,r4,r45);
OUTCOME out5 := 1..5;
EVENT RouteOut[route,out5] := (NL1, 1..5, NL2, 1..2, ND0, 1..5, ND1, 1..5, NB0, 1..3);
PROBABILITIES p[route, out5 in RouteOut] := [NL1, 1, 0.2, NL1, 2, 0.05, ... ];
© 2009 H.I. Gassmann
MPL (continued)RANDOM DATA Demand[route, out5 in RouteOut] := ...
DATA AircraftAvail[aircraft] := ...; TicketPrice[route] := ...; PotentialPass[aircraft,route] := ...; MonthlyCost [aircraft,route] := ...;
DECISION VARIABLES Assign[aircraft,route] -> x WHERE (PotentialPass > 0);
STAGE2 VARIABLES EmptySeats[route] -> y1; TurnedAway[route] -> y2;
MODEL MIN TotalCost = SUM(aircraft,route: MonthlyCost * Assign) + SUM(route: TicketPrice * TurnedAway);
SUBJECT TO AircraftCap[aircraft]: SUM(route: Assign) <= AircraftAvail; PassengerBal[route]: SUM(aircraft: PotentialPass * Assign) + TurnedAway[route] – EmptySeats[route] = Demand[route];
© 2009 H.I. Gassmann
MPL capabilities• Solve deterministic equivalent (any MPL solver)• Built-in decomposition solver (two-stage - Cplex) • Communication with SMI • Planned extensions: nested decomposition
© 2009 H.I. Gassmann
AMPLset aircraft := {A1, A2, A3, A4};set routes := {r1, r2, r3, r4, r5};
param avail{aircraft} >= 0;param ticketPrice{routes} > 0;param potentialPassenger{aircraft, routes} default 0;param MonthlyCost {a in aircraft, r in routes: potentialPassenger[a,r] > 0};
var demand{route} random;
var Assign{a in aircraft, r in routes: potentialPassenger[a,r] > 0} >= 0;var EmptySeats{route} suffix stage 2;var TurnedAway{route} suffix stage 2;
minimize totalCost: sum{a in aircraft, r in routes: potentialPassenger[a,r] > 0} MonthlyCost[a,r]*Assign[a,r] + sum{r in routes} TicketPrice[r]*TurnedAway[r];
subject to AircraftCap{a in aircraft}: sum{r in routes: potentialPassenger[a,r] > 0} Assign[a,r] <= avail[a];
subject to PassengerBalance{r in routes}: sum{a in aircraft: potentialPassenger[a,r] > 0} potentialPassenger[a,r] * Assign[a,r]
+ TurnedAway[r] - EmptySeats[r] = demand[r];
© 2009 H.I. Gassmann
Frontline systems• Robust optimization• Chance constraints• Recourse models• Expected value, VaR, CVar objectives• One or two stages• Continuous distributions (automatic sampling)• Deterministic equivalent or simulation• Example
© 2009 H.I. Gassmann
SMI (Stochastic Modeling Interface)
• Coin-OR project• API for interaction with stochastic models• Scenario-based• Discrete distributions
© 2009 H.I. Gassmann
Optimization Services• The Optimization Services project aims to provide
A set of standards to facilitate communication between modeling languages, solvers, problem analyzers, simulation engines, and registry and discovery services in a distributed computing environment.
© 2009 H.I. Gassmann
Solvers
AML
Corporate databases
User interfaceData inter-
change
© 2009 H.I. Gassmann
What Is Optimization Services (OS)?A set of XML-based standards for representing, among others,
– optimization instances (OSiL, also OSgL, OSnL and OSsL)– optimization results (OSrL and OSaL)– optimization solver options (OSoL)– communication between clients and solvers (OSpL)
• Open source libraries to work with these standards• A robust API for solver algorithms and modeling systems • Support for linear, integer, nonlinear and stochastic programs• A command line executable OSSolverService• Executables OSAmplClient and GAMSLinks for AMPL and GAMS • Utilities to convert MPS files and AMPL nl files into OSiL• Server software that works with Apache Tomcat and Apache Axis
© 2009 H.I. Gassmann
Why a standard interface?
.
.
....
Modelling systems
Solvers
.
.
....
Modelling systems
Solvers
n*m hook-ups n+m hook-ups
© 2009 H.I. Gassmann
Why XML?• Existing parsers to check syntax• Easy to generate automatically• Tree structure naturally mirrors expression trees for
nonlinear functions• Arbitrary precision and name space• Automatic attribute checking (e.g., nonnegativity)• Querying capabilities via XQuery• Encryption standards being developed• Easy integration into broader IT infrastructure
© 2009 H.I. Gassmann
OSiL Schema – Deterministic data
…
© 2009 H.I. Gassmann
Representation of uncertainty• Explicit event trees
– Scenario formulation– Only record data items that differ from parent scenario
• Implicit trees (distribution-based formulation)– Assume independence between stages– Distributions within stage discrete or continuous
• Probabilistic constraints– Simple chance constraints– Joint chance constraints
© 2009 H.I. Gassmann
OSInstance: In-memory representation
• XML elements correspond to C++ classes• Child elements mapped as member classes
• set(), get() and calculate() methods
class OSInstance{public: OSInstance(); InstanceHeader *instanceHeader; InstanceData *instanceData;}; // class OSInstance
© 2009 H.I. Gassmann
OSoL – OS option language• Solver options• Initializations of variables• System requirements• Job parameters• In-memory representation: OSOption• API: get(), set(), add() methods
© 2009 H.I. Gassmann
OSrL and OSResult• Result of the optimization
– Solution status– Statistics– Value of primal and dual variables
• Can be displayed in a browser
© 2009 H.I. Gassmann
Solver support• All versions of OS download with COIN-OR solvers
– Clp– Cbc– Ipopt– Bonmin– Couenne– Symphony
• Additiona solver support– Cplex– GLPK– Lindo
© 2009 H.I. Gassmann
Future developments• Stochastic programming• Cone programming• Instance modification• Solution analysis
© 2009 H.I. Gassmann
Other software• SLP-IOR• SPInE/SAMPL/SMPL• Fort-SP• DECIS• MSLiP• …
© 2009 H.I. Gassmann
Conclusions• Slow but steady progress• Stochastic programming is more than scenario
trees and deterministic equivalents• SP-aware modeling systems