benders_2stage_mt Namespace Reference

Functions

def scen_solve (i, subi, cutconst, cutcoeff, dem_queue, objsub, queue_lock, io_lock)
 
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.get_parameter("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, "")
 
int num_threads = 2
 
list subi = []
 
 dem_queue = queue.Queue()
 
list received = subi[0].sync_db.add_parameter("received", 1, "units received from first stage solution")
 
list demand = subi[0].sync_db.add_parameter("demand", 1, "stochastic demand")
 
 lowerbound = float('-inf')
 
 upperbound = float('inf')
 
 objmaster = float('inf')
 
int it = 1
 
 value
 
dictionary dem_dict = {}
 
float objsubsum = 0.0
 
 queue_lock = threading.Lock()
 
 io_lock = threading.Lock()
 
dictionary coef = {}
 
list objsub = []
 
list cons = []
 
dictionary threads = {}
 
 target
 
 scen_solve
 
 args
 

Function Documentation

◆ get_data_text()

def benders_2stage_mt.get_data_text ( )

Definition at line 53 of file benders_2stage_mt.py.

53def get_data_text():
54  return '''
55 Sets
56  i factories /f1*f3/
57  j distribution centers /d1*d5/
58 
59 Parameter
60  capacity(i) unit capacity at factories
61  /f1 500, f2 450, f3 650/
62  demand(j) unit demand at distribution centers
63  /d1 160, d2 120, d3 270, d4 325, d5 700 /
64  prodcost unit production cost /14/
65  price sales price /24/
66  wastecost cost of removal of overstocked products /4/
67 
68 Table transcost(i,j) unit transportation cost
69  d1 d2 d3 d4 d5
70  f1 2.49 5.21 3.76 4.85 2.07
71  f2 1.46 2.54 1.83 1.86 4.76
72  f3 3.26 3.08 2.60 3.76 4.45;
73 
74 $ifthen not set useBig
75 Set
76  s scenarios /lo,mid,hi/
77 
78 table ScenarioData(s,*) possible outcomes for demand plus probabilities
79  d1 d2 d3 d4 d5 prob
80 lo 150 100 250 300 600 0.25
81 mid 160 120 270 325 700 0.50
82 hi 170 135 300 350 800 0.25;
83 $else
84 $if not set nrScen $set nrScen 10
85 Set s scenarios /s1*s%nrScen%/;
86 parameter ScenarioData(s,*) possible outcomes for demand plus probabilities;
87 option seed=1234;
88 ScenarioData(s,'prob') = 1/card(s);
89 ScenarioData(s,j) = demand(j)*uniform(0.6,1.4);
90 $endif
91 '''
92 

◆ get_master_text()

def benders_2stage_mt.get_master_text ( )

Definition at line 93 of file benders_2stage_mt.py.

◆ get_sub_text()

def benders_2stage_mt.get_sub_text ( )

Definition at line 150 of file benders_2stage_mt.py.

◆ scen_solve()

def benders_2stage_mt.scen_solve (   i,
  subi,
  cutconst,
  cutcoeff,
  dem_queue,
  objsub,
  queue_lock,
  io_lock 
)

Definition at line 28 of file benders_2stage_mt.py.

References benders_2stage.iter, and scen_solve.

Variable Documentation

◆ all_model_types

benders_2stage_mt.all_model_types

Definition at line 213 of file benders_2stage_mt.py.

◆ args

benders_2stage_mt.args

Definition at line 292 of file benders_2stage_mt.py.

◆ coef

dictionary benders_2stage_mt.coef = {}

Definition at line 278 of file benders_2stage_mt.py.

◆ cons

list benders_2stage_mt.cons = []

Definition at line 280 of file benders_2stage_mt.py.

◆ cp_master

benders_2stage_mt.cp_master = ws.add_checkpoint()

Definition at line 215 of file benders_2stage_mt.py.

◆ cp_sub

benders_2stage_mt.cp_sub = ws.add_checkpoint()

Definition at line 216 of file benders_2stage_mt.py.

◆ cutcoeff

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

Definition at line 223 of file benders_2stage_mt.py.

◆ cutconst

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

Definition at line 222 of file benders_2stage_mt.py.

◆ data

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

Definition at line 199 of file benders_2stage_mt.py.

◆ databases

benders_2stage_mt.databases

Definition at line 219 of file benders_2stage_mt.py.

◆ dem_dict

dictionary benders_2stage_mt.dem_dict = {}

Definition at line 261 of file benders_2stage_mt.py.

◆ dem_queue

benders_2stage_mt.dem_queue = queue.Queue()

Definition at line 231 of file benders_2stage_mt.py.

◆ demand

list benders_2stage_mt.demand = subi[0].sync_db.add_parameter("demand", 1, "stochastic demand")

Definition at line 234 of file benders_2stage_mt.py.

◆ io_lock

benders_2stage_mt.io_lock = threading.Lock()

Definition at line 277 of file benders_2stage_mt.py.

◆ it

int benders_2stage_mt.it = 1

Definition at line 244 of file benders_2stage_mt.py.

◆ lowerbound

benders_2stage_mt.lowerbound = float('-inf')

Definition at line 241 of file benders_2stage_mt.py.

◆ master

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

Definition at line 218 of file benders_2stage_mt.py.

◆ masteri

benders_2stage_mt.masteri = cp_master.add_modelinstance()

Definition at line 221 of file benders_2stage_mt.py.

◆ maxiter

int benders_2stage_mt.maxiter = 40

Definition at line 211 of file benders_2stage_mt.py.

◆ num_threads

int benders_2stage_mt.num_threads = 2

Definition at line 229 of file benders_2stage_mt.py.

◆ objmaster

benders_2stage_mt.objmaster = float('inf')

Definition at line 243 of file benders_2stage_mt.py.

◆ objsub

list benders_2stage_mt.objsub = []

Definition at line 279 of file benders_2stage_mt.py.

◆ objsubsum

float benders_2stage_mt.objsubsum = 0.0

Definition at line 274 of file benders_2stage_mt.py.

◆ opt

benders_2stage_mt.opt = ws.add_options()

Definition at line 209 of file benders_2stage_mt.py.

◆ opt_data

benders_2stage_mt.opt_data = ws.add_options()

Definition at line 201 of file benders_2stage_mt.py.

◆ queue_lock

benders_2stage_mt.queue_lock = threading.Lock()

Definition at line 276 of file benders_2stage_mt.py.

◆ received

list benders_2stage_mt.received = subi[0].sync_db.add_parameter("received", 1, "units received from first stage solution")

Definition at line 233 of file benders_2stage_mt.py.

◆ scen_solve

benders_2stage_mt.scen_solve

Definition at line 292 of file benders_2stage_mt.py.

Referenced by scen_solve().

◆ scenario_data

benders_2stage_mt.scenario_data = data.out_db.get_parameter("ScenarioData")

Definition at line 207 of file benders_2stage_mt.py.

◆ subi

list benders_2stage_mt.subi = []

Definition at line 230 of file benders_2stage_mt.py.

◆ target

benders_2stage_mt.target

Definition at line 292 of file benders_2stage_mt.py.

◆ theta

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

Definition at line 224 of file benders_2stage_mt.py.

◆ theta_fix

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

Definition at line 225 of file benders_2stage_mt.py.

◆ threads

dictionary benders_2stage_mt.threads = {}

Definition at line 290 of file benders_2stage_mt.py.

◆ upperbound

benders_2stage_mt.upperbound = float('inf')

Definition at line 242 of file benders_2stage_mt.py.

◆ value

benders_2stage_mt.value

Definition at line 251 of file benders_2stage_mt.py.

◆ ws

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

Definition at line 195 of file benders_2stage_mt.py.