Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
Expand all | Collapse all

shift arraye

  • 1.  shift arraye

    Posted Tue August 05, 2014 02:50 PM

    Originally posted by: fahimeh


    hello.

    I want to define an a decision variable (a[i][j]), but when i define it, in this way

    using CP;

    range R=0..3;

    range Rm=1..3;

    range Round =1..4;

    dvar int a[R][R] in 0..1;

    dvar int tmp [R] in 0..1;

    dvar int b[R][R] in 0..1;

    minimize

    sum (i,j in R) a[i][j]+b[i][j];

     

    subject to {

    forall( i in R){
      forall( j in R){
        c= (i+j)%4;
     
        tmp[j]=a[i][c];
        }
      forall( j in R){
          a[i][j]=tmp[j];
           }  
        }      
     forall(i in R) {

     forall (j in R){

      a[i][j]+b[i][j] >=1

       }

      }

    }

     

    it makes this error   " Type syntax error, unexpected ="

     

    would you please tell me if i want to shift decision variable,what code i should write?

    thank


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 2.  Re: shift arraye

    Posted Thu August 14, 2014 08:49 AM

    Originally posted by: Philippe_Refalo


    Hi Fahimeh,

    OPL is a declarative langage and you can only state constraints in the suject to section. That is you cannot use = (an assignment) between variables. You have to make then equal using a constraint like x == y. In your case I believe you want to make some variables equal in the matrix a. In this case you can use direct constraints like a[i][c] == a[i][j] wihout the need for an intermediate variable (tmp). Since tmp is a mathematical variable it cannot be "reused" as in an imperative langage.

    Regards

    Philippe


    #DecisionOptimization
    #OPLusingCPOptimizer