在混合整数规划模型中使用max / min

时间:2015-10-06 18:20:13

标签: cplex gurobi integer-programming

我构建一个混合整数编程模型,我想定义一个决策变量的最小值和最小值。

例如,假设C = {19,20,30}

我想将C_early定义为19,将C_late定义为30.然后我想最小化差异。使用辅助约束成功定义了C_late部分,但是,我认为我缺少了最小部分的内容。

这是我的代码:

int I=...;
int J=...;
int K=...; 
int T=...;

range Order = 1..I;
range Job = 1..J;
range Machine=1..K;
range Position = 1..T;

int p[Order][Job]=...;
int a[Order][Job][Machine]=...;


dvar boolean x[Order][Job][Machine][Position];
dvar int C_late[Order];
dvar int C_early[Order];
dvar int diff[Order];
dvar int+ y [Machine][Position];
dvar int+ C[Order][Job];
dvar int Cmax;


minimize 
Cmax;

subject to{
// Ensure that a job is scheduled on one position only
forall(i in Order, j in Job: p[i][j]>0) sum(t in Position, m in Machine) 
x[i][j][m][t] == 1;

forall(m in Machine, t in Position) sum(i in Order, j in Job: p[i][j]>0)
x[i][j][m][t] <= 1;  

forall(i in Order, j in Job: p[i][j]>0 , m in Machine, t in Position)
   x[i][j][m][t] - a[i][j][m] <= 0;

forall (m in Machine)
y[m][1] >= sum(i in Order, j in Job) p[i][j]*x[i][j][m][1];

forall(m in Machine, t in Position: t>=2)
y[m][t] >= y[m][t-1] + sum(i in Order, j in Job) p[i][j]*x[i][j][m][t];

forall(i in Order, j in Job: p[i][j]>0, m in Machine, t in Position) 
C[i][j] >= y[m][t] - 100000*(1 - x[i][j][m][t]);

forall(m in Machine) 
sum(i in Order, j in Job, t in Position) p[i][j]*x[i][j][m][t] - Cmax <= 0;

forall(i in Order, j in Job: p[i][j]>0)
C[i][j] >= C_early[i];

forall(i in Order, j in Job: p[i][j]>0)
C[i][j] <= C_late[i];

forall (i in Order)
C_late[i] - C_early[i] <= diff[i]
}

最后三个限制与我的问题有关。

数据集示例:

J=3;
K=3;
T=10;
I=10;

p= [
        [15,0,0], 
        [14,0,0],
        [16,0,0],
        [15,0,0],
        [14,0,0],
        [16,0,0],
        [16,0,0],
        [14,0,0],
        [15,0,0],
        [17,16,14]
            ];

a = [
        [[1,1,1], [0,0,0], [0,0,0]], 
        [[0,1,1], [0,0,0], [0,0,0]],
        [[1,1,1], [0,0,0], [0,0,0]],
        [[1,0,1], [0,0,0], [0,0,0]],
        [[0,1,1], [0,0,0], [0,0,0]],
        [[1,1,1], [0,0,0], [0,0,0]],
        [[0,1,1], [0,0,0], [0,0,0]],
        [[0,1,1], [0,0,0], [0,0,0]],
        [[1,1,1], [0,0,0], [0,0,0]],
        [[1,1,1], [1,1,1], [1,0,1]],
            ]; 

我知道我必须使用big m方法进行最小约束,但是,我不知道如何 谢谢,

1 个答案:

答案 0 :(得分:0)

你只能最小化Cmax,而不是差异。这可能是一个错误。