假设我在时间 t = 1 时有一组,伤害 = {1,5,6,9,11,21,23,29}。该集合的元素根据决策变量 Repair[n][t] 在不同周期进行更新。因此,为了更新集合的元素,我正在 OPL Cplex 中编写下面给出的代码。但我没有用这段代码得到结果。请指导我,以便我可以找到决策变量相关的时变集。优化问题有 30 个约束。但我只写了两个约束。
{int} Damage[time];
// objective function
max sum(n in bus)(t in time)pd[n][t];
// Constraints
subjected to {
forall ( t in time, rc in Rem, n in Damage){
(StatusLine[rc][n][t] == 1) => (repair[n][s]==1);
(StatusLine[rc][n][t] == 0) => (repair[n][s]==0);
}
}
forall (n in Damage, t in time:!(t==1)){
(repair[n][t]==1) => Damage[s].remove(n);
}
}
}
您混合了脚本部分允许的内容和建模部分允许的内容。您无法在建模部分修改集合。
Damage[s].remove(n);
无法在要阻止的主题中工作。
你可以在那里写什么
Damage[t][n]==0;
对于给定的 t 和给定的 n
你也有一些语法错误
range time=1..5;
range bus=1..3;
int repair[bus][time]=[[1 ,0]];
int Damage[bus][time];
dvar boolean pd[bus][time];
// objective function
maximize sum(n in bus,t in time)pd[n][t];
// Constraints
subject to {
forall (n in bus, t in time:!(t==1)){
(repair[n][t]==1) => (Damage[n][t]==0);
}
}
有效