Skip to main content

values of parameters dependant on decision variable

Answered

Comments

3 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    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 try Gurobot, our chatbot interface offering instant, expert-level support.
  • Jaromił Najman
    • Gurobi Staff

    It is not directly possible to use a variable as an index of an expression or another variable. However, it is possible to formulate it in such a way as is discussed in the post use a decision variable as an index.

    In general if possible, I would try to avoid using optimization variables as indices. In your case, what exactly are you trying to achieve by accessing \(\texttt{D[i,j] for i in B}\)? Do you want to actually use the values of the binary variables to access either \(\texttt{D[0,j]}\) or \(\texttt{D[1,j]}\)? You can achieve this by formulating

    \[\begin{align*}
    D_{0} \cdot (1-B) + D_{1} \cdot B
    \end{align*}\]

    with the appropriate indices for \(B\).

    Best regards, 
    Jaromił

    0
  • Leon Stefánsson
    • Gurobi-versary
    • First Comment
    • First Question

    Thank you for the answear Jaromil,

    D is not binary, but a distance matrix.

    I found the post yesterday you referred to and after some pondering got around to using a dummy variable

    \begin{align*}
    b \in R^{n x i} \\
    B_n = \sum_{i = 1}^{\I} n*b_{n,i}  \forall n \in N
    \end{align*}

    Then I set the objective function as:
    \begin{align*}
    \sum_{i,j,n}^{} D_{i,j}R{j,n}b{n,i}
     
     
     
    0

Post is closed for comments.