Unsupported type for LinExpr addition argument

2k Views Asked by At

I'm new to Gurobi and I'm trying to solve a simple model, but im getting the following error: Unsupported type (<'class 'gurobipy.TempConstr'>) for LinExpr addition argument.

The model is the following:

from gurobipy import *

precios={1:{1:5,2:5,3:5},
     2:{1:2,2:2.2,3:2.1},
     3:{1:3,2:3.3,3:3.1},
     4:{1:4,2:4.4,3:4.1}}
vitaminas={1:{1:0.1,2:0.1,3:0.1},
     2:{1:0.05,2:0.05,3:0.05},
     3:{1:0.07,2:0.07,3:0.07},
     4:{1:0.09,2:0.09,3:0.09}}
carbohidratos={1:{1:0.1,2:0.1,3:0.1},
     2:{1:0.07,2:0.07,3:0.07},
     3:{1:0.08,2:0.08,3:0.08},
     4:{1:0.09,2:0.09,3:0.09}}

hmax={1:24,2:27.5,3:30}
vmin={1:22,2:22,3:22}
bdown={1:0.02,
   3:0.2}
bup={1:0.04,
   3:0.3}

componentes=[1,2,3,4]
comp_control=[1,3]
paises=[1,2,3]
tav=22
demanda=1000

model = Model("Produccion")
x = model.addVars(componentes, paises,vtype=GRB.CONTINUOUS,name="x")

model.addConstrs((quicksum(carbohidratos[i][j]*x[i,j]<=hmax[j] for i in 
componentes) for j in paises), name='Maximo de carbohidratos')

model.addConstrs((quicksum(vitaminas[i][j]*x[i,j]>=vmin[j] for i in 
componentes) for j in paises),name='Minimo de vitaminas')

model.addConstrs(((bdown[i]*quicksum(x[i,j] for i in componentes)-x[i,j]<=0 
for i in comp_control) for j in paises),name='Limite inferior por 
componentes')

model.addConstrs(((x[i,j]-bup[j]*quicksum(x[i,j] for i in componentes)<=0 
for i in comp_control) for j in paises),name='Limite inferior por 
componentes')

model.addConstr((quicksum(x[1,j])<=tav),name='Maximo de formula disponible')

model.addConstr((quicksum(x[i,j] for i in componentes for j in 
paises)==demanda),name='Demanda total')

model.addConstrs((x[i,j]>=0 for i in componentes for j in 
paises),name='Producciones no negativas')

obj = quicksum(quicksum(precios[i][j] * x[i, j] for i in componentes) for j 
in paises)

model.setObjective(obj, GRB.MINIMIZE)

model.optimize()

I think that the complicating constraints are the 3rd and 4th ones.

Thanks in advance.

0

There are 0 best solutions below