Topic
  • 3 replies
  • Latest Post - ‏2013-12-08T07:15:07Z by AlexFleischer
6A0Q_Hartioun_Arzoumanian
6 Posts

Pinned topic How to update values of variables in opl main script

‏2013-12-06T21:34:59Z |

How could I add two vectors in the main script,

for example I need to create a new two dimensional array and assign it an opl data array and then add another two dimensional array to it.

How can this be done in OPL?

  • AlexFleischer
    AlexFleischer
    1248 Posts

    Re: How to update values of variables in opl main script

    ‏2013-12-07T08:52:25Z  

    Hi,

    you may use a scripting Array through the keyword Array or you can use also an OPL array that you have declared before.

    The computations will be faster if you do them in OPL like int c[i in R1][j in R2]=a[i][j]+b[i][j];

    regards

     

  • 6A0Q_Hartioun_Arzoumanian
    6 Posts

    Re: How to update values of variables in opl main script

    ‏2013-12-07T11:16:23Z  

    Hi,

    you may use a scripting Array through the keyword Array or you can use also an OPL array that you have declared before.

    The computations will be faster if you do them in OPL like int c[i in R1][j in R2]=a[i][j]+b[i][j];

    regards

     

    Yes but whenever I do the following:

    var src = new IloOplModelSource("project.mod");    
    var def = new IloOplModelDefinition(src);     
    var cplex = new IloCplex();      
    var model = new IloOplModel(def, cplex);     
    var data = new IloOplDataSource("project.dat");
    var data2 = new IloOplDataElements();

    data2.VMMapping[2][4] = 1; // here I get an error

    it says VMMapping doesnot exist.

    where VMMapping is a two dimensional array declared in project.mod file as follows:

    int VMMapping[v in V][d in D] = ...; 

    regards,

  • AlexFleischer
    AlexFleischer
    1248 Posts

    Re: How to update values of variables in opl main script

    ‏2013-12-08T07:15:07Z  

    Yes but whenever I do the following:

    var src = new IloOplModelSource("project.mod");    
    var def = new IloOplModelDefinition(src);     
    var cplex = new IloCplex();      
    var model = new IloOplModel(def, cplex);     
    var data = new IloOplDataSource("project.dat");
    var data2 = new IloOplDataElements();

    data2.VMMapping[2][4] = 1; // here I get an error

    it says VMMapping doesnot exist.

    where VMMapping is a two dimensional array declared in project.mod file as follows:

    int VMMapping[v in V][d in D] = ...; 

    regards,

    Hi

     

    as said in another thread you should first assign to VMMapping an array

    regards