warehouse Namespace Reference

Functions

def get_model_text ()
 
def solve_warehouse (workspace, number_of_warehouses, result, db_lock)
 

Variables

 ws = GamsWorkspace(system_directory = sys.argv[1])
 
 result_db = ws.add_database()
 
string status_string = ""
 
int status = 0
 
 db_lock = threading.Lock()
 
dictionary threads = {}
 
 target
 
 solve_warehouse
 
 args
 

Function Documentation

◆ get_model_text()

def warehouse.get_model_text ( )

Definition at line 16 of file warehouse.py.

16def get_model_text():
17  return '''
18 $title Warehouse.gms
19 
20 $eolcom //
21 $SetDDList warehouse store fixed disaggregate // acceptable defines
22 $if not set warehouse $set warehouse 10
23 $if not set store $set store 50
24 $if not set fixed $set fixed 20
25 $if not set disaggregate $set disaggregate 1 // indicator for tighter bigM constraint
26 $ife %store%<=%warehouse% $abort Increase number of stores (>%warehouse)
27 
28 set res respond codes / 0 Normal
29  1 License Error
30  2 No solution
31  3 Other Error /
32  ares(res) / 3 /;
33 
34 Sets Warehouse /w1*w%warehouse% /
35  Store /s1*s%store% /
36 Alias (Warehouse,w), (Store,s);
37 Scalar
38  fixed fixed cost for opening a warehouse / %fixed% /
39 Parameter
40  capacity(WareHouse)
41  supplyCost(Store,Warehouse);
42 
43 $eval storeDIVwarehouse trunc(card(store)/card(warehouse))
44 capacity(w) = %storeDIVwarehouse% + mod(ord(w),%storeDIVwarehouse%);
45 supplyCost(s,w) = 1+mod(ord(s)+10*ord(w), 100);
46 
47 Variables
48  open(Warehouse)
49  supply(Store,Warehouse)
50  obj;
51 Binary variables open, supply;
52 
53 Equations
54  defobj
55  oneWarehouse(s)
56  defopen(w);
57 
58 defobj.. obj =e= sum(w, fixed*open(w)) + sum((w,s), supplyCost(s,w)*supply(s,w));
59 
60 oneWarehouse(s).. sum(w, supply(s,w)) =e= 1;
61 
62 defopen(w).. sum(s, supply(s,w)) =l= open(w)*capacity(w);
63 
64 $ifthen %disaggregate%==1
65 Equations
66  defopen2(s,w);
67 defopen2(s,w).. supply(s,w) =l= open(w);
68 $endif
69 
70 model distrib /all/;
71 solve distrib min obj using mip;
72 
73 $macro setResult(n) option clear=ares; ares(n) = yes;
74 if (distrib.modelstat=%ModelStat.LicensingProblem% or
75  distrib.solvestat=%Solvestat.LicensingProblems%,
76  setResult('1');
77  abort 'License Error';
78 );
79 if (distrib.solvestat<>%SolveStat.NormalCompletion% or
80  distrib.modelstat<>%ModelStat.Optimal% and
81  distrib.modelstat<>%ModelStat.IntegerSolution%,
82  setResult('2');
83  abort 'No solution';
84 );
85 setResult('0'); '''
86 

Referenced by solve_warehouse().

◆ solve_warehouse()

def warehouse.solve_warehouse (   workspace,
  number_of_warehouses,
  result,
  db_lock 
)

Definition at line 87 of file warehouse.py.

References get_model_text(), markowitz.key, and solve_warehouse.

Variable Documentation

◆ args

warehouse.args

Definition at line 153 of file warehouse.py.

◆ db_lock

warehouse.db_lock = threading.Lock()

Definition at line 150 of file warehouse.py.

◆ result_db

warehouse.result_db = ws.add_database()

Definition at line 141 of file warehouse.py.

◆ solve_warehouse

warehouse.solve_warehouse

Definition at line 153 of file warehouse.py.

Referenced by solve_warehouse().

◆ status

int warehouse.status = 0

Definition at line 146 of file warehouse.py.

◆ status_string

string warehouse.status_string = ""

Definition at line 145 of file warehouse.py.

◆ target

warehouse.target

Definition at line 153 of file warehouse.py.

◆ threads

dictionary warehouse.threads = {}

Definition at line 151 of file warehouse.py.

◆ ws

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

Definition at line 136 of file warehouse.py.

def get_model_text()
Definition: warehouse.py:16