Originally posted by: Sulivan
I have developed two C++ programmes using CP optimizer to solve scheduling problem, which are compiled to MEX functions to be called by Matlab. Both programmes work fine when they are running independently in different Matlab sessions. However, when I run these programmes one after another in the same Matlab session, I receive the following exception:
Exception thrown at (some position in memory) (main.mexw64) in MATLAB.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF. occurred
Then the programme crashes.
Both programmes are written like the following:
IloEnv env;
IloModel model(env);
/* Add constraints and objective */
IloCP cp(model);
//IloCP cp(env);
// cp.extract(model);
// cp.setParameter(...);
if (cp.solve()) {
// Do something
}
//cp.end();
env.end();
I tried commenting and uncommenting cp.end() and env.end() in the last two lines; or using different names in two programmes, (eg., model and model1, cp and cp1). I have also tried using IloCP cp(env) and cp.extract(model). None of these worked, stilling receiving the same exception. The symptom is:
1. Running these two programmes in different Matlab sessions, fine.
2. Running any of them in the same Matlab session for multiple times, fine.
3. Running one of them after the other in the same Matlab session, exception thrown during the call of the constructor IloCP in the second programme.
Can anybody figure out the reason or work around a solution? Thanks in advance.
#CPOptimizer#DecisionOptimization