如何在 OPL 代码中将我的 objective 更改为 "Minimize Max() - Min()"?

How do I change my objective to "Minimize Max() - Min()" in OPL Code?

我有一些 OPL 代码可以最小化我的决策变量的总和。它工作正常,我很满意,但我想更改我的 objective 以最小化我的决策变量的...范围...。

这是我的工作 OPL 代码:

// Decision Variables
dvar int Column0Row1;
dvar int Column0Row2;
dvar int Column0Row3;
dvar int OColumn0Row1;
dvar int Column1Row2;
dvar int Column1Row4;
dvar int OColumn0Row2;
dvar int OColumn1Row2;
dvar int Column2Row3;
dvar int Column2Row4;
dvar int OColumn0Row3;
dvar int OColumn2Row3;
dvar int Column3Row4;
dvar int OColumn1Row4;
dvar int OColumn2Row4;
dvar int OColumn3Row4;

// Objective
minimize Column0Row1 + Column0Row3 + Column1Row2 + Column1Row4 + OColumn0Row2 + Column2Row3 + Column3Row4 + OColumn2Row4;
// Constraints
subject to
{
    Column0Row1 == -OColumn0Row1;
    Column0Row1 >= 1;
    Column0Row2 <= -1;
    Column0Row3 == -OColumn0Row3;
    Column0Row3 >= 1;
    OColumn0Row1 <= -1;
    Column1Row2 == -OColumn1Row2;
    Column1Row2 >= 1;
    Column1Row4 == -OColumn1Row4;
    Column1Row4 >= 1;
    OColumn0Row2 == -Column0Row2;
    OColumn0Row2 >= 1;
    OColumn1Row2 <= -1;
    Column2Row3 == -OColumn2Row3;
    Column2Row3 >= 1;
    Column2Row4 <= -1;
    OColumn0Row3 <= -1;
    OColumn2Row3 <= -1;
    Column3Row4 == -OColumn3Row4;
    Column3Row4 >= 1;
    OColumn1Row4 <= -1;
    OColumn2Row4 == -Column2Row4;
    OColumn2Row4 >= 1;
    OColumn3Row4 <= -1;
    Column0Row1 + Column0Row2 + Column0Row3 == 0;
    OColumn0Row1 + Column1Row2 + Column1Row4 == 0;
    OColumn0Row2 + OColumn1Row2 + Column2Row3 + Column2Row4 == 0;
    OColumn0Row3 + OColumn2Row3 + Column3Row4 == 0;
    OColumn1Row4 + OColumn2Row4 + OColumn3Row4 == 0;
}

我想把我的 objective 改成这样:

// Objective
minimize Math.Max(Column0Row1, Column0Row3, Column1Row2, Column1Row4, OColumn0Row2, Column2Row3, Column3Row4, OColumn2Row4) - Math.Min(Column0Row1, Column0Row3, Column1Row2, Column1Row4, OColumn0Row2, Column2Row3, Column3Row4, OColumn2Row4);

所以objective应该是:最高决策变量减去最低决策变量。

任何想法表示赞赏。

minimize maxl(Column0Row1, Column0Row3, Column1Row2, Column1Row4, OColumn0Row2, Column2Row3, Column3Row4, OColumn2Row4) - minl(Column0Row1, Column0Row3, Column1Row2, Column1Row4, OColumn0Row2, Column2Row3, Column3Row4, OColumn2Row4);

工作正常