Skip to main content

Reuse Expression of Existing Constraint to Build New Constraints

Answered

Comments

4 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 why not try our AI Gurobot?.
  • Eli Towle
    • Gurobi Staff

    Hi Sneha,

    Introducing auxiliary variables seems like a good way to do this. We can create a new \( t \) variable for each inventory day, then base each day's inventory off of the previous day's inventory . For example:

    $$\begin{alignat*}{3} t_1 &= & 5x_1 - &&2 y_1 \\ t_2 &= t_1 + & 15x_2 - && 4y_2 \\ t_3 &= t_2 + & 10x_3 - && 6y_3 \end{alignat*}$$

    Then, we define the bounds to the \( t \) variables:

    $$\begin{align*}t_1 &\geq -40 \\ t_2 &\geq -60 \\ t_3 &\geq -80 \end{align*}$$

    Note that we have to use two separate constraints for each time period: one for setting the \( t \) variable, and another for setting its lower bound.

    Eli

    0
  • Sneha Bishnoi
    • Gurobi-versary
    • First Comment
    • First Question

    Hi Eli, 

    I tried the suggestion and modified my LP file (with appropriate introduction of variable t#1 and t#2 in Generals section , however it now makes the model infeasible. Not sure , why it would since the problem is still the same with rearrangement of terms around equations to introduce new variable


    C0: - t#1 + 5 x#1 - 2 y#1  =0

    C1: -t#2 + t#1 + 15 x#2 - 4 y#2  =0 

    C3: t#1 >= -40

    C4: t#2 >= -60

    0
  • Eli Towle
    • Gurobi Staff

    Hi Sneha,

    I think there should be a space between \( \texttt{=} \) and \( \texttt{0} \) in constraints \( \texttt{C0} \) and \( \texttt{C1} \). There may be other similar spacing problems in the LP file. Though I don't recommend trying to manually edit LP model files like this. LP files are meant more for visually inspecting a model written using a solver API, rather than as a framework for writing models.

    Thanks,

    Eli

    0

Post is closed for comments.