Skip to main content

Usage of variable as key during building of model - Python API




  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi Grzegorz,

    Unfortunately, in order to access and make use of the variable objects while constructing the your model, you have to call the update function due to Gurobi's lazy update approach.

    Is there a particular reason why you would like to use the variable object as key instead of the variable name? You could also just get the variable object by using the getVarByName function.

    Best regards,

  • Grzegorz Siekaniec
    First Comment

    Hi Jaromił, thanks for finding time to provide an answer. The reason why I want to have bidrectional dictionary is to map business domain objects with variables so it is easier to query solution and then take actions on those objects. Otherwise, I need to use a variable name as a proxy. I ended up with populating regular dictionary in the beginning and then populating bidirectional dictionary after calling update function.


Please sign in to leave a comment.