Loading...
Searching...
No Matches
transport8 Namespace Reference

Functions

def scen_solve (checkpoint, bmult_list, list_lock, io_lock)
 

Variables

str GAMS_MODEL
 
sys sys_dir = sys.argv[1] if len(sys.argv) > 1 else None
 
GamsWorkspace ws = GamsWorkspace(system_directory=sys_dir)
 
GamsWorkspace cp = ws.add_checkpoint()
 
GamsWorkspace job = ws.add_job_from_string(GAMS_MODEL)
 
 checkpoint
 
list bmult_list = [1.3, 1.2, 1.1, 1.0, 0.9, 0.8, 0.7, 0.6]
 
Lock list_lock = Lock()
 
Lock io_lock = Lock()
 
int nr_workers = 2
 
dict threads = {}
 
 target
 
 scen_solve
 
 args
 

Function Documentation

◆ scen_solve()

def transport8.scen_solve (   checkpoint,
  bmult_list,
  list_lock,
  io_lock 
)

Definition at line 62 of file transport8.py.

62def scen_solve(checkpoint, bmult_list, list_lock, io_lock):
63 list_lock.acquire()
64 mi = checkpoint.add_modelinstance()
65 list_lock.release()
66 bmult = mi.sync_db.add_parameter("bmult", 0, "demand multiplier")
67 opt = ws.add_options()
68 opt.all_model_types = "cplex"
69
70 # instantiate the GamsModelInstance and pass a model definition and GamsModifier to declare bmult mutable
71 mi.instantiate("transport use lp min z", GamsModifier(bmult), opt)
72 bmult.add_record().value = 1.0
73
74 while True:
75 # dynamically get a bmult value from the queue instead of passing it to the different threads at creation time
76 list_lock.acquire()
77 if not bmult_list:
78 list_lock.release()
79 return
80 b = bmult_list.pop()
81 list_lock.release()
82 bmult.first_record().value = b
83 mi.solve()
84
85 # we need to make the ouput a critical section to avoid messed up report informations
86 io_lock.acquire()
87 print(f"Scenario bmult={b}:")
88 print(f" Modelstatus: {mi.model_status}")
89 print(f" Solvestatus: {mi.solver_status}")
90 print(f" Obj: {mi.sync_db['z'].first_record().level}")
91 io_lock.release()
92
93

Variable Documentation

◆ args

transport8.args

Definition at line 115 of file transport8.py.

◆ bmult_list

list transport8.bmult_list = [1.3, 1.2, 1.1, 1.0, 0.9, 0.8, 0.7, 0.6]

Definition at line 104 of file transport8.py.

◆ checkpoint

transport8.checkpoint

Definition at line 102 of file transport8.py.

◆ cp

GamsWorkspace transport8.cp = ws.add_checkpoint()

Definition at line 98 of file transport8.py.

◆ GAMS_MODEL

str transport8.GAMS_MODEL

Definition at line 14 of file transport8.py.

◆ io_lock

Lock transport8.io_lock = Lock()

Definition at line 108 of file transport8.py.

◆ job

GamsWorkspace transport8.job = ws.add_job_from_string(GAMS_MODEL)

Definition at line 101 of file transport8.py.

◆ list_lock

Lock transport8.list_lock = Lock()

Definition at line 107 of file transport8.py.

◆ nr_workers

int transport8.nr_workers = 2

Definition at line 111 of file transport8.py.

◆ scen_solve

transport8.scen_solve

Definition at line 115 of file transport8.py.

◆ sys_dir

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

Definition at line 95 of file transport8.py.

◆ target

transport8.target

Definition at line 115 of file transport8.py.

◆ threads

dict transport8.threads = {}

Definition at line 112 of file transport8.py.

◆ ws

GamsWorkspace transport8.ws = GamsWorkspace(system_directory=sys_dir)

Definition at line 96 of file transport8.py.