0

我建立了一个混合整数规划模型,我想定义一个决策变量的最小值和 mzximum。

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

我想将 C_early 定义为 19,将 C_late 定义为 30。然后我想最小化差异。C_late 部分是使用辅助约束成功定义的,但是,我认为我在 min 部分缺少一些东西。

这是我的代码:

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]],
            ]; 

我知道我必须对 min 约束使用 big m 方法,但是,我不确定如何谢谢,

4

1 回答 1

0

您只会最小化 Cmax,而不是 diff。这可能是一个错误。

于 2015-10-07T17:05:35.227 回答