Problem with dictionaries and arrays
Awaiting user inputI kind of have a unique Opimization Problem therefore cant look at examples. What I want to do is to minimize cost of production with machines and tasks to be assigned. Also there are different types of machines with different costs but firstly I want to solve another problem.
A minimum example is like followes:
stations = [1,2]
costs = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
arcs = [(i,j) for i in tasks for j in stations]
c = {(i,j): costs_BTC1[j-1] for i,j in arcs}
The tasks variable I get from a Excel Sheet and it works fine. The output for tasks is like that:
['w01','w02','w03','w04','w05','w06','w07','w08','w09','w10','w11', 'w12','w13','w14','w15','w16','w17','w18','w19','w20']
When I print c i get:
{('w01', 1): 2,
('w01', 2): 3,
('w02', 1): 2,
('w02', 2): 3,
('w03', 1): 2,
('w03', 2): 3,
.....}
and so on 40 times this kind of combination.
What I want is that the costs are dependent on tasks but not on stations like here. So for this example something like:
('w01', 1): 1
('w02', 1): 2
('w03', 1): 3
... and so on and the same values for station 2 because cost are not dependent on station.
How can I do this? If I try to make cost to a dictionary it says that integer or slices are expected but even like that cant reach what I want
Aprreciate your help!
-
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 try Gurobot, our chatbot interface offering instant, expert-level support. -
Note that this is not really a Gurobi issue but rather a general Python question.
Could you please provide a minimal reproducible example? For this, you would to at least provide the costs_BTC1 list and state what exactly you want to get.
0
Post is closed for comments.
Comments
2 comments