Searching...
No Matches
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.

## Variables

str benders_2stage.GAMS_DATA

str benders_2stage.GAMS_MASTER_MODEL

str benders_2stage.GAMS_SUB_MODEL

sys benders_2stage.sys_dir = sys.argv[1] if len(sys.argv) > 1 else None

GamsWorkspace benders_2stage.ws = GamsWorkspace(system_directory=sys_dir)

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

int benders_2stage.max_iter = 40

benders_2stage.all_model_types

benders_2stage.databases

GamsWorkspace benders_2stage.cutconst

GamsWorkspace benders_2stage.cutcoeff

GamsWorkspace benders_2stage.theta

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

float benders_2stage.lower_bound = float("-inf")

float benders_2stage.upper_bound = float("inf")

float benders_2stage.obj_master = float("inf")

int benders_2stage.it = 1

benders_2stage.value

float benders_2stage.obj_sub = 0.0

GamsWorkspace 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. Both the master and the sub problems are implemented with the GamsModelInstance 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) placeholder constraints and turn them into valid Benders cuts during the run of the algorithm.

Definition in file benders_2stage.py.

GAMS Development Corp.
GAMS Software GmbH

General Information and Sales
U.S. (+1) 202 342-0180
Europe: (+49) 221 949-9170
GAMS is a registered trademark of GAMS Software GmbH in the European Union