4 Approach: use a convex combination formulation.
6 Copyright (c) by Joao Pedro PEDROSO and Mikio KUBO, 2012
8 from pyscipopt
import Model, quicksum, multidict
11 def eoq(I, F, h, d, w, W, a0, aK, K):
12 """eoq -- multi-item capacitated economic ordering quantity model
15 - F[i]: ordering cost for item i
16 - h[i]: holding cost for item i
17 - d[i]: demand for item i
18 - w[i]: unit weight for item i
19 - W: capacity (limit on order quantity)
20 - a0: lower bound on the cycle time (x axis)
21 - aK: upper bound on the cycle time (x axis)
22 - K: number of linear pieces to use in the approximation
23 Returns a model, ready to be solved.
28 delta = float(aK - a0) / K
33 b[i, k] = F[i] / T + h[i] * d[i] * T / 2.
35 model = Model(
"multi-item, capacitated EOQ")
39 x[i] = model.addVar(vtype=
"C", name=
"x(%s)" % i)
40 c[i] = model.addVar(vtype=
"C", name=
"c(%s)" % i)
42 w_[i, k] = model.addVar(ub=1, vtype=
"C", name=
"w(%s,%s)" % (i, k))
45 model.addCons(
quicksum(w_[i, k]
for k
in range(K)) == 1)
46 model.addCons(
quicksum(a[i, k] * w_[i, k]
for k
in range(K)) == x[i])
47 model.addCons(
quicksum(b[i, k] * w_[i, k]
for k
in range(K)) == c[i])
49 model.addCons(
quicksum(w[i] * d[i] * x[i]
for i
in I) <= W)
51 model.setObjective(
quicksum(c[i]
for i
in I),
"minimize")
57 if __name__ ==
"__main__":
60 {1: [300, 10, 10, 20],
67 model =
eoq(I, F, h, d, w, W, a0, aK, K)
73 if model.getVal(x[v]) >= EPS:
74 print(x[v].name,
"=", model.getVal(x[v]))
76 print(
"Optimal value:", model.getObjVal())