Loading...
Searching...
No Matches
transport8a Namespace Reference

Functions

def scen_solve (cp_file, bmult_queue, queue_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
 
os cp_file = os.path.join(ws.working_directory, cp.name) + ".g00"
 
Queue bmult_queue = Queue()
 
list bmult = [0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3]
 
Lock io_lock = Lock()
 
Lock queue_lock = Lock()
 
int nr_workers = 4
 
dict processes = {}
 
 target
 
 scen_solve
 
 args
 

Function Documentation

◆ scen_solve()

def transport8a.scen_solve (   cp_file,
  bmult_queue,
  queue_lock,
  io_lock 
)

Definition at line 61 of file transport8a.py.

61def scen_solve(cp_file, bmult_queue, queue_lock, io_lock):
62 ws = GamsWorkspace()
63 cp = ws.add_checkpoint(cp_file)
64 mi = cp.add_modelinstance()
65 bmult = mi.sync_db.add_parameter("bmult", 0, "demand multiplier")
66 opt = ws.add_options()
67 opt.all_model_types = "cplex"
68
69 # instantiate the GAMSModelInstance and pass a model definition and GAMSModifier to declare bmult mutable
70 mi.instantiate("transport use lp min z", GamsModifier(bmult), opt)
71 bmult.add_record().value = 1.0
72
73 while True:
74 # dynamically get a bmult value from the queue instead of passing it to the different processes at creation time
75 queue_lock.acquire()
76 if bmult_queue.empty():
77 queue_lock.release()
78 return
79 b = bmult_queue.get()
80 queue_lock.release()
81 bmult.first_record().value = b
82 mi.solve()
83
84 # we need to make the ouput a critical section to avoid messed up report informations
85 io_lock.acquire()
86 print("Scenario bmult=" + str(b) + ":")
87 print(" Modelstatus: " + str(mi.model_status))
88 print(" Solvestatus: " + str(mi.solver_status))
89 print(" Obj: " + str(mi.sync_db.get_variable("z").find_record().level))
90 io_lock.release()
91
92

Variable Documentation

◆ args

transport8a.args

Definition at line 116 of file transport8a.py.

◆ bmult

list transport8a.bmult = [0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3]

Definition at line 104 of file transport8a.py.

◆ bmult_queue

Queue transport8a.bmult_queue = Queue()

Definition at line 103 of file transport8a.py.

◆ checkpoint

transport8a.checkpoint

Definition at line 100 of file transport8a.py.

◆ cp

GamsWorkspace transport8a.cp = ws.add_checkpoint()

Definition at line 96 of file transport8a.py.

◆ cp_file

os transport8a.cp_file = os.path.join(ws.working_directory, cp.name) + ".g00"

Definition at line 101 of file transport8a.py.

◆ GAMS_MODEL

str transport8a.GAMS_MODEL

Definition at line 14 of file transport8a.py.

◆ io_lock

Lock transport8a.io_lock = Lock()

Definition at line 109 of file transport8a.py.

◆ job

GamsWorkspace transport8a.job = ws.add_job_from_string(GAMS_MODEL)

Definition at line 99 of file transport8a.py.

◆ nr_workers

int transport8a.nr_workers = 4

Definition at line 112 of file transport8a.py.

◆ processes

dict transport8a.processes = {}

Definition at line 113 of file transport8a.py.

◆ queue_lock

Lock transport8a.queue_lock = Lock()

Definition at line 110 of file transport8a.py.

◆ scen_solve

transport8a.scen_solve

Definition at line 116 of file transport8a.py.

◆ sys_dir

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

Definition at line 94 of file transport8a.py.

◆ target

transport8a.target

Definition at line 116 of file transport8a.py.

◆ ws

GamsWorkspace transport8a.ws = GamsWorkspace(system_directory=sys_dir)

Definition at line 95 of file transport8a.py.