1
$\begingroup$

In my optimization model, I use piecewise-linear constraints with the output of $y[m]$. The question or problem I have now is whether there is a way in Gurobi (Java) to form the integral for this PWL in my objective function, from $-20$ to my $x[m]$, where $x[m]$ is my optimization variable. I need the area between the $x$-axis and the PWL constraint, where $y[m]$ is always $\ge0$.

$\endgroup$
2
$\begingroup$

Integrating a piecewise linear function means you end up with a piecewise quadratic function.

Unless there is come convex structure in the resulting piecewise quadratic function (i.e. the PWL is non-decreasing) you will end up with a model involving nonconvexities.

It was an interesting question so I had to play around a bit with it, and wrote a small post here https://yalmip.github.io/example/integratedpwa/. It is not Java, but the basic idea in the 'hard way' should be easily transferable to any modelling language.

$\endgroup$
9
  • $\begingroup$ Thank you for the detailed answer! But if I understand correctly, I now have to determine the function equation for all sections of my PWL and then integrate them and add them to my model with binary variables. If I have understood the idea correctly, I understand the approach, but would also mean at the same time that I no longer need my PWL constraint function from Gurobi, so to speak, or? $\endgroup$ – Handballer73 May 5 at 14:27
  • 1
    $\begingroup$ I don't see any approach where the basic piecewise affine functions would be explicitly used in the model. $\endgroup$ – Johan Löfberg May 5 at 14:46
  • $\begingroup$ The basic function itself is not, but since I don't have the basic function at all, so to speak, but only pass the points of the different sections to the PWL constraint, I have to set up the basic functions first in order to be able to integrate them, or not? $\endgroup$ – Handballer73 May 5 at 14:56
  • $\begingroup$ The points are only a proxy for the underlying function, so that just means those points have to be mapped into the associated integral instead. Having said that, if those points come from some function approximation, you can just as well continue with a piecewise affine approximation of the integral to reduce head-ache, i.e. do the last paragraph in the linked post, which corresponds to the PWL command I presume. $\endgroup$ – Johan Löfberg May 5 at 15:10
  • $\begingroup$ To be honest, I don't understand anything anymore. I have 5 x and 5 y values as input for my PWL constraint. Between these values is linearized in this constraint. As output parameter of the constraint I have y[m](x), which I can use directly in the objective function. So I do not have linearized straight line equations to integrate. But if I look at the example in the link, linear equations are put into integral form, added and then provided with a binary variable, or? $\endgroup$ – Handballer73 May 5 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.