Trying to input a large matrix of parameters efficiently
Hello,
I was trying to input parameter matrix (in 2 dimensional) as an object of "tupledict" in Gurobi,
What I have in mind is that one can use "multidict" to assign value to each element manually, for example as below:
IJ,matrix_A = multidict({(1,1):a11,(1,2):a12, ... (m,1):am1, ..., (m,n):amn})
But if there is another efficient way I can generate this gurobi's tupledict from the original list without manually inputing each element. (I was thinking use for-loop + multidict, but there is no function like "adding" a new element to the current multidict.)
Thanks in advance.
-
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 Pohan,
It's hard to give concrete advice without seeing your actual data structures. In general, you should try to avoid using for-loops in Python and use list comprehension instead. You may want to put in some timers and do profiling on the code so you can pin down the bottleneck and try to improve on that.
Cheers,
Matthias0
Post is closed for comments.
Comments
2 comments