Decision Optimization

 View Only
Expand all | Collapse all

Optimization about array

Archive User

Archive UserMon March 07, 2016 07:08 AM

ALEX FLEISCHER

ALEX FLEISCHERMon March 07, 2016 09:34 AM

  • 1.  Optimization about array

    Posted Mon March 07, 2016 07:08 AM

    Originally posted by: Rym


    Hello

     

    How can i optimize this statement without loop for

    main

    {

    var ress=new Array();

    for(var g in masterOpl.countPV)
        {

    ress[masterOpl.indexes.get(g.npm,g.nvm)]=masterOpl.countPV[g];
        }

     

     

    with the model:

    tuple PM
    {
      int npm;
      string nvm;
      }

    int VMmin=1;
    int VMmax=4;

    range P = 1..p;

    string S[VMmin..VMmax]=["s","m","l","xl"];
     {string} VMTypes={S[v] | v in VMmin..VMmax};

      {PM} indexes={<i,j> | i in P,j in VMTypes};

    int countPV[ <i,j> in indexes]=OPPMVMS[j][i];

     

     

    Thanks


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Optimization about array

    Posted Mon March 07, 2016 09:34 AM

    Hi,

    in scripting you may do reference copy:

    execute
     {

    var AA=new Array(3);
    AA[1]=2;
    var BB=new Array(3);
    BB=AA;
    writeln(AA[1]," ",BB[1]);
    BB[1]=1;
    writeln(AA[1]," ",BB[1]);
    }

    gives

     

    2 2
    1 1

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer