Skip to main content

Modelling piecewise function 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 try Gurobot, our chatbot interface offering instant, expert-level support.
  • Jaromił Najman
    • Gurobi Staff

    Could you share the details of the piecewise-linear function \(PF(\cdot)\)? It is hard to say anything without knowing much about it.

    0
  • Jia Qi Ng
    • Gurobi-versary
    • First Comment
    • First Question

    Hi Jaromil, thank you for the response. The piecewise-linear function is defined as shown, hope this helps to clarify my question, thank you!

    0
  • Jaromił Najman
    • Gurobi Staff

    Hi Jia,

    You can try implementing function \(PF\) as part of your model. This means, that you shouldn't try to see \(PF\) as a separate function but see it as constraints defining \(\delta_j\). This would mean to model

    \[\begin{align}
    \max_{x,\delta,FI} &\,\, - \sum_{j=1}^N w_jx_j - \sum_{j=1}^N \delta_j + \delta_0\\
    \text{s.t.} &\,\, \delta_j = \sum_{t=1}^T \lambda_{t^j} f_{t^j} &\quad \forall \, j=1,\dots,N\\
     &\,\, \lambda_{1^j} \leq z_{1^j} &\quad \forall \, j=1,\dots,N \\
    &\,\, \lambda_{t^j} \leq z_{t^j-1}+ z_{t^j} &\quad \forall \, t^j=2,\dots,T^j-1 \,, \forall\, j=1,\dots,N\\
    &\,\, \lambda_{M^j} \leq z_{T^j-1}+ z_{t^j} &\quad \forall \, j=1,\dots,N\\
    &\,\, \sum_{t=1}^{T^j} \lambda_{t^j} = 1&\quad \forall \, j=1,\dots,N\\
    &\,\, \sum_{t=1}^{T^j-1} z_{t^j} = 1&\quad \forall \, j=1,\dots,N\\
    &\,\, \sum_{t=1}^{T^j}  \lambda_{t^j} s_{t^j} = x_j&\quad \forall \, j=1,\dots,N\\
    &z_{t^j} \in \{0,1\}, \lambda_{t^j}\geq 0 &\quad \forall \, t^j=2,\dots,T^j-1 \,, \forall\, j=1,\dots,N
    \end{align}\]

    In the above you would have to adjust \(f_{t^j},s_{t^j}\) to the inputs \(\hat{x},\hat{y}\).
    I don't think that all indices and constraints are 100% correct in the above but I think it is enough to get the idea of what is meant.

    Best regards, 
    Jaromił

    0

Post is closed for comments.