Originally posted by: SystemAdmin
Daniel,
I have a class with all members being publicly declared. The environment is send to this class as argument to constructor.
void main ()
{
IloEnv env;
CP1 P1(env, nr1, nr2);
}
// class P1
class CP1
{
// declare everything needed for both problem1 and problem2
// declare different functions to construct parts of the model
solveP1();
}
Now I have tried two approaches resulted unwantedly and unexpectedly:
1)
CP1 ::solveP1()
{
// do some crazy stuffs
m_cplexP1.use(solveP2(env, this, ));
m_cplexP1.solve();
}
now inside the callback
ILOINCUMBENTCALLBACKn()
{
//try to build a local model and solve it make use of the elements of the class. Many difficulties raise here.
}
2.1) the second approach is like this:
Let's separate the P2 elements in a different class CP2 and pass the environment to it:
establish a complete class of data structures and functionalities.
Now:
CP1::solveP1()
{
// do some crazy stuffs
CP2 P2(env, ...);
m_cplexP1.use(Ben(env, P2, ... )) // sent by value
}
now inside the callback
ILOINCUMBENTCALLBACKn()
{
//the constraints are already introduced in the SP
// just insert them in a model and NOW MAKE YOUR OWN OBJECTIVE add it to the model and solve it.
// export the model
/ sounds ...
}
2.2) the thirs one is that we do not pass it into the callback; rather create it inside the callback
ILOINCUMBENTCALLBACKn()
{
CP2 p2;
// do create the customized objectve here and add it to the model.
// no matter if the model has been already extracted to cplex or you wanna do it here.
}
All these failed.
I dont know if I could explain it well; I tried to explain it short and accurate!?
Plase let me know if you need more details.
#CPLEXOptimizers#DecisionOptimization