Search code examples
matlabcplexpiecewisemixed-integer-programming

Piecewise linear constraint in CPLEX API for MATLAB


I am a (almost) beginner with CPLEX and optimization. I am trying to set up an optimization problem in Matlab using the newly added feature of CPLEX (12.7.1), which enables the definition of piecewise linear (PWL) constraints. However, it is not clear to me how to do it in Matlab. The documentation on this is quite sparse. IBM has only one example (transport.m) , which defines the piecewise linear constraint as a combination of linear equalities and SOSs of type 2. However, this is not really using the newly added feature to directly specify a piecewise linear function. And the procedure in matlab can become quite cumbersome as the number of variables and piecewise constraints increase. Do you know if there is a way to express it differently, in Matlab?

Thank you


Solution

  • The new piecewise linear constraint support you mention was announced in the release notes here (In version 12.7.0). The MATLAB API was not included in that list. If having the functionality directly in MATLAB is important to you, you could add a request for it in the IBM RFE Community. In the meantime, you'll need to use one of the other APIs (C, C++, Java, .NET, Python).

    You could call another executable from within MATLAB using the system command. On the other hand, besides requiring a bit more work, your current technique should be fine.