I am trying to translate some Gurobi code across to CPLEX and am having trouble working out how to set the starting value for a variable.
The original code looks like this:
for (int b=0; b<nB ; ++b){
for (int t=0; t<t_max; ++t){
Yvars[b][t].set(GRB_DoubleAttr_Start, startVals[b][t+shift]);
}
}
what would be the equivalent CPLEX code? I cant find information anywhere of how to do this. The closest I can find is this:
However, that suggests that I have to add the start values to the model itself, like this:
IloNumVarArray startVar(env);
IloNumArray startVal(env);
for (int b = 0; b < nB; ++b)
for (int t = 0; t < t_max; ++t) {
startVar.add(Yvars[b][t]);
startVal.add(startVals[b][t+shift]);
}
cplex.addMIPStart(startVar, startVal);
And not just affect the individual variables as in the original code. Is there a way to just do it to the variables like with Gurobi? Or do I have to do everything at once?