File Reference

Go to the source code of this file.


def benders_2stage.get_data_text ()
def benders_2stage.get_master_text ()
def benders_2stage.get_sub_text ()

Variables = GamsWorkspace(system_directory = sys.argv[1]) = ws.add_job_from_string(get_data_text())
 benders_2stage.opt_data = ws.add_options()
 benders_2stage.scenario_data = data.out_db["ScenarioData"]
 benders_2stage.opt = ws.add_options()
int benders_2stage.maxiter = 40
 benders_2stage.cp_master = ws.add_checkpoint()
 benders_2stage.cp_sub = ws.add_checkpoint()
 benders_2stage.master = ws.add_job_from_string(get_master_text())
 benders_2stage.masteri = cp_master.add_modelinstance()
 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.theta_fix = masteri.sync_db.add_parameter("thetaFix", 0, "")
 benders_2stage.sub = ws.add_job_from_string(get_sub_text())
 benders_2stage.subi = cp_sub.add_modelinstance()
 benders_2stage.received = subi.sync_db.add_parameter("received", 1, "units received from master")
 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
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