TypeError: unsupported operand type(s) for /: 'int' and 'Var'
AnsweredHi there, I am new in the Gurobi I need some direction on how to solve the following error: TypeError: unsupported operand type(s) for /: 'int' and 'Var'tinpsi_ui[u,i,k] = 1/psi_ui[u,i,k]
In the problem I am solving
psi_ui[u,i,k] = model.addVar(vtype=GRB.CONTINUOUS, name="psi_ui[%d,%d,%d]"%(u,i,k))
is a continuos decision variable,
tinpsi_ui[u,i,k] = model.addVar(vtype=GRB.CONTINUOUS, name="psi_ui[%d,%d,%d]"%(u,i,k))
is an auxiliary continuos decision variable,
x[u,v,i,k] = model.addVar(vtype=GRB.BINARY, name="x[%d,%d,%d,%d]"%(u,v,i,k))
is a binary decision variable
I have the following contraint:
\sum_{u\in U} \sum_{k=0}^{K} \sum_{i=1}^{C_u}
x_{uvik} \leq{L_v} \quad \forall{v}\in V
(tau_v[v]/psi_ui[u,i])
I code this contraint as follow:
for v in V:
#constraint = LinExpr()
for u in U:
for i in range(C_u[u]):
for k in range(1,K):
tinpsi_ui[u,i,k] = 1/psi_ui[u,i,k]
model.addConstr(inpsi_ui[u,i,k] == (psi_ui[u,i,k])**(-1))
constraint.add(tau_v[v]*x[u,v,i,k]*tinpsi_ui[u,i,k])
model.addConstr(constraint <= L_v[v])
Thank you,
Hernani
0
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
Hi Hermani,
This post should help you get started with variable divisions:
How do I divide by a variable in Gurobi? – Gurobi Support PortalCheers,
Matthias0
Post is closed for comments.
Comments
2 comments