independentvariable
independentvariable

Reputation: 338

Absolute value of variable in CPLEX api for matlab

I am trying to solve a model on Matlab by using CPLEX. When the objective is

Maximize x1 + 2 x2 + 3 x3 + x4

Introducing cplex.Model.obj = [ 1; 2; 3; 1]; is enough.

What shall I do when the objective is

Maximize abs(x1) + 2 x2 + 3 x3 + x4

Upvotes: 1

Views: 659

Answers (1)

rkersh
rkersh

Reputation: 4465

The short answer is that the CPLEX MATLAB API does not support an absolute value function "out of the box". So, as suggested in the comments, if you want to use the MATLAB API, you'll have to formulate it yourself. However, the C++, Java, and .NET Concert APIs do support abs (e.g., for the Java API see here). It is also supported in the docplex modeling API (see here).

The documentation for the CPLEX MATLAB API for version 12.8 (currently, the latest release) is here. I'm not sure if it will help make the documentation easier to use, but for me it is far easier to navigate if you click on the "Table of contents" link in the upper-left corner. This will allow you to expand the documentation tree and hop around easier. It is definitely worth looking at the examples that are shipped with CPLEX.

Upvotes: 1

Related Questions