benders_2stage.py File Reference

This example demonstrates a sequential implementation of a simple Benders decomposition method for a stochastic linear program. More...

Go to the source code of this file.

## Functions

def benders_2stage.get_data_text ()

def benders_2stage.get_master_text ()

def benders_2stage.get_sub_text ()

## Variables

benders_2stage.ws = GamsWorkspace(system_directory = sys.argv[1])

benders_2stage.scenario_data = data.out_db["ScenarioData"]

int benders_2stage.maxiter = 40

benders_2stage.all_model_types

benders_2stage.databases

benders_2stage.cutconst = masteri.sync_db.add_parameter("cutconst", 1, "Benders optimality cut constant")

benders_2stage.cutcoeff = masteri.sync_db.add_parameter("cutcoeff", 2, "Benders optimality coefficients")

benders_2stage.theta = masteri.sync_db.add_variable("theta", 0, VarType.Free, "Future profit function variable")

benders_2stage.demand = subi.sync_db.add_parameter("demand", 1, "stochastic demand")

benders_2stage.lowerbound = float('-inf')

benders_2stage.upperbound = float('inf')

benders_2stage.objmaster = float('inf')

int benders_2stage.iter = 1

benders_2stage.value

float benders_2stage.objsub = 0.0

benders_2stage.probability = scenario_data.find_record((s.key(0), "prob")).value

## Detailed Description

This example demonstrates a sequential implementation of a simple Benders decomposition method for a stochastic linear program.

The underlying model implements a simple distribution system with stochastic demand data. The master and the subproblems are implemented with the GAMSModelInstance object which allows resolving the model with modified input without regenerating the model. A GamsModelInstance has a fixed model rim, so this provides a challenge for Benders master problem because every iteration adds new constraints (the Benders cuts) to the master. We get around this limitation of GamsModelInstance by initializing the GamsModelInstance of the master with a fixed number of empty (i.e. non-binding) placeholders constraints and during the run of the algorithm turn these placeholder constraints into valid Benders cuts.

Definition in file benders_2stage.py.