Topic
  • 4 replies
  • Latest Post - ‏2013-12-16T12:43:00Z by Cagri
SystemAdmin
SystemAdmin
623 Posts

Pinned topic paasing data to cp model from the main model

‏2009-05-06T18:46:16Z |

[shadi said:]

i have the following code:

[i]  var cpConfig0 = new IloOplRunConfiguration("btpair.mod", "basicData.dat");
  var cpModel0 = cpConfig0.oplModel;
  var cpData0 = cpModel0.dataElements;
 
        cpData0.nSeq=10;
        cpModel0.addDataSource(cpData0);
        cpModel0.generate();[/i]


in the basicData i have the following assignment:
nSeq=20;

why the btpair use 20 and not 10.  i want to give the nSeq variable initial value and be able to change it however i want.

thanks in advanced
shadi
Updated on 2009-07-27T21:15:26Z at 2009-07-27T21:15:26Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    623 Posts

    Re: paasing data to cp model from the main model

    ‏2009-05-07T18:02:43Z  

    [fwagner@Ilog.fr said:]

    You cannot regenerate an OPL model.
    Getting data elements from an OPL model triggers its generation, in order to have all data available.

    If you want to reinstantiate a model with modified data, you need a new object.

    Something like:
      var cpModel1 = new IloOplModel(cpModel0.modelDefinition);
      cpData0.nSeq=10;
      cpModel1.addDataSource(cpData0);
      cpModel1.generate();



  • SystemAdmin
    SystemAdmin
    623 Posts

    Re: paasing data to cp model from the main model

    ‏2009-05-08T16:21:18Z  

    [fwagner@Ilog.fr said:]

    You cannot regenerate an OPL model.
    Getting data elements from an OPL model triggers its generation, in order to have all data available.

    If you want to reinstantiate a model with modified data, you need a new object.

    Something like:
      var cpModel1 = new IloOplModel(cpModel0.modelDefinition);
      cpData0.nSeq=10;
      cpModel1.addDataSource(cpData0);
      cpModel1.generate();



    [shadi said:]

    thank you Frank

    shadi
  • SystemAdmin
    SystemAdmin
    623 Posts

    Re: paasing data to cp model from the main model

    ‏2009-07-23T16:20:32Z  

    [shadi said:]

    thank you Frank

    shadi

    [shadi said:]

    Dear Frank,
    i thought that i solved this problem using another way, but now When generateing the odm application from my project i can see that the way that i followed is not correct, i want to pass parameters from the scenario to this model, my current code is:


      var cpConfig0 = new IloOplRunConfiguration("btpair.mod", "basicData.dat");
      var cpModel0 = cpConfig0.oplModel;
      var cpData0 = cpModel0.dataElements;
     
        // i want to pass many data here in order to initialize my global data like :
        cpData0.nSeq=10;

        cpModel0.addDataSource(cpData0);
        cpModel0.generate();


    and the btpair model use only the data from the basicData data file and not the data that i passed before the generate function (nSeq=20 and not 10).

    can you explain to me how i can do that in details, becuase i have not only simple variable like nSeq, i have more complex data structures like tupleset and arrays, and i want pass these data from database from the odm.
    where to add the code that you sent? after the  cpModel0.generate(); command?

    thanks in advanced
    Kshieboun Shadi


  • SystemAdmin
    SystemAdmin
    623 Posts

    Re: paasing data to cp model from the main model

    ‏2009-07-27T21:15:26Z  

    [shadi said:]

    Dear Frank,
    i thought that i solved this problem using another way, but now When generateing the odm application from my project i can see that the way that i followed is not correct, i want to pass parameters from the scenario to this model, my current code is:


      var cpConfig0 = new IloOplRunConfiguration("btpair.mod", "basicData.dat");
      var cpModel0 = cpConfig0.oplModel;
      var cpData0 = cpModel0.dataElements;
     
        // i want to pass many data here in order to initialize my global data like :
        cpData0.nSeq=10;

        cpModel0.addDataSource(cpData0);
        cpModel0.generate();


    and the btpair model use only the data from the basicData data file and not the data that i passed before the generate function (nSeq=20 and not 10).

    can you explain to me how i can do that in details, becuase i have not only simple variable like nSeq, i have more complex data structures like tupleset and arrays, and i want pass these data from database from the odm.
    where to add the code that you sent? after the  cpModel0.generate(); command?

    thanks in advanced
    Kshieboun Shadi


    [shadi said:]

    hi,
    i solved this problem.

    shadi