求解模型后,我需要访问四维decion变量的值。这是我在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);
}
}
}
我真的需要您的帮助才能使用模型的仿真结果。
我期待着您的来信。
扎卡里亚语
答案 0 :(得分:1)
听起来您已经成功构建并解决了模型。正确?假设这是正确的,您应该可以使用以下内容访问解决方案值:
for (int i = 0; i < this.y.length; i++) {
for (int j = 0; j < this.y[i].length; j++) {
for (int k = 1; k < this.y[i][j].length; k++) {
double[] x = cplex.getValues(y[i][j][k]);
for (int l = 0; l < this.y[i][j][k].length; ++l) {
System.out.printf("Variable [%d][%d][%d][%d] = %f%n",
i, j, k, l, x[l]);
}
}
}
}
答案 1 :(得分:-1)
我建议在CPLEX_Studio128 \ cplex \ examples \ src \ java
中使用示例facility.java在那里您将看到
// Create variables. We have variables
// open[j] if location j is open.
// supply[i][j]] how much client i is supplied from location j
IloNumVar[] open = cplex.boolVarArray(nbLocations);
IloNumVar[][] supply = new IloNumVar[nbClients][];
for (int i = 0; i < nbClients; i++)
supply[i] = cplex.numVarArray(nbLocations, 0.0, 1.0);