Problem with tuple and floar addition
AnsweredHello guys i have a little problen with the following code:
I want to add the product from alpha and better to the costs c but i dont know how to convert it to a float? i would really appreciate your help!
from gurobipy import *
I,M = multidict({1:[(400,340,500)], 2:[(650,200,400)], 3:[(300,600,500)], 4:[(500,600,600)]})
J,Max,Min = multidict({1:[3000,200], 2:[3000,200],3:[3000,200], 4:[3000,200]})
d = {(1,'Butanol'):((0,0,0),(80,70,90),(80,70,90),(100,110,90)), (1,'Biodiesel'):((0,0,0),(90,80,100),(95,85,75),(85,75,95)),
(2,'Butanol'):((0,0,0),(280,270,290),(280,300,290),(280,260,270)), (2,'Biodiesel'):((0,0,0),(120,130,110),(150,170,160),(110,120,130)),
(3,'Butanol'):((0,0,0),(240,250,260),(230,250,240),(240,250,260)), (3,'Biodiesel'):((0,0,0),(140,150,130),(150,140,130),(120,150,110)),
(4,'Butanol'):((0,0,0),(180,170,160),(130,120,140),(150,160,170)), (4,'Biodiesel'):((0,0,0),(80,70,60),(60,70,50),(80,70,60)),
(5,'Butanol'):((0,0,0),(180,170,190),(180,170,190),(180,170,190)), (5,'Biodiesel'):((0,0,0),(80,70,90),(80,100,90),(100,80,90))
}
K = set([k for (k,p) in d])
P = set([p for (k,p) in d])
produce = {1:['switch'], 2:['seed'], 3:['salz'], 4:['süß']}
alpha = {('Butanol', 'switch'):0.189,('Biodiesel', 'switch'):0,('Butanol', 'seed'):0.189,('Biodiesel', 'seed'):0,('Butanol', 'salz'):0.078,('Biodiesel', 'salz'):0.24125,('Butanol', 'süß'):0.078,('Biodiesel', 'süß'):0.24125}
beta = {('Butanol', 'switch'):1.233,('Biodiesel', 'switch'):0,('Butanol', 'seed'):1.233,('Biodiesel', 'seed'):0,('Butanol', 'salz'):2.044,('Biodiesel', 'salz'):(-2,846),('Butanol', 'süß'):2.0444,('Biodiesel', 'süß'):(-2,846)}
weight_bio = {'switch':0.00175, 'seed':0.00175, 'salz':0.00175, 'süß':0.00175}
cost_bio = {(1,1):4, (1,2):6, (1,3):9, (1,4):3,
(2,1):5, (2,2):4, (2,3):7, (2,4):5,
(3,1):6, (3,2):8, (3,3):4, (3,4):6,
(4,1):8, (4,2):5, (4,3):3, (4,4):6,
(5,1):10, (5,2):8, (5,3):4, (5,4):9
}
c_bio = {}
for i in I:
for j in J:
for q in produce[i]:
for p in P:
c_bio[i, j, q] = cost_bio[i,j] * weight_bio[q] +(beta[p,q] *alpha[p,q])
1
-
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 Leon,
Please note that this is not really a Gurobi related question.
The values of \(\texttt{('Biodiesel','salz')}\) and \(\texttt{('Biodiesel,'süß')}\) are given as pairs and not floats (note the comma \((-2, 846)\)). These should probably read
('Biodiesel', 'salz'):(-2.846), [...], ('Biodiesel', 'süß'):(-2.846)
Best regards,
Jaromił0
Post is closed for comments.
Comments
2 comments