IloOr constraint is added to the model with some other constraints. The solver is called to solve the model. Then the IloOr is deleted and another IloOr constraint is added. Unfornatly the first IloOr constraint doesn't seem to be deleted as I checked *.lp output file. the second IloOr constraint did added. Here is the code:
for (int i = 0; i < 10; i++) {
IloOr pOr;
//for each loop x, y are different
pOr.add(x == 0 && y == 10);
pOr.add(y == 0 && x == 10);
mod.add(pOr);
mod.solve();
mod.remove(pOr);
pOr.end();
}
So it just adds more IloOr constraint for each loop.
Topic

Re: remove IloOr constraint
20121211T12:49:44ZThis is the accepted answer. This is the accepted answer.What version of CPLEX do you use? If I remember correctly then some of the older version had a bug that would result in exactly the behavior you observe (I take it you initialize pOr correctly with 'IloOr pOr(env)' and do not leave out the 'env' argument as you did in your post). 
Re: remove IloOr constraint
20121211T13:42:21ZThis is the accepted answer. This is the accepted answer. SystemAdmin
 20121211T12:49:44Z
What version of CPLEX do you use? If I remember correctly then some of the older version had a bug that would result in exactly the behavior you observe (I take it you initialize pOr correctly with 'IloOr pOr(env)' and do not leave out the 'env' argument as you did in your post).
Yes, IloOr is defined correctly 
Re: remove IloOr constraint
20121211T14:47:29ZThis is the accepted answer. This is the accepted answer. beckywang
 20121211T13:42:21Z
cplex 12.1
Yes, IloOr is defined correctly
If not then the only workaround I see is to explicitly reextract the model:
for (int i = 0; i < 10; i++) { IloOr pOr(env); //for each loop x, y are different pOr.add(x == 0 && y == 10); pOr.add(y == 0 && x == 10); mod.add(pOr); // Explicitly reextract the model. // To do this first extract a different model and then // extract the original model again. IloModel old = cplex.getModel(); IloModel empty(cplex.getEnv()); cplex.extract(empty); cplex.extract(old); empty.end(); cplex.solve(); mod.remove(pOr); pOr.end(); }
Updated on 20140324T22:44:00Z at 20140324T22:44:00Z by ironman 
Re: remove IloOr constraint
20121211T21:11:12ZThis is the accepted answer. This is the accepted answer. SystemAdmin
 20121211T14:47:29Z
The bug I mentioned was fixed for CPLEX 12.4.0.1. Any option to upgrade to this or an even more recent version of CPLEX?
If not then the only workaround I see is to explicitly reextract the model:
<pre class="java dw" dataeditorlang="java" datapbcklang="java" dir="ltr">for (int i = 0; i < 10; i++) { IloOr pOr(env); //for each loop x, y are different pOr.add(x == 0 && y == 10); pOr.add(y == 0 && x == 10); mod.add(pOr); // Explicitly reextract the model. // To do this first extract a different model and then // extract the original model again. IloModel old = cplex.getModel(); IloModel empty(cplex.getEnv()); cplex.extract(empty); cplex.extract(old); empty.end(); cplex.solve(); mod.remove(pOr); pOr.end(); } </pre> 
Re: remove IloOr constraint
20121213T22:21:39ZThis is the accepted answer. This is the accepted answer. beckywang
 20121211T21:11:12Z
Thanks. The work around works. 
Re: remove IloOr constraint
20121214T07:38:19ZThis is the accepted answer. This is the accepted answer. beckywang
 20121213T22:21:39Z
We have upgraded to cplex 12.5. So I have both programs with work around(using cplex 12.0) and without. I ran both programs. It produced different results. The one without the work around is faster which I sort of understand, but why different results. Then I tried the work around program on the upgraded version. This time both programs came to the same result.
Different optimal objective function values? Different optimal x vectors? 
Re: remove IloOr constraint
20121214T17:45:24ZThis is the accepted answer. This is the accepted answer. SystemAdmin
 20121214T07:38:19Z
What is the exact difference you observe?
Different optimal objective function values? Different optimal x vectors? 
Re: remove IloOr constraint
20130102T08:52:47ZThis is the accepted answer. This is the accepted answer. beckywang
 20121214T17:45:24Z
Both the optimal obj. value and optimal x are different.
Could you export the two models to SAV files and attach them here?