Hi,
Here's my problem : I have two MILP that I compute one after the other.
The second one uses the same data as the first one and some result from the first optimization.
In order to be able add cuts an to use heuristics easily, I computed my problem in C++,
But to be able to change fastely the model, I computed it in OPL.
So, I import the .mod and .data with the associated functions, but IloOplModel does non have an add() method, so I canot add the constraints that use first optimization data.
And I don't want to have to write an .dat file and then add it as a second Source for the problem because I think this is stupid to write a file to open it right away. Thus, I don't know if that is possible...
Is there a way to convert an IloOplModel into a IloModel once it has been initialized with its .mod and .dat files ?
Thanks for your time,
Adrian
Topic

Re: Add constraints to an IloOplModel
20120516T01:15:11ZThis is the accepted answer. This is the accepted answer. AlexFleischer
 20120515T13:56:45Z
hi,
could
<pre class="java dw" dataeditorlang="java" datapbcklang="java" dir="ltr">IloOplModel opl = ... opl.getCplex().getModel(); </pre>
help?
Regards 
Re: Add constraints to an IloOplModel
20120516T07:00:48ZThis is the accepted answer. This is the accepted answer. gustavokambara
 20120516T01:15:11Z
But how can I add such constraints since I don't have the decision variables explicitly declared in Java?
opl.generate();
IloModel model = opl.getCplex().getModel();
IloNumVarMap X = opl.getElement("X").asNumVarMap();
for(IloInt t=1; t<=T; t++){
for(IloInt r=1; r<=R; r++){
IloRange C(env, f_min(t,r), V[t].get(r), f_max(t,r));
model.add(C);
}
Thanks again, Alex
Adrian 
Re: Add constraints to an IloOplModel
20120516T11:50:06ZThis is the accepted answer. This is the accepted answer. SystemAdmin
 20120516T07:00:48Z
This one, I've got the answer !
opl.generate();
IloModel model = opl.getCplex().getModel();
IloNumVarMap X = opl.getElement("X").asNumVarMap();
for(IloInt t=1; t<=T; t++){
for(IloInt r=1; r<=R; r++){
IloRange C(env, f_min(t,r), V[t].get(r), f_max(t,r));
model.add(C);
}
Thanks again, Alex
Adrian 
Re: Add constraints to an IloOplModel
20120516T12:52:08ZThis is the accepted answer. This is the accepted answer. gustavokambara
 20120516T11:50:06Z
And where do you use X? V[t] = X[t]?