Access to particular key value in variable output of Gurobi

686 views
Skip to first unread message

sami

unread,
Dec 1, 2016, 12:17:06 PM12/1/16
to Gurobi Optimization
Hi,
I have sorted values and keys of my variables from Gorubi. for example, I have: [ 4.0, 3.0, 1.0 ] vars with[ (3, 1, 45), (2, 1, 80), (3, 1, 37) ]keys. If I choose 3.0 in vars, how can I access to (2,1,80) in keys? 
Regards,
Sami

Renan Garcia

unread,
Dec 2, 2016, 8:55:54 AM12/2/16
to gur...@googlegroups.com
If you had the numerical values themselves stored in a dictionary, say 'vals', then you would access the value using the key as an index. For example, vals[2, 1, 80]. For more details about fundamental Python data structures see https://docs.python.org/3/tutorial/datastructures.html.

If you had the variables (or Var objects) stored in a dictionary, say 'vars', then you would index the variable using the key and access the value through the X attribute (see http://www.gurobi.com/documentation/7.0/refman/x.html#attr:X). For example, vars[2, 1, 80].X

There are several code examples at http://www.gurobi.com/resources/examples/example-models-overview that should provide a great starting point for what you are trying to do.

--

---
You received this message because you are subscribed to the Google Groups "Gurobi Optimization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gurobi+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages