More Related Content
Similar to Seminar: New Stochastic Programming Features for MPL - Nov 2011
Similar to Seminar: New Stochastic Programming Features for MPL - Nov 2011 (20)
More from Bjarni Kristjánsson
More from Bjarni Kristjánsson (11)
Seminar: New Stochastic Programming Features for MPL - Nov 2011
- 1. Stochastic Extensions
New Stochastic Programming Features
for the MPL Modeling Language
Presented by
Bjarni Kristjansson
Maximal Software, Inc.
Copyright © 2011 Maximal Software, Inc. All rights reserved
1
- 2. Presentation Overview
• Previous Stochastic Work
• Design Issues for Modeling Languages
• New Keywords for Stochastic Models
• Stochastic Programming with MPL
• Formulating Scenario-Based Models in MPL
• Formulating Independent Variable Models in MPL
• Solving Stochastic Models with CPLEX and GUROBI
• Demonstration of MPL Stochastic Models
• News on Gurobi Support and Academic Program
Copyright © 2011 Maximal Software, Inc. All rights reserved
2
- 3. Previous Stochastic Work
MPL/SPInE Project
• Collaboration project with Brunel University
• Fully implemented Scenario-based modeling for MPL
• Solved models using FortSP (Nested Benders)
• Could also compute HN, WS, EV, DEQ
• Generated SMPS format
But there were some issues:
• Designed as preprocessor for MPL
• Separate MPL file generated for every scenario
• Serious scalability issues
• Lacking support for other model types (indep variables, etc.)
• Limited to a single stochastic solver
Copyright © 2011 Maximal Software, Inc. All rights reserved
3
- 4. New Project: Stochastic Support for MPL
Current release of MPL provides following support for
Stochastic Programming:
• Multiple model types (Scenarios, Independent, etc.)
• New keywords and cleanup on syntax
• New callable library interface (C-API)
• Support for multiple solvers (BendX, FortSP, Coin-SMI, etc.)
• Support for both SMPS and OptML (XML)
Copyright © 2011 Maximal Software, Inc. All rights reserved
4
- 5. MPL Stochastic Extensions
• New Syntax for stochastic models in MPL
• Data structures for storing stochastic information
• Callable Interface for Stochastic Programming
• New Stochastic Solver - BendX (Callable Library)
Deterministic Equivalent
Two-stage Benders
Multi-stage Benders
• Connect to BendX to MPL
• SMPS Reader/Writer
• XML Reader/Writer (OptML/OSiL)
• Create Model Library
• Testing Software
• Release to Market
Copyright © 2011 Maximal Software, Inc. All rights reserved
5
- 6. Design Issues for Modeling Languages
Stochastic Representation in Modeling Language
should be:
• Readable
• Straightforward
• Compact
• Efficient Model Generation
• Interface Directly with Solvers
• Utilize Original Data
• Complete
• Extensible
Copyright © 2011 Maximal Software, Inc. All rights reserved
6
- 7. Keywords for Scenario Based Models
STOCHASTIC
Keyword marking the start of stochastic formulation (optional)
TIME
Index used to describe the temporal horizon (optional)
STAGES
Decision stages for the model (optional)
STAGEMAP
Mapping of time index into stages (optional)
SCENARIO
Index used identify the scenarios
TREE
Specify the structure of the event tree for the scenarios (optional)
PROBABILITIES
Probabilities (discrete) associated with each scenario
RANDOM DATA
Random parameters of the problem for each scenario
Copyright © 2011 Maximal Software, Inc. All rights reserved
7
- 8. Keywords for Discrete Based Models
STOCHASTIC
Keyword marking the start of stochastic formulation (optional)
STAGES
Decision stages for the model (optional)
STAGEMAP
Mapping of time index into stages (optional)
INDEP
Index for the independent variables
OUTCOME
The values representing outcome of the independent variables
EVENT
Connect outcomes to independent variables (optional)
PROBABILITIES
Probabilities (discrete) associated with each outcome
RANDOM DATA
Random parameters of the problem for each outcome
Copyright © 2011 Maximal Software, Inc. All rights reserved
8
- 9. Farmer Model (sample from Birge book)
TITLE
Farmer;
STOCHASTIC
SCENARIO
sc := 1..3;
INDEX
crop := (Wheat,Corn,SugarB);
prLevel := 1..2;
PROBABILITIES
Prob[sc] := ALLEQUAL;
RANDOM DATA
Yield[crop,sc] := SPARSEFILE("Farmer.dat");
DATA
Cost[crop] := (150,230,260);
SellPrice[crop,prLevel] := (170, 0,
150, 0,
36, 10);
PurPrice[crop] := (238, 210, 0);
MinReq[crop] := (200,240, 0);
AvailLand := 500;
MaxBeets := 6000;
Copyright © 2011 Maximal Software, Inc. All rights reserved
9
- 10. Farmer Model (cont.)
VARIABLES
Plant[crop];
STAGE2 VARIABLES
CropPurchased[crop] WHERE (PurPrice > 0);
CropSold[crop,prLevel] WHERE (SellPrice > 0);
MODEL
MIN TotalCost = - SUM(crop,prLevel: SellPrice * CropSold)
+ SUM(crop: PurPrice * CropPurchased)
+ SUM(crop: Cost * Plant);
SUBJECT TO
LandUse: SUM(crop: Plant) <= AvailLand;
MeetMinReq[crop]: - Yield * Plant
- CropPurchased
+ SUM(prLevel: CropSold)
<= -MinReq;
BeetCap[crop=SugarB]: Yield * Plant
- SUM(prLevel: CropSold)
>= 0.0;
BOUNDS
CropSold[crop:=SugarB,prLevel:=1] <= MaxBeets;
END
Copyright © 2011 Maximal Software, Inc. All rights reserved
10
- 11. Aircraft Allocation Model
TITLE
AircraftAlloc;
STOCHASTIC
INDEX
aircraft := (A,B,C,D);
INDEP
route := (NL1, NL2, ND0, ND1, NB0) -> {r1,r2,r3,r4,r5);
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,
. . . . . . .
NB0, 2, 0.8,
NB0, 3, 0.1];
Copyright © 2011 Maximal Software, Inc. All rights reserved
11
- 12. Aircraft Allocation Model (cont.)
RANDOM DATA
Demand[route, out5 IN RouteOut] :=
[NL1, 1, 200,
NL1, 2, 220,
. . . . . . .
NB0, 2, 600,
NB0, 3, 620];
DATA
AircraftAvail[aircraft] := (10, 19, 25, 15);
PriceTicket[route] := (13, 13, 7, 7, 1);
PotentialPass[aircraft, route]
:= (16, 15, 28, 23, 81,
, 10, 14, 15, 57,
, 5, , 7, 29,
9, 11, 22, 17, 55);
MonthlyCost[aircraft, route]
:= (18, 21, 18, 16, 10,
, 15, 16, 14, 9,
, 10, , 9, 6,
17, 16, 17, 15, 10);
DECISION VARIABLES
Assign[aircraft, route] -> x
WHERE (PotentialPass > 0);
Copyright © 2011 Maximal Software, Inc. All rights reserved
12
- 13. Aircraft Allocation Model (cont.)
STAGE2 VARIABLES
EmptySeats[route] -> y1;
TurnedAway[route] -> y2;
MACRO
OperatingCost := SUM(aircraft, route: MonthlyCost * Assign);
LostRevenue := SUM(route: PriceTicket * TurnedAway);
MODEL
MIN TotalCost = OperatingCost + LostRevenue;
SUBJECT TO
AircraftCap[aircraft]:
SUM(route: Assign)
<=
AircraftAvail;
PassBal[route]:
SUM(aircraft: PotentialPass * Assign)
+ TurnedAway[route]
- EmptySeats[route]
=
Demand[route];
END
Copyright © 2011 Maximal Software, Inc. All rights reserved
13
- 14. BendX - Callable Library Interface (C-API)
int BendxLoadStochStages(HPROB hProb, int StageCount,
int *VarStages, int *ConStages,
char **StageNames);
int BendxLoadStochTree(HPROB hProb, int TreeType, int TreeCount,
int *TreeData, int *TreeData2);
int BendxLoadStochScenarios(HPROB hProb, int ScenCount, double *ProbData,
int *TreeStageStart, int *ScenBegin,
int RandomCount, int *RandomCol,
int *RandomRow, double *RandomData,
char **ScenNames);
int BendxLoadStochIndep(HPROB hProb, int IndepCount, int *RandomCol,
int *RandomRow, int *OutcomeCounts, int EventCount,
double *ProbData, double *RandomData);
int BendxLoadStochBlocks(HPROB hProb, int IndepCount, int *OutcomeCounts,
int EventCount, double *ProbData, int *EventBegin,
int RandomCount, int *RandomCol, int *RandomRow,
double *RandomData);
Copyright © 2011 Maximal Software, Inc. All rights reserved
14