Originally posted by: Lessi
Another question: when I add codes to extract the value of the incumbent solution, it throws an exception. Your suggestion is valueable!
IloBoolVarArray y(env, 0); //this is the declaration of the y variables
...
ILOINCUMBENTCALLBACK0(feasibilityCheck)
{
cout << "we are in an incumbent callback!!!" << endl;
int newIncumbent = this->hasIncumbent();
if (newIncumbent)
{
cout << "we have an incumbent solution" << endl;
//those two lines of code throw an exception - I also try with IloNumArray y_val(env,"Number of variables to extract"); but it does not solve the issue
IloNumArray y_val(env);
this->getValues(y_val, y);
//I also try again with getValue(y[0]); it throws the same exception.
}
}
I put the code in a try/catch, and it shows: Error: IloExtractable 2 IloNumVarI has not been extracted by IloAlgorithm
Thanks,
-----------------------
Solved: I use model.add method to explicitly add the variables to the model.
#CPLEXOptimizers#DecisionOptimization