Skip to main content

Variate Piece-wise Linear Function

Answered

Comments

2 comments

  • w sj
    First Question
    First Comment

    If your function is continuous, perhaps you can first convert it into a linear function and then use addconstr

    0
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi Natalie,

    In your code snippet, the definition of \(x\) variables is missing.

    Note that the size of the \(\texttt{xpts}\) and \(\texttt{ypts}\) lists has to be the same, see addGenConstrPWL and the documentation on PWL.

    In your case, you want the \(\texttt{ypts}\) to hold the values at break points of you function, i.e.,

    xpts = [0, 4800, 15000, 30000 ]
    ypts = [0, 24960, 75960, 144960]

    With the \(x\) points and \(y\) points Gurobi is able to compute the PWL segments that you define via linear terms in your function.

    Best regards, 
    Jaromił

    0

Please sign in to leave a comment.