Commit 6aeb910a authored by Michael Keller's avatar Michael Keller
Browse files

savepoint

parent 1b5f30ee
......@@ -52,7 +52,7 @@ def main():
for c1 in range(numb_crops):
for c2 in range(numb_crops):
if get_ind(p, n, c1, c2) is None:
obj.append((R(c1, c2) + R(c2, c1))) # the solver MAXimizes
obj.append(R(c1, c2) + R(c2, c1)) # the solver MAXimizes
# speeds up index queries
dp[str(p) + "|" + str(n) + "|" + str(c1) + "|" + str(c2)] = ind
......@@ -61,6 +61,7 @@ def main():
# setup the QP
m = gp.Model("qpc")
m.params.NonConvex = 2
x = m.addMVar(len(obj), lb=[0.0 for _ in obj], ub=[1.0 for _ in obj], name="x")
# the quadratic constraint / objective function (ensures a valid field)
......@@ -74,12 +75,9 @@ def main():
for cB in range(numb_crops):
O[get_ind(p, n, c1, c2)][get_ind(p, n, cA, cB)] = 1
# O = np.ones((len(obj), len(obj)))
m.setObjective(
sum([
(sum(
O[i][j] * x[i] * x[j] for i in range(len(obj))
) - x[j])
for j in range(len(obj)) ])
m.addConstr(
x @ O @ x - sum(x) == 0,
"Quad_constr",
# sum([
# (sum(
# O[i][j] * x[i] * x[j] for i in range(len(obj))
......@@ -153,7 +151,7 @@ def main():
s += sol[get_ind(p, n0, c1, c2)].X
score += sol[get_ind(p, n0, c1, c2)].X * obj[get_ind(p, n0, c1, c2)]
print(s, end=", ")
# print("")
print("")
print("\n\nScore: ", score)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment