Originally posted by: Helia
Hi everyone,
I am solving a quite large problem in OPL and to save time, I give an initial solution to the problem. What seems problematic is that the solution which is built upon my initial solution, has terrible quality. In the initial solution, I provide the value of all major decision variables in the model. Meaning that only those decision variables who are the summation of these major decision variables, are not given. However, the value of objective function of the initial solution is way larger than it should be. Any idea?
To solve this issue, I have tried to provide the value of objective function and some of the non-major decision variables in the initial solution. Now the issue is that these decision variables are not arrays and it seems like I can not use the same procedure (of defining a variable, attaching it to the decision variable and setting the vector) for these decision variables in main script, because I receive this error:
Description Resource Path Location Type
Scripting runtime error: Method attach() can only be used with arrays in this context..
Here is a copy of a part of the main script:
main{
thisOplModel.generate();
var def = thisOplModel.modelDefinition;
//access data file
var data = new IloOplDataSource("10 co-103.dat");
var cplex1 = new IloCplex();
var opl1 = new IloOplModel(def, cplex1);
opl1.addDataSource(data);
opl1.generate();
// Setting initial solution
writeln("Setting initial solution");
var FinalDCvectors = new IloOplCplexVectors();// for this variable and teh next one, there is no error because they replace arrays
var LTLDCDCFlowVectors = new IloOplCplexVectors();
var ObjFunVector=new IloOplCplexVectors(); // causing error
var TotalDCCostVector =new IloOplCplexVectors(); // causing error
var TotalFlowCostVector =new IloOplCplexVectors(); // causing error
// We attach the FinalDCSolInitial (defined as data) as starting solution for the variables finalDC.
FinalDCvectors.attach(opl1.JointDCOpen,opl1.FinalDCSolInitial );
LTLDCDCFlowVectors.attach(opl1.LTLFlowDCDC,opl1.LTLCompanyDCDCFlowSolInitial );
ObjFunVector.attach(opl1.TotalLogisticsCost,opl1.InitialObjFun);
TotalDCCostVector.attache(opl1.TotalDCCost,opl1.InitialTotalDCCost) ;
TotalFlowCostVector.attach(opl1.TotalFlowCost,opl1.InitialTotalFlowCost) ;
FinalDCvectors.setVectors(cplex1);
LTLDCDCFlowVectors.setVectors(cplex1);
ObjFunVector.setVectors(cplex1);
TotalDCCostVector.setVectors(cplex1);
TotalFlowCostVector.setVectors(cplex1);
writeln("Start problem solving");
cplex1.solve();
opl1.postProcess();
}
Thanks for your insight
Best,
Helia
#DecisionOptimization#OPLusingCPLEXOptimizer