1

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

这是我的工作 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
minimize Math.Max(Column0Row1, Column0Row3, Column1Row2, Column1Row4, OColumn0Row2, Column2Row3, Column3Row4, OColumn2Row4) - Math.Min(Column0Row1, Column0Row3, Column1Row2, Column1Row4, OColumn0Row2, Column2Row3, Column3Row4, OColumn2Row4);

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

任何想法表示赞赏。

4

1 回答 1

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

工作正常

于 2018-06-29T19:30:44.990 回答