Table of Contents
Introduction
DE is a solver for stochastic programs modeled with GAMS Extended Mathematical Programming for Stochastic Programming (EMP SP). DE can solve multi-stage LP, MIP, QCP, NLP and MINLP stochastic programming models. For details about EMP SP and the syntax to modify an existing GAMS model to be an stochastic programming model in GAMS EMP SP see Stochastic Programming. A list of DE solver options is given at the end of this document.
Stochastic programs are mathematical programs that include data that is not known with certainty, but is approximated by probability distributions. The simplest form of a stochastic program is the two-stage stochastic linear program with recourse. In mathematical terms it is defined as follows.
Let
The first two lines define the first-stage problem and the last two lines define the second-stage problem. In the first stage,
In the first stage, a decision has to be made before the realization of the uncertain data is clear. The optimal solution of the first stage is fixed and only then the values that the uncertain parameters take will become known. Given the fixed solution of the first stage and the new data, in the second stage recourse action can be taken and the optimal solution determined. Each possible realization of the uncertain data is represented by an
One of the most common methods to solve a two-stage stochastic LP is to build and solve the deterministic equivalent. Assume that the uncertain parameters follow a (finite) discrete distribution and that each scenario
Note that for stochastic linear programs the deterministic equivalent is just a very large linear program.
The solver DE automatically generates the deterministic equivalent of a stochastic program and then hands it over for solution to a solver, termed the subsolver. The subsolver is the default solver for the type of model to be solved. The user may choose another subsolver with the option subsolver.
If modelers want to use DE, they may either add the option
option emp = de;
before the solve
statement in the model or they may choose the solver DE on the command line, e.g.
gams mymodel.gms emp=de
Random Variables
Random variables and their distributions and stages determine the number of scenarios in the model and thus the number of equations that are generated for the deterministic equivalent. If there are two or more random variables in one stage they may be jointly distributed or not.
Assume that there is a two-stage stochastic model
In addition to two-stage stochastic models, DE can also solve multi-stage stochastic models. Let
The following figure illustrates the scenario tree of a stochastic model with four stages.

Note that the structure of the scenario tree is limited: each node in a stage has exactly the same number of arcs.
If there is more than one random variable per stage, then the number of scenarios increases accordingly. Note that there is no absolute limit to the number of stages and random variables, but the model can become very large very quickly as the number of stages and random variables increases. Note further that the random variables are stagewise independent. The realization of the random variables in one stage does not influence the realization of the random variables in a later stage.
Sampling Procedures
DE can solve only stochastic programs with random variables that follow discrete probability distributions. If the random data follows a continuous probability distribution the set sample
to facilitate sampling. An example follows.
randvar d normal 45 10 sample d 100
These two lines are a portion of the emp.info
file. In the first line d
is defined as a random variable that follows a Normal distribution with mean 45 and standard deviation 10. In the second line it is specified that the continuous distribution is approximated by a sample of size 100. Note that the user determines the sample size sample
is mandatory for random variables with continuous distributions. Otherwise the following error message will appear:
*** Only random variables with sampled continuous distributions supported.
Observe that behind the scenes the sampling is performed by the LINDO system. So the modeler needs a LINDO licence for sample sizes larger than 10 (smaller sample sizes are included in the demo version). The LINDO system offers three variance reduction algorithms: the Antithetic algorithm, the Latin Square algorithm and the Monte Carlo algorithm. They may be enabled using either the option svr_ls_antithetic or svr_ls_latinsquare or svr_ls_montecarlo respectively.
Alternatively, the modeler may chose to generate a sample of the distribution first and then enter the sample as a discrete distribution in the emp.info
file. There are two stochastic libraries that can be used for this procedure: the GAMS Stochastic Library and the LINDO Sampling Library. An example and details about the procedure using the LINDO library are given in section Sampling in the EMP manual.
The Expected Value Problem
Consider the special case where the sample size is 1 and the "sampled" value equals the expected value of the random variable. This entails that the random variable is replaced by its expected value. The resulting model is deterministic and is called the Expecetd Value Program. DE facilitates solving the Expected Value Problem through the option solveEVProb. If this option is specified in the option file (see example below) the Expected Value Problem is solved after the original stochastic model and the solution is reported. In addition, DE offers the option to choose a separate subsolver for the Expecetd Value Problem, the option evsubsolver.
In the following example the stochastic model is solved with the subsolver Conopt and the Expected Value Problem is solved with the subsolver Minos.
$onecho > de.opt subsolver conopt solveEVProb evsubsolver minos $offecho mymodel.optfile=1; solve mymodel min obj using emp scenario dict;
Note that the option solveEVProb is not defined for models with chance constraints and models featuring VaR and CVaR. These model types are discussed in the next section.
What types of models can DE handle?
As mentioned earlier, DE can solve two-stage and multi-stage stochastic linear, quadratic and nonlinear models and the mixed-integer versions of all these models. There are two further classes of stochastic models that DE is equipped to solve: stochastic programs with chance constraints and stochastic programs with other risk measures such as Variance at Risk (VaR) and Conditional Variance at Risk (CVaR). CVaR is also called Expected Shortfall.
In stochastic programs with chance constraints the goal is to make an optimal decision prior to the realization of random data while allowing the constraints to be violated with a certain probability. Mathematically, a stochastic linear program with chance constraints can be expressed as follows:
where
DE offers three reformulation options to solve stochastic programs with chance constraints: a reformulation using a mixed-integer program with big
For details on single and joint chance constraints and examples how to use the option ccreform
, see the section Chance Constraints with EMP in the EMP manual. Note that random variables in programs with chance constraints may follow discrete or continuous probability distributions. Note further that there are no stages in stochastic programs with chance constraints.
As mentioned earlier, DE automatically optimizes the expected value of the objective function variable. DE also supports other risk measures, such as VaR and CVaR. In mathematical terms, DE is able to solve the following:
where
Reformulation Techniques
In this section some details are given about the reformulations that DE is performing behind the scenes.
Simple two-stage stochastic model
As mentioned previously, DE converts a stochastic model into its deterministic equivalent. Using the model nbsimple.gms
from the GAMS EMP model library as an example, we show how exactly the deterministic equivalent is built. Note that this model is also discussed in detail in the section A Simple Example: The News Vendor Problem of the EMP manual.
The model is given by the following equations:
where
Here
First, DE draws 4 values from the Normal distribution specified in the annotations. These 4 values are the basis for the 4 scenarios that are generated. For each scenario, a separate equation for the two second-stage constraints is built (that are 8 equations). In the process, for each of the three decison variables of the second stage 4 variables are generated since the second-stage decison variables may take different values for each scenario. Next, an equation for the profit for each scenario is generated (4 equations) and finally, the equation to compute the average profit is built. So there are a total of 13 equations. They are given here:
Note that there is only one realization of the first-stage decision variable
A multi-stage stochastic model
DE recursively builds a scenario tree to generate the deterministic equivalent of multi-stage models. We take the model inventory
from the EMP manual to demonstrate how this is done. The 4-stage model is given by the following equations:
where
Here
This model is reformulated in the following way. First, an equation for the first stage constraint is generated. Secondly, three realizations of
Chance Constraints
Models with chance constraints are reformulated as mixed integer problems by default. This reformulation is discussed in detail in the section Chance Constraints with EMP in the EMP manual. Reformulations using a convex hull or indicator variables and indicator constraints are also possible. The reformulation method may be determined by the user with the option ccreform.
Computing VaR
Models involving VaR are reformulated using mixed integer programs with big portfolio.gms
we demonstrate how this is done. This model is discussed in the section Value at Risk (VaR) in the EMP manual. The model is given by the following equations:
where
Let
Here
Note that the default value for big
Computing CVaR
Models with CVaR are reformulated by converting the annotations into new variables and equations. Using the model portfolio.gms
as an example we demonstrate how this is done. This model features in the GAMS EMP library and is also discussed in the section Conditional Value at Risk (CVaR) in the EMP manual. The model is given by:
where
DE reformulates this model by introducing three new variables and three associated equations. Let
Thus the model is reformulated to an LP and may be solved by an appropriate solver. It is easy to see that
Logfile
The logfile gives much information about the solver progress. The following is the DE log output from running the nbdiscjoint model from the GAMS EMP Model Library:
--- Starting compilation --- nbdisjoint.gms(74) 3 Mb --- Starting execution: elapsed 0:00:00.024 --- nbdisjoint.gms(72) 4 Mb --- --- collecting and writing gdx file --- --- Generating EMP model nb --- nbdisjoint.gms(72) 6 Mb --- 5 rows 9 columns 19 non-zeroes --- 6 nl-code 2 nl-non-zeroes --- nbdisjoint.gms(72) 4 Mb --- Executing DE: elapsed 0:00:00.083 --- Input model type identified and solved as LP DE 24.5.1 r54187 Released Sep 23, 2015 DEG x86 64bit/MacOS X --- DE has 26 rows 50 columns 116 non-zeroes IBM ILOG CPLEX 24.5.1 r54187 Released Sep 23, 2015 DEG x86 64bit/MacOS X Cplex 12.6.2.0 Reading data... Starting Cplex... Unable to load names. Tried aggregator 1 time. LP Presolve eliminated 14 rows and 31 columns. Reduced LP has 12 rows, 19 columns, and 36 nonzeros. Presolve time = 0.01 sec. (0.02 ticks) Iteration log . . . Iteration: 1 Dual infeasibility = 52.800000 Iteration: 10 Dual objective = 2660.700000 LP status(1): optimal Cplex Time: 0.06sec (det. 0.05 ticks) Optimal solution found. Objective : 1173.900000 --- Restarting execution --- nbdisjoint.gms(72) 2 Mb --- Reading solution for model nb --- nbdisjoint.gms(72) 3 Mb --- --- scattering and reading gdx file --- --- randvar Id = d maps to s_d --- nbdisjoint.gms(72) 3 Mb --- randvar Id = r maps to s_r --- level Id = s maps to s_s --- level Id = x maps to s_x --- nbdisjoint.gms(72) 4 Mb --- Scatter finished in 2 ms --- nbdisjoint.gms(74) 4 Mb *** Status: Normal completion --- Job nbdisjoint.gms Stop 12/06/15 18:02:47 elapsed 0:00:00.382
First, the model in scalar form is generated. It has 5 equations, so the model statistics report 5 rows. Further, it has 6 positive variables, one free variable and 2 random variables, so there are 9 columns. A matrix form representation of the model with the variables as columns and the equations as rows has 19 non-zero entries. Next, DE generates the deterministic equivalent. The statistics for the deterministic equivalent indicate that there are 26 rows, 50 columns and 116 non-zero entries. The stochastic model has 6 scenarios, so for each second-stage equation there are 6 equations in the deterministic equivalent (i.e. a total of 24 equations). In addition, there is one first-stage equation and one equation to compute the expected value of the objective variable, which brings the sum total to 26 equations or rows. Similarly, for each second-stage variable in the stochastic model there are 6 variables in the determininistic equivalent (i.e a total of 48 variables). In addition, there is the first-stage decision variable and a variable for the expected value of the objective adding up to a total of 50 variables or columns.
Note that the model type is identified as an LP and thus the default LP solver is invoked. In this case the subsolver is Cplex and most of the remainder of the logfile is output from the subsolver. At the end the mapping specified in the dictionary is performed.
The logfile of solving stochastic models with VaR or CVaR is similar. It reports that the model type is being determined, the deterministic equivalent built and then handed over to the appropriate subsolver to be solved. However, when solving stochastic programs with chance constraints there is much more happening behind the scenes. DE automatically hands over the model to the subsolver JAMS. By default, JAMS reformulates the model and generates a scalar version of it. The scalar version of the reformulated model is then handed back to the GAMS system to be solved by an appropriate subsolver. The logfile reports the progress of the subsolver until the model is solved. Then the solution from the GAMS subsolver is handed to JAMS and a list of disjunsctions and their activity level is reported. (The equations in the scalar version of the reformulated model that may be left unsatisfied are called disjunctions. Active disjunctions refer to equations that are satisfied and not active disjunctions refer to equations that are not satisfied.)
Parts of the DE logfile from running the simplechance model from the GAMS EMP Model Library are given below. These parts of the logfile demonstrate the solution process for stochastic models with chance constraints that was just described.
... --- Generating EMP model sc --- simplechance.gms(79) 6 Mb --- 3 rows 5 columns 9 non-zeroes --- 9 nl-code 4 nl-non-zeroes --- simplechance.gms(79) 4 Mb --- Executing DE: elapsed 0:00:00.024 --- Input model type identified and solved as LP DE 24.5.1 r54187 Released Sep 23, 2015 DEG x86 64bit/MacOS X --- Reset Solvelink = 2 JAMS 1.0 24.5.1 r54187 Released Sep 23, 2015 DEG x86 64bit/MacOS X JAMS - Solver for Extended Mathematical Programs (EMP) ------------------------------------------------------ --- Using Option File Reading parameter(s) from "jams.159" >> EMPInfoFile .../Models/225a/jamsinfo.dat >> SubSolver CPLEX Finished reading from "jams.159" --- EMP Summary Logical Constraints = 0 Disjunctions = 7 Adjusted Constraint = 0 Flipped Constraints = 0 Dual Variable Maps = 0 Dual Equation Maps = 0 VI Functions = 0 Equilibrium Agent = 0 Bilevel Followers = 0 *** Warning 7 of 7 BigM disjunctions use DE's default for bigM (10000) --- The model .../Models/225a/emp.dat will be solved by GAMS --- --- Job emp.dat Start 12/06/15 18:43:18 24.5.1 r54187 DEX-DEG x86 64bit/MacOS X GAMS 24.5.1 Copyright (C) 1987-2015 GAMS Development. All rights reserved ... --- Generating MIP model m --- emp.dat(68) 3 Mb --- 10 rows 19 columns 40 non-zeroes --- 7 discrete-columns --- Executing CPLEX: elapsed 0:00:00.016 IBM ILOG CPLEX 24.5.1 r54187 Released Sep 23, 2015 DEG x86 64bit/MacOS X Cplex 12.6.2.0 Reading data... Starting Cplex... .... MIP Solution: 4.750000 (11 iterations, 0 nodes) Final Solve: 4.750000 (2 iterations) ... --- Reading solution for model m *** Status: Normal completion --- Job emp.dat Stop 12/06/15 18:43:18 elapsed 0:00:00.299 --- Returning from GAMS step --- --- Disjunction Summary Disjunction 1 is not active Disjunction 2 is active Disjunction 3 is active Disjunction 4 is active Disjunction 5 is not active Disjunction 6 is active Disjunction 7 is active --- --- Restarting execution --- simplechance.gms(79) 2 Mb --- Reading solution for model sc --- simplechance.gms(79) 3 Mb --- --- scattering and reading gdx file --- --- randvar Id = om1 maps to s_om1 --- simplechance.gms(79) 3 Mb --- randvar Id = om2 maps to s_om2 --- level Id = x1 maps to x1_l --- marginal Id = x1 maps to x1_m --- level Id = x2 maps to x2_l --- level Id = e1 maps to e1_l --- level Id = e2 maps to e2_l --- simplechance.gms(79) 4 Mb --- Scatter finished in 2 ms --- simplechance.gms(81) 4 Mb *** Status: Normal completion
Summary of DE Options
General Options
Option | Description | Default |
---|---|---|
correlationtype | Sample correlation type | 0 |
empinfofile | Path and name of file containing additional EMP-SP information as randvar, jrandvar, stage etc. | |
subsolver | Subsolver to run | |
subsolveropt | Optfile value to pass to the subsolver | 1 |
svr_ls_antithetic | Sample variance reduction map to Lindo Antithetic algorithm | |
svr_ls_latinsquare | Sample variance reduction map to Lindo Latin Square algorithm | |
svr_ls_montecarlo | Sample variance reduction map to Lindo Montecarlo algorithm |
Options for chance constraint models
Option | Description | Default |
---|---|---|
ccreform | Reformulation option passed to JAMS | bigM |
jamsopt | JAMS option file |
Options for recourse models
Option | Description | Default |
---|---|---|
evsubsolver | Subsolver to run on expected value problem | |
evsubsolveropt | Optfile value to pass to the subsolver for expected value problem | 1 |
maxnodes | Tree size limit | 100000 |
solveEVProb | Solve and report the expected value solution | 0 |
varbigm | Big M for Value at Risk reformulation | 1000.0 |
Detailed Descriptions of DE Options
ccreform (string): Reformulation option passed to JAMS ↵
This option determines how to formulate the indicator contraints of the chance constraints in the deterministic equivalent. The model is passed to JAMS for the actual reformulation and solution with a subsolver. The possible reformulation options are
bigM [big eps threshold]
,chull [big eps]
, andindic
. Theindic
setting only works with solver that under stand the indicator syntax in a GAMS option file.Default:
bigM
correlationtype (integer): Sample correlation type ↵
Default:
0
value meaning 0
Pearson 1
Kendall 2
Spearman
empinfofile (string): Path and name of file containing additional EMP-SP information as randvar, jrandvar, stage etc. ↵
evsubsolver (string): Subsolver to run on expected value problem ↵
evsubsolveropt (integer): Optfile value to pass to the subsolver for expected value problem ↵
Range: {
1
, ...,999
}Default:
1
jamsopt (string): JAMS option file ↵
maxnodes (integer): Tree size limit ↵
Range: {
1000
, ..., ∞}Default:
100000
solveEVProb (no value): Solve and report the expected value solution ↵
Default:
0
subsolver (string): Subsolver to run ↵
subsolveropt (integer): Optfile value to pass to the subsolver ↵
Range: {
1
, ...,999
}Default:
1
svr_ls_antithetic (string): Sample variance reduction map to Lindo Antithetic algorithm ↵
svr_ls_latinsquare (string): Sample variance reduction map to Lindo Latin Square algorithm ↵
svr_ls_montecarlo (string): Sample variance reduction map to Lindo Montecarlo algorithm ↵
varbigm (real): Big M for Value at Risk reformulation ↵
Default:
1000.0