benders_2stage Namespace Reference

Functions

def get_data_text ()
 
def get_master_text ()
 
def get_sub_text ()
 

Variables

 ws = GamsWorkspace(system_directory = sys.argv[1])
 
 data = ws.add_job_from_string(get_data_text())
 
 opt_data = ws.add_options()
 
 scenario_data = data.out_db["ScenarioData"]
 
 opt = ws.add_options()
 
int maxiter = 40
 
 all_model_types
 
 cp_master = ws.add_checkpoint()
 
 cp_sub = ws.add_checkpoint()
 
 master = ws.add_job_from_string(get_master_text())
 
 databases
 
 masteri = cp_master.add_modelinstance()
 
 cutconst = masteri.sync_db.add_parameter("cutconst", 1, "Benders optimality cut constant")
 
 cutcoeff = masteri.sync_db.add_parameter("cutcoeff", 2, "Benders optimality coefficients")
 
 theta = masteri.sync_db.add_variable("theta", 0, VarType.Free, "Future profit function variable")
 
 theta_fix = masteri.sync_db.add_parameter("thetaFix", 0, "")
 
 sub = ws.add_job_from_string(get_sub_text())
 
 subi = cp_sub.add_modelinstance()
 
 received = subi.sync_db.add_parameter("received", 1, "units received from master")
 
 demand = subi.sync_db.add_parameter("demand", 1, "stochastic demand")
 
 lowerbound = float('-inf')
 
 upperbound = float('inf')
 
 objmaster = float('inf')
 
int iter = 1
 
 value
 
float objsub = 0.0
 
 probability = scenario_data.find_record((s.key(0), "prob")).value
 

Function Documentation

◆ get_data_text()

def benders_2stage.get_data_text ( )

Definition at line 21 of file benders_2stage.py.

21def get_data_text():
22  return '''
23 Sets
24  i factories /f1*f3/
25  j distribution centers /d1*d5/
26 
27 Parameter
28  capacity(i) unit capacity at factories
29  /f1 500, f2 450, f3 650/
30  demand(j) unit demand at distribution centers
31  /d1 160, d2 120, d3 270, d4 325, d5 700 /
32  prodcost unit production cost /14/
33  price sales price /24/
34  wastecost cost of removal of overstocked products /4/
35 
36 Table transcost(i,j) unit transportation cost
37  d1 d2 d3 d4 d5
38  f1 2.49 5.21 3.76 4.85 2.07
39  f2 1.46 2.54 1.83 1.86 4.76
40  f3 3.26 3.08 2.60 3.76 4.45;
41 
42 $ifthen not set useBig
43 Set
44  s scenarios /lo,mid,hi/
45 
46 table ScenarioData(s,*) possible outcomes for demand plus probabilities
47  d1 d2 d3 d4 d5 prob
48 lo 150 100 250 300 600 0.25
49 mid 160 120 270 325 700 0.50
50 hi 170 135 300 350 800 0.25;
51 $else
52 $if not set nrScen $set nrScen 10
53 Set s scenarios /s1*s%nrScen%/;
54 parameter ScenarioData(s,*) possible outcomes for demand plus probabilities;
55 option seed=1234;
56 ScenarioData(s,'prob') = 1/card(s);
57 ScenarioData(s,j) = demand(j)*uniform(0.6,1.4);
58 $endif
59 '''
60 

◆ get_master_text()

def benders_2stage.get_master_text ( )

Definition at line 61 of file benders_2stage.py.

◆ get_sub_text()

def benders_2stage.get_sub_text ( )

Definition at line 118 of file benders_2stage.py.

Variable Documentation

◆ all_model_types

benders_2stage.all_model_types

Definition at line 181 of file benders_2stage.py.

◆ cp_master

benders_2stage.cp_master = ws.add_checkpoint()

Definition at line 183 of file benders_2stage.py.

◆ cp_sub

benders_2stage.cp_sub = ws.add_checkpoint()

Definition at line 184 of file benders_2stage.py.

◆ cutcoeff

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

Definition at line 191 of file benders_2stage.py.

◆ cutconst

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

Definition at line 190 of file benders_2stage.py.

◆ data

benders_2stage.data = ws.add_job_from_string(get_data_text())

Definition at line 168 of file benders_2stage.py.

◆ databases

benders_2stage.databases

Definition at line 187 of file benders_2stage.py.

◆ demand

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

Definition at line 200 of file benders_2stage.py.

◆ iter

int benders_2stage.iter = 1

Definition at line 208 of file benders_2stage.py.

Referenced by benders_2stage_mt.scen_solve().

◆ lowerbound

benders_2stage.lowerbound = float('-inf')

Definition at line 205 of file benders_2stage.py.

◆ master

benders_2stage.master = ws.add_job_from_string(get_master_text())

Definition at line 186 of file benders_2stage.py.

◆ masteri

benders_2stage.masteri = cp_master.add_modelinstance()

Definition at line 189 of file benders_2stage.py.

◆ maxiter

int benders_2stage.maxiter = 40

Definition at line 179 of file benders_2stage.py.

◆ objmaster

benders_2stage.objmaster = float('inf')

Definition at line 207 of file benders_2stage.py.

◆ objsub

float benders_2stage.objsub = 0.0

Definition at line 232 of file benders_2stage.py.

◆ opt

benders_2stage.opt = ws.add_options()

Definition at line 177 of file benders_2stage.py.

◆ opt_data

benders_2stage.opt_data = ws.add_options()

Definition at line 170 of file benders_2stage.py.

◆ probability

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

Definition at line 241 of file benders_2stage.py.

◆ received

benders_2stage.received = subi.sync_db.add_parameter("received", 1, "units received from master")

Definition at line 199 of file benders_2stage.py.

◆ scenario_data

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

Definition at line 176 of file benders_2stage.py.

◆ sub

benders_2stage.sub = ws.add_job_from_string(get_sub_text())

Definition at line 196 of file benders_2stage.py.

◆ subi

benders_2stage.subi = cp_sub.add_modelinstance()

Definition at line 198 of file benders_2stage.py.

◆ theta

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

Definition at line 192 of file benders_2stage.py.

◆ theta_fix

benders_2stage.theta_fix = masteri.sync_db.add_parameter("thetaFix", 0, "")

Definition at line 193 of file benders_2stage.py.

◆ upperbound

benders_2stage.upperbound = float('inf')

Definition at line 206 of file benders_2stage.py.

◆ value

benders_2stage.value

Definition at line 215 of file benders_2stage.py.

◆ ws

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

Definition at line 164 of file benders_2stage.py.