【发布时间】:2018-11-29 16:49:44
【问题描述】:
求解模型后,我需要访问四维十进制变量的值。这是我在 Java 中的 decion 变量的声明:
this.y = new IloIntVar[this.Ncd][][][];
for(int i=0; i<this.y.length;i++) {
this.y[i]= new IloIntVar[this.Ncd][][];
for(int j=0; j<this.y[i].length;j++) {
this.y[i][j]= new IloIntVar[this.Nbv+1][];
for(int k=1; k<this.y[i][j].length; k++) {
this.y[i][j][k]= new IloIntVar[this.T+1];
this.y[i][j][k]= this.cplex.boolVarArray(this.T+1);
}
}
}
我真的需要你的帮助才能使用我的模型的模拟结果。
期待您的来信。
扎卡利亚
【问题讨论】:
-
顺便说一句,在您的代码 sn-p 中,您设置了两次
this.y[i][j][k]。一次使用new IloIntVar[this.T+1],再次使用this.cplex.boolVarArray(this.T+1)。您可能应该摆脱前者,因为它没有做任何有成效的事情。 -
在最里面的for循环中以
k=1开头似乎也有点奇怪。这是故意的吗? -
@rkersh 谢谢你的回答.. 我声称我从 k = 1 开始,因为它涉及所有车辆。关于您对报告结构的评论,我想知道我是否可以使用以下语句:
this.y = new IloIntVar [this.Ncd] [this.Ncd] [this.Nbv + 1] [this.T + 1]; for (int i = 0; i <this.Ncd; i ++) { for (int j = 0; j <this.Ncd; j ++) { for (int k = 1; k <= this.Nbv; k ++) { for (int t = 1; t <this.T + 1; t ++) { this.y [i] [j] [k] [t] = this.cplex.boolVar (); } } } }? -
如果你想要的话,可以使用
k=1;您的多维数组中会有一些空槽,您只需要注意这一点。没有必要停止使用boolVarArray,否则。 -
@rkersh 如果我理解正确,最后这句话是否正确?