Topic
  • 4 replies
  • Latest Post - ‏2013-07-27T22:19:30Z by W7AJ_Lingli_Wang
W7AJ_Lingli_Wang
W7AJ_Lingli_Wang
11 Posts

Pinned topic How to correct my model?

‏2013-07-26T00:56:42Z |

The following is my model just for programming practice.  I got the message that there is as error in  ct6 (those red statements)  and the message says "syntax error, unexpected =". 

It have puzzled my for two days. How to overcome it ? Help, thank in advance!

 

 rang Phases=1..6; 

int dr[Phases]=...; 
 
int sp_w=710; 
int sp_s=725; 
int a=...; 
int b=...; 
 
dvar int+ fr[Phases];
dvar int+ hw_wd[Phases]; 
dvar int+ fr_hd; 
dvar int+ hw_hd; 
 
 
minimize
  b*fr_hd+sum(i in Phases)
  a*fr[i]; 
 
subject to {
  forall(i in Phases)
    ct1:
      hw_wd[i]*fr[i]>=dr[i]; 
  forall(i in Phases)
    ct2:
      hw_wd[i]*fr[i]-hw_wd[i]<dr[i];
  forall(i in Phases:i%2==1)
    ct3:  
      hw_wd[i]<=8; 
  forall(i in Phases:i%2==1)
    ct3:
      hw_wd[i]>=4;      
  forall(i in Phases:i%2==0)
    ct4:
       hw_wd[i]<=10; 
  forall(i in Phases:i%2==0)
    ct4:
       hw_wd[i]>=8;    
    ct5:
       hw_hd<=10;
    ct5:
       hw_hd>=5;      
  forall(i in Phases)  
    ct6:
      fr[i]=ceil(dr[i]/hw_wd[i]); 
    
    ct7:
      fr_hd=ceil(sp_s/hw_hd);              
 };
 
 execute
 {
   writeln("fr[Phases]"=fr[Phases]);
   writeln("hw_wd[Phases]"=hw_wd[Phases]);
   writeln("fr_hd"=fr_hd);
   writeln("hw_hd"=hw_hd); 

 

  • AlexFleischer
    AlexFleischer
    1270 Posts

    Re: How to correct my model?

    ‏2013-07-26T06:28:53Z  

    Hi

     

    for the equality constraint, you should use == instead of =

     

    regards

  • W7AJ_Lingli_Wang
    W7AJ_Lingli_Wang
    11 Posts

    Re: How to correct my model?

    ‏2013-07-26T21:35:38Z  

    Hi

     

    for the equality constraint, you should use == instead of =

     

    regards

    Thanks to AlexFleischer but I have tried to use == instead of =, then more other errors will occur.

     I found that there are some conflicts among the objective function and constraints. Now, I can get the correct result by modifying  the model as follows. However, there are some errors in the statements about "writeln", so now i am learning the usage of "writeln".

     

    range Phases=1..6;
    int dr[Phases]=[135,180,120,180,90,20];
     
     
    int sp_s=725; 
    int a=20;//...; 
    int b=11;//...; 
     
     
    dvar int+ fr[Phases];
    dvar int+ hw_wd[Phases]; 
    dvar int+ fr_hd; 
    dvar int+ hw_hd; 
     
     
    minimize
     b*fr_hd+sum(i in Phases)
      a*fr[i]; 
     
    subject to {
     forall(i in Phases)
        ct1:
          hw_wd[i]*fr[i]>=dr[i]; 
      forall(i in Phases)
        ct2:
          fr_hd*hw_hd>=sp_s;  
      forall(i in Phases:i%2==1)
        ct3:  
          hw_wd[i]<=8; 
      forall(i in Phases:i%2==1)
        ct4:
          hw_wd[i]>=4;      
      forall(i in Phases:i%2==0)
        ct5:
           hw_wd[i]<=10; 
      forall(i in Phases:i%2==0)
        ct6:
           hw_wd[i]>=8;    
        ct7:
           hw_hd<=10;
        ct8:
           hw_hd>=5;      
      
         
                       
     };
     
     /*execute
     {
       //writeln("fr[Phases]"=fr[Phases]);
       //writeln("hw_wd[Phases]"=hw_wd[Phases]);
       writeln("fr_hd"=fr_hd);
       writeln("hw_hd"=hw_hd);  
    }*/
     
  • AlexFleischer
    AlexFleischer
    1270 Posts

    Re: How to correct my model?

    ‏2013-07-27T06:04:14Z  

    Thanks to AlexFleischer but I have tried to use == instead of =, then more other errors will occur.

     I found that there are some conflicts among the objective function and constraints. Now, I can get the correct result by modifying  the model as follows. However, there are some errors in the statements about "writeln", so now i am learning the usage of "writeln".

     

    range Phases=1..6;
    int dr[Phases]=[135,180,120,180,90,20];
     
     
    int sp_s=725; 
    int a=20;//...; 
    int b=11;//...; 
     
     
    dvar int+ fr[Phases];
    dvar int+ hw_wd[Phases]; 
    dvar int+ fr_hd; 
    dvar int+ hw_hd; 
     
     
    minimize
     b*fr_hd+sum(i in Phases)
      a*fr[i]; 
     
    subject to {
     forall(i in Phases)
        ct1:
          hw_wd[i]*fr[i]>=dr[i]; 
      forall(i in Phases)
        ct2:
          fr_hd*hw_hd>=sp_s;  
      forall(i in Phases:i%2==1)
        ct3:  
          hw_wd[i]<=8; 
      forall(i in Phases:i%2==1)
        ct4:
          hw_wd[i]>=4;      
      forall(i in Phases:i%2==0)
        ct5:
           hw_wd[i]<=10; 
      forall(i in Phases:i%2==0)
        ct6:
           hw_wd[i]>=8;    
        ct7:
           hw_hd<=10;
        ct8:
           hw_hd>=5;      
      
         
                       
     };
     
     /*execute
     {
       //writeln("fr[Phases]"=fr[Phases]);
       //writeln("hw_wd[Phases]"=hw_wd[Phases]);
       writeln("fr_hd"=fr_hd);
       writeln("hw_hd"=hw_hd);  
    }*/
     

    Hi

     

    instead of

    writeln("fr[Phases]"=fr[Phases]);

    you should write

    writeln("fr[Phases]=",fr[Phases]);

    regards

  • W7AJ_Lingli_Wang
    W7AJ_Lingli_Wang
    11 Posts

    Re: How to correct my model?

    ‏2013-07-27T22:19:30Z  

    Hi

     

    instead of

    writeln("fr[Phases]"=fr[Phases]);

    you should write

    writeln("fr[Phases]=",fr[Phases]);

    regards

    Thank you very much AlexFleischer. I have modify the error as your suggestion.