使用决策变量作为数组索引的CPLEX OPL [英] CPLEX OPL using decision variable as array index
问题描述
在我的数据输入文件中,有参数Input [j] [n] [a] [b] [c] [d] [e] [f] [g] [h] [i] [k]对于j,n,a,b,c,d,e,f,g,h,i,k的所有值.
In my data input file, there is the parameter Input[j][n][a][b][c][d][e][f][g][h][i][k] for all values of j,n,a,b,c,d,e,f,g,h,i,k.
我的模型计算一些布尔决策变量(从dv1到dv10)(目的是使成本最小化).然后,我需要计算Value [j] [n],该值等于输入中取决于决策变量的相应值.但是错误是'Indexing array "Input" with type dvar boolean not supported by this algorithm'
My model calculates some boolean decision variables (from dv1 to dv10) (objective is to minimize costs). And then, I need to calculate Value[j][n], which equals the corresponding value in input depending on the decision variables. But the error is 'Indexing array "Input" with type dvar boolean not supported by this algorithm'
因此,我想执行以下操作:
Thus I want to do the following:
forall(j in J, n in N) {
Value[j][n] == Input[j][n][dv1][dv2][dv3][dv4][dv5][dv6][dv7][dv8][dv9][dv10][dv11][dv12];
}
如何在CPLEX中计算该值?提前致谢!
How can you calculate this in CPLEX? Thanks in advance!
推荐答案
您也可以看看
可以阅读的地方
range r=1..5;
float value[r]=[2,3,4.5,1,0];
dvar int i in 1..5;
maximize sum(k in r) value[k]*(k==i);
subject to
{
}
execute
{
writeln("i=",i);
}
这篇关于使用决策变量作为数组索引的CPLEX OPL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!