Topic
  • 9 replies
  • Latest Post - ‏2013-09-25T12:56:58Z by AlexFleischer
pickup
pickup
19 Posts

Pinned topic syntax error

‏2013-09-20T14:26:39Z |

i have a problem when i execute my model, syntax error in the objective function : this is not an array type

the objectiv function is : sum v in V sum i in I sum  j in J  ( Cv * DIJij * XIJVijv )

in cplex : 

 

minimize sum (v in V, i in I, j in J)(CV[v]*DIJ[i][j]*Xijv[i][j][v]);
 
Updated on 2013-09-20T14:27:21Z at 2013-09-20T14:27:21Z by pickup
  • AlexFleischer
    AlexFleischer
    1268 Posts

    Re: syntax error

    ‏2013-09-20T14:47:25Z  

    Hi,

     

    can you attach your model ?

     

    regards

  • pickup
    pickup
    19 Posts

    Re: syntax error

    ‏2013-09-20T21:49:09Z  

    hi, 

    this is my model, thank you 

    regards 

    Attachments

  • AlexFleischer
    AlexFleischer
    1268 Posts

    Re: syntax error

    ‏2013-09-23T13:41:08Z  
    • pickup
    • ‏2013-09-20T21:49:09Z

    hi, 

    this is my model, thank you 

    regards 

    Hi

    if you add teh key keyword in

    tuple distance{
     key int i;
     key int j;
     int valeur;
    }

     

    and

     

    tuple coutveh{
      key int v;
       int  coutvehicule;
    }

     

    then if you write

    minimize
    sum (v in V)
      sum (i in I)
        sum ( j in J)
    item(CV,v).coutvehicule*item(DIJ,<i.i,j.j>).valeur*Xijv[i][j][v];

    subject to
    {
    }

     

    the model will work fine

     

    regards

     

     

  • pickup
    pickup
    19 Posts

    Re: syntax error

    ‏2013-09-23T21:54:27Z  

    Hi

    if you add teh key keyword in

    tuple distance{
     key int i;
     key int j;
     int valeur;
    }

     

    and

     

    tuple coutveh{
      key int v;
       int  coutvehicule;
    }

     

    then if you write

    minimize
    sum (v in V)
      sum (i in I)
        sum ( j in J)
    item(CV,v).coutvehicule*item(DIJ,<i.i,j.j>).valeur*Xijv[i][j][v];

    subject to
    {
    }

     

    the model will work fine

     

    regards

     

     

     

    thank you Mr. Alex ,

    and how we can define this two set in a graph G=( N, A)

     SEGP (i) = {j in N : (i, j) in A} : is all successors of node i

     SEGM (i) = {j in N : (j, i) in A} :all predecessors of node i

    in my model I defined as : 

     

     
    tuple Ssegplus{
     
     int n; 
     int s;
    tuple Ssegmoins{
     
     int n; 
     int e;
    }  

     

    {Ssegplus}SEGP=...;
    {Ssegmoins}SEGM=...;

    but i have a problem when i execute my model, syntax error in the contraints: 

    1) The type Ssegplus {} can not be used to userFunction.

    2) The type Ssegmoin{} can not be used to userFunction.

     

     subject to
    {
      
      c1:   forall (i in ICF)

    sum (v in V, j in SEGP[i]) Xijv[i][j][v]==1;

       
      c2 : forall (i in ICF)
    sum (v in V, j in SEGM[i])Xijv[j][i][v]==1;

     

    regards
    Updated on 2013-09-23T22:23:22Z at 2013-09-23T22:23:22Z by pickup
  • AlexFleischer
    AlexFleischer
    1268 Posts

    Re: syntax error

    ‏2013-09-24T07:59:16Z  
    • pickup
    • ‏2013-09-23T21:54:27Z

     

    thank you Mr. Alex ,

    and how we can define this two set in a graph G=( N, A)

     SEGP (i) = {j in N : (i, j) in A} : is all successors of node i

     SEGM (i) = {j in N : (j, i) in A} :all predecessors of node i

    in my model I defined as : 

     

     
    tuple Ssegplus{
     
     int n; 
     int s;
    tuple Ssegmoins{
     
     int n; 
     int e;
    }  

     

    {Ssegplus}SEGP=...;
    {Ssegmoins}SEGM=...;

    but i have a problem when i execute my model, syntax error in the contraints: 

    1) The type Ssegplus {} can not be used to userFunction.

    2) The type Ssegmoin{} can not be used to userFunction.

     

     subject to
    {
      
      c1:   forall (i in ICF)

    sum (v in V, j in SEGP[i]) Xijv[i][j][v]==1;

       
      c2 : forall (i in ICF)
    sum (v in V, j in SEGM[i])Xijv[j][i][v]==1;

     

    regards

    Hi,

    {Ssegplus}SEGP=...;
    {Ssegmoins}SEGM=...;

    are sets.

    SEGP[i] is an array indirection.

    Instead of

    sum (v in V, j in SEGP[i]) Xijv[i][j][v]==1;

    have you tried anything like

    sum (v in V, j in SEGP:j.n==i) Xijv[i][j.s][v]==1;

    regards

  • pickup
    pickup
    19 Posts

    Re: syntax error

    ‏2013-09-24T20:48:03Z  

    Hi,

    {Ssegplus}SEGP=...;
    {Ssegmoins}SEGM=...;

    are sets.

    SEGP[i] is an array indirection.

    Instead of

    sum (v in V, j in SEGP[i]) Xijv[i][j][v]==1;

    have you tried anything like

    sum (v in V, j in SEGP:j.n==i) Xijv[i][j.s][v]==1;

    regards

    hi,

    yes i try it but i have problem : 

    sum (v in V, j in SEGP:j.n==i) Xijv[i][j.s][v]==1;

    Not available for int operator == <i:int>.

     

    regards

     

     
     
  • AlexFleischer
    AlexFleischer
    1268 Posts

    Re: syntax error

    ‏2013-09-25T07:15:31Z  
    • pickup
    • ‏2013-09-24T20:48:03Z

    hi,

    yes i try it but i have problem : 

    sum (v in V, j in SEGP:j.n==i) Xijv[i][j.s][v]==1;

    Not available for int operator == <i:int>.

     

    regards

     

     
     

    Ok then

    sum (v in V, j in SEGP:j.n==i.i) Xijv[i][<j.s>][v]==1;
     

  • pickup
    pickup
    19 Posts

    Re: syntax error

    ‏2013-09-25T12:11:43Z  

    Ok then

    sum (v in V, j in SEGP:j.n==i.i) Xijv[i][<j.s>][v]==1;
     

    hi 

    thank you it works now,

    and for this 2 constraint please :

    c4: forall ( v in V)  ( sum of  i in SEGP (0) ) X0iv=1 ; to say all successors of node  0 ( 0 is the index of dépot) 

    c5: forall ( v in V)  ( sum of  i in SEGM (0) ) Xi0v=1 ; to say all predecessors of node  0 ( 0 is the index of dépot) ,

    IN CPLEX :

     

    c4 : forall (v in V) 
    sum (i in SEGP:j.n==ID.ID)Xijv[i][<j.s>][v]==1; (when we say" i in ID " it means i is the dépôt  with index 0)
     
    c5: forall (v in V) 
    sum (i in SEGM:j.n==ID.ID)Xijv[i][<j.e>][v]==1;  (when we say" i in ID " it means i is the dépôt  with index 0)

    syntax error :

     

    1) The name "j" does not exist
     
    2) Operator not available for <i:int> Sinddepot == {}.

    regards

     

     

  • AlexFleischer
    AlexFleischer
    1268 Posts

    Re: syntax error

    ‏2013-09-25T12:56:58Z  
    • pickup
    • ‏2013-09-25T12:11:43Z

    hi 

    thank you it works now,

    and for this 2 constraint please :

    c4: forall ( v in V)  ( sum of  i in SEGP (0) ) X0iv=1 ; to say all successors of node  0 ( 0 is the index of dépot) 

    c5: forall ( v in V)  ( sum of  i in SEGM (0) ) Xi0v=1 ; to say all predecessors of node  0 ( 0 is the index of dépot) ,

    IN CPLEX :

     

    c4 : forall (v in V) 
    sum (i in SEGP:j.n==ID.ID)Xijv[i][<j.s>][v]==1; (when we say" i in ID " it means i is the dépôt  with index 0)
     
    c5: forall (v in V) 
    sum (i in SEGM:j.n==ID.ID)Xijv[i][<j.e>][v]==1;  (when we say" i in ID " it means i is the dépôt  with index 0)

    syntax error :

     

    1) The name "j" does not exist
     
    2) Operator not available for <i:int> Sinddepot == {}.

    regards

     

     

    Hi

     

    the syntax is ok for

    c4 : forall (v in V)
    sum (i in SEGP:i.n==0)Xijv[item(ICF,0)][<i.s>][v]==1;

    so I will let you adapt it so that is does what you need.

     

    Regards