Skip to main content

Resource usage in continous time modeling

Answered

Comments

7 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?.
  • Jaromił Najman
    • Gurobi Staff

    Hi Amine,

    I assume the \(\texttt{if}\)-statement means that \(Z_{jk}\) shall equal 1 when the inequalities are fulfilled and 0 otherwise, correct?

    One possible way would be to introduce the relationships
    if \(S_j \leq t\) then \(x_j=1\) else \(x_j=0\)
    if \(t \leq S_j + P_j -1\) then \(y_j=1\) else \(y_j=0\)
    This is well described in the stackexchange post How to write if else statement in Linear programming?

    You can then use the binary variables \(x_j, y_j\) and the addGenConAnd() function to model
    \(Z_{jk} = x_j \land y_j\) which means that \(Z_{jk}\) is 1 only if both inequalities hold and 0 otherwise.

    This is just one possible way to avoid the introduction of a triple indexed variable. There might be different and/or better ways to achieve this.

    Best regards,
    Jaromił

    0
  • Amine Athmani
    • Gurobi-versary
    • First Comment
    • First Question

    Hello Jaromił, Thank you for your quick answer,

    My problem is that \(S_j \) is a decision variable which represents the starting time and can take values in \( [ 1 ... H ] \). On the other hand, \(Z_{jk}\) is not binary but an integer decision variable that represents the allocation of resource k to event j. And I want to determine \(Y_{kt}\) (resource usage) which is equal to the sum over events j of \(Z_{jk}\) but only when event is scheduled. 

    Best regards.

    0
  • Jaromił Najman
    • Gurobi Staff

    Hi Amine,

    Could you explain what exactly the \(\texttt{if}\)-statement means in this case?

    Best regards,
    Jaromił

    0
  • Amine Athmani
    • Gurobi-versary
    • First Comment
    • First Question

    Hi again Jaromił,

    The if statement means that we take into account the value of \(Z_{jk}\) only in the timeslots where the event j is scheduled (  \(S_{j} <= t <=  S_{j} + P_{j} - 1   \) ). Otherwise we don't take it into account.

    Best regards. 

    0
  • Jaromił Najman
    • Gurobi Staff

    I understand, so to achieve that, you could use an additional \(\texttt{if-then}\)-statement as
    if \(z_j\geq1\) then \(w_{jk} = Z_{jk}\) else \(w_{jk}=0\)

    where \(z_j = x_j \land y_j\) with \(x_j, y_j\) as defined in my previous message. \(w_{jk}\) would then represent the value of the term in the summation which either equals \(Z_{jk}\) or is ignored and equals \(0\).

    0
  • Amine Athmani
    • Gurobi-versary
    • First Comment
    • First Question

    Hello,

    That's a really interesting technique, I will try it out and let you know so the community can benefit from it. Thanks a lot for your time and quick answers Jaromił. 

    Have a good day.

    0

Post is closed for comments.