CPLEX api for matlab 中变量的绝对值

Absolute value of variable in CPLEX api for matlab

我正在尝试使用 CPLEX 在 Matlab 上求解模型。当 objective 为

Maximize x1 + 2 x2 + 3 x3 + x4

介绍cplex.Model.obj = [ 1; 2; 3; 1];就够了。

当objective是

时我该怎么办

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

简短的回答是 CPLEX MATLAB API 不支持绝对值函数 "out of the box"。所以,正如评论中所建议的,如果你想使用 MATLAB API,你必须自己制定它。但是,C++、Java 和 .NET Concert API 确实支持 abs(例如,对于 Java API,请参阅 here). It is also supported in the docplex modeling API (see here) .

CPLEX MATLAB API 版本 12.8(当前为最新版本)的文档是 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,随 CPLEX 一起提供。