Formulate a constraint considering T as a set rather than a parameter
AnsweredHello!
I am formulating a mathematical model and I encountered a problem, I am trying to simplify it through the following example:
First of all, I assumed T as a parameter (positive number).
Y_t is a binary parameter, where t in 1..T.
y_t is a binary variable, where t in 1..T.
Mathematically, I have formulated the following constraint:
(Y_t) + (y_t) + (Y_t+1) + (y_t+1) <= 1 for t in 1..T-1 if T > 1
For many reasons (too long to talk about and hard to explain), I need to consider T as a set instead of considering it as a parameter. In this case, how can the previous constraint be formulated mathematically?
Thank you in advance!
-
Official comment
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. -
Hi,
I don't know whether it makes sense for your application, but you could define everything over each element of \(T\).
\[\begin{align*}
Y_{i,t} &\in \{0,1\} &&\quad \forall i \in \{1,\dots,t\},\, t \in T\\
y_{i,t} &\in \{0,1\} &&\quad \forall i \in \{1,\dots,t\},\, t \in T\\
Y_{i,t} &+ y_{i,t} + (Y_{i,t}+1) + (y_{i,t}+1) \leq 1 &&\quad \forall i \in \{1,\dots,t-1\},\, t \in T \text{ if } t > 1
\end{align*}\]Best regards,
Jaromił1
Post is closed for comments.
Comments
2 comments