Cannot mix scalar and tuple values in a tuplelist--
---
You received this message because you are subscribed to a topic in the Google Groups "Gurobi Optimization" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gurobi/sVKW0U1Voms/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gurobi+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "Gurobi Optimization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gurobi+unsubscribe@googlegroups.com.
Usually, variables are created with two complete indexes in Gurobi such as i=3 and j=2 yielding: x_11, x_12, x_21, x_22, x_31, x_32. However, I am trying to eliminate some redundant variables so as to decrease computation time. I have created the following variables with the following code:
from gurobipy import *
rangevalue = list(range(8,13))
I = 10
E = [6, 3, 4, 2, 4, 2, 5, 1, 4, 2]
m = Model("a")
for i in range(I):
for k in range(len(rangevalue)):
t = E[i]
y[i+1, rangevalue[k] - t] = m.addVar(vtype=GRB.BINARY,
name="y%s" % str([i+1, rangevalue[k] - t]))
m.update()
y
This yields following variables:
{(1, 2): <gurobi.Var y[1, 2]>,
(1, 3): <gurobi.Var y[1, 3]>,
(1, 4): <gurobi.Var y[1, 4]>,
(1, 5): <gurobi.Var y[1, 5]>,
(1, 6): <gurobi.Var y[1, 6]>,
(2, 5): <gurobi.Var y[2, 5]>,
(2, 6): <gurobi.Var y[2, 6]>,
(2, 7): <gurobi.Var y[2, 7]>,
(2, 8): <gurobi.Var y[2, 8]>,
(2, 9): <gurobi.Var y[2, 9]>,
(3, 4): <gurobi.Var y[3, 4]>,
(3, 5): <gurobi.Var y[3, 5]>,
(3, 6): <gurobi.Var y[3, 6]>,
(3, 7): <gurobi.Var y[3, 7]>,
(3, 8): <gurobi.Var y[3, 8]>,
(4, 6): <gurobi.Var y[4, 6]>,
(4, 7): <gurobi.Var y[4, 7]>,
(4, 8): <gurobi.Var y[4, 8]>,
(4, 9): <gurobi.Var y[4, 9]>,
(4, 10): <gurobi.Var y[4, 10]>,
(5, 4): <gurobi.Var y[5, 4]>,
(5, 5): <gurobi.Var y[5, 5]>,
(5, 6): <gurobi.Var y[5, 6]>,
(5, 7): <gurobi.Var y[5, 7]>,
(5, 8): <gurobi.Var y[5, 8]>,
(6, 6): <gurobi.Var y[6, 6]>,
(6, 7): <gurobi.Var y[6, 7]>,
(6, 8): <gurobi.Var y[6, 8]>,
(6, 9): <gurobi.Var y[6, 9]>,
(6, 10): <gurobi.Var y[6, 10]>,
(7, 3): <gurobi.Var y[7, 3]>,
(7, 4): <gurobi.Var y[7, 4]>,
(7, 5): <gurobi.Var y[7, 5]>,
(7, 6): <gurobi.Var y[7, 6]>,
(7, 7): <gurobi.Var y[7, 7]>,
(8, 7): <gurobi.Var y[8, 7]>,
(8, 8): <gurobi.Var y[8, 8]>,
(8, 9): <gurobi.Var y[8, 9]>,
(8, 10): <gurobi.Var y[8, 10]>,
(8, 11): <gurobi.Var y[8, 11]>,
(9, 4): <gurobi.Var y[9, 4]>,
(9, 5): <gurobi.Var y[9, 5]>,
(9, 6): <gurobi.Var y[9, 6]>,
(9, 7): <gurobi.Var y[9, 7]>,
(9, 8): <gurobi.Var y[9, 8]>,
(10, 6): <gurobi.Var y[10, 6]>,
(10, 7): <gurobi.Var y[10, 7]>,
(10, 8): <gurobi.Var y[10, 8]>,
(10, 9): <gurobi.Var y[10, 9]>,
(10, 10): <gurobi.Var y[10, 10]>}
Now, I need to create the following constraint set:
y[1, 2] + y[1, 3] + y[1, 4] + y[1, 5] + y[1, 6] == 1
y[2, 5] + y[2, 6] + y[2, 7] + y[2, 8] + y[2, 9] == 1
For all values of variable i. My code directly works and shows what I am doing. If you may find a way to create these constraints either with addConstr and addConstrs functions, I would really appreciate it.
--
---
You received this message because you are subscribed to the Google Groups "Gurobi Optimization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gurobi+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to gurobi+un...@googlegroups.com.