rework example/bus_sched
@@ -13,14 +13,15 @@ import numpy
demands = [8, 10, 7, 12, 4, 4]
slots = len(demands)
-# variables
-x = IntVar(0,sum(demands), shape=slots, name="x")
-constraint = [x[i] + x[i+1] >= demands[i] for i in range(0,slots-1)]
-constraint += [x[-1] + x[0] == demands[-1]] # 'around the clock' constraint
+# variables
+x = intvar(0,sum(demands), shape=slots, name="x")
-objective = sum(x) # number of buses
+model = Model(
+ [x[i] + x[i+1] >= demands[i] for i in range(0,slots-1)],
+ x[-1] + x[0] == demands[-1], # 'around the clock' constraint
+)
+model.minimize(sum(x))
-model = Model(constraint, minimize=objective)
print("Value:", model.solve()) # solve returns objective value
print("Solution:", x.value())
