Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
5 replies Latest Post - ‏2012-05-16T12:52:08Z by SystemAdmin
SystemAdmin
SystemAdmin
1883 Posts
ACCEPTED ANSWER

Pinned topic Add constraints to an IloOplModel

‏2012-05-15T08:43:19Z |
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
Updated on 2012-05-16T12:52:08Z at 2012-05-16T12:52:08Z by SystemAdmin
  • AlexFleischer
    AlexFleischer
    1126 Posts
    ACCEPTED ANSWER

    Re: Add constraints to an IloOplModel

    ‏2012-05-15T13:56:45Z  in response to SystemAdmin
    hi,

    could

    IloOplModel opl = ...
    opl.getCplex().getModel();
    


    help?

    Regards
    Updated on 2014-03-26T05:56:34Z at 2014-03-26T05:56:34Z by AlexFleischer
    • gustavokambara
      gustavokambara
      3 Posts
      ACCEPTED ANSWER

      Re: Add constraints to an IloOplModel

      ‏2012-05-16T01:15:11Z  in response to AlexFleischer
      But how can I add such constraints since I don't have the decision variables explicitly declared in Java?
      • SystemAdmin
        SystemAdmin
        1883 Posts
        ACCEPTED ANSWER

        Re: Add constraints to an IloOplModel

        ‏2012-05-16T07:00:48Z  in response to gustavokambara
        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