values of parameters dependant on decision variable
回答済みHello,
I have a simple problem i wish to solve, where i want to minimize a product of two parameters.
One of the parameters is dependant on the decision variable and the other's indices are dependant open the decision variable. My code below might clarify this better:
-
正式なコメント
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. -
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 -
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
投稿コメントは受け付けていません。
コメント
3件のコメント