Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

Initializing array of tuple

  • 1.  Initializing array of tuple

    Posted 11/22/17 10:36 AM

    Originally posted by: Rym


    I'm writing a model with OPL and i have this error 

     
    Erreur de l'analyseur syntaxique de script : missing expression.

     

    int N=1..5;

    tuple edge // link definition
    {
    int i;
    int j;
    }
    {edge} liaison = { <i,j> | i in 1..Nodes,j in i..Nodes:i!=j};

     

    tuple VDCr
    {

    int nv;
    int liaisons[liaison];

    }

    VDCr VDC[N];

     

     


    execute xvs
    {

     for(var i in N )
        
     {
       var x1=1;
       var x2=x1+1; 
       
      while((x1<=((VDC[i].nv)-1))&&(x2<=VDC[i].nv))   
        
      {
         
       
       var trouve=0;
        x2=x1+1
       while( x2<=VDC[i].nv)
       
       {
       
       VDC[i].liaisons[<x1,x2>]=1+Opl.rand(1);  

       if(VDC[i].liaisons[<x1,x2>]==1)
       {
       trouve=1;   
       
     }
     else
     {
     trouve=0; 
     
    }  
           
       
       
       x2++;
           
    }    
        
       if(trouve==1) 
       
       {
       x1++;   
       
     }      
      
        
        
      }
    }  
    }          
        

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Initializing array of tuple

    Posted 11/22/17 11:15 AM

    hi

    //int N=1..5;
     range  N=1..5;
     int Nodes=5;
    tuple edge // link definition
    {
    int i;
    int j;
    }
    {edge} liaison = { <i,j> | i in 1..Nodes,j in i..Nodes:i!=j};

     

    tuple VDCr
    {

    int nv;
    int liaisons[liaison];

    }

    VDCr VDC[N];

     

    edge x1x2;


    execute xvs
    {

     for(var i in N )
        
     {
       var x1=1;
       var x2=x1+1;
       
      while((x1<=((VDC[i].nv)-1))&&(x2<=VDC[i].nv))   
        
      {
         
       
       var trouve=0;
        x2=x1+1
       while( x2<=VDC[i].nv)
       
       {
       x1x2.x1=x1;
       x1x2.x2=x2;
       VDC[i].liaisons[x1x2]=1+Opl.rand(1);  
       if(VDC[i].liaisons[x1x2]==1)
       {
       trouve=1;   
       
     }
     else
     {
     trouve=0;
     
    }  
           
       
       
       x2++;
           
    }    
        
       if(trouve==1)
       
       {
       x1++;   
       
     }      
     
        
        
      }
    }  
    }         

    works

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer