Skip to main content

tabulated values for a gurobi variable

Answered

Comments

2 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than two 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.
  • Maliheh Aramon
    • Gurobi Staff

    Hi Federico, 

    I am not sure I fully understood your question. I guess you mean that the continuous variable \(x\) can be assigned to a value from the set \(\{a_1, a_2, \ldots, a_k\}\). To model this, you can define binary decision variables \(z_i\) which equals 1 if the value \(a_i\) is assigned to variable \(x\) and equals 0 otherwise. You would then need to define the constraints below:

    \[\begin{align} & \sum_{i=1}^{k} z_i = 1 & \\ & x =  \sum_{i=1}^{k} a_i z_i &  \end{align}\]

    The first constraint ensures that exactly one of the \(z\) variables is assigned to 1 and the second constraint ensures that \(x\) variable is assigned to exactly one value from the predetermined set.

    Hope this helps. Let me know if I misunderstood your question. 

    Best regards,

    Maliheh 

    0

Post is closed for comments.