メインコンテンツへスキップ

tabulated values for a gurobi variable

回答済み

コメント

1件のコメント

  • 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

サインインしてコメントを残してください。