Topic
  • 9 replies
  • Latest Post - ‏2014-04-15T09:22:46Z by rdumeur
khadeejah
khadeejah
7 Posts

Pinned topic scheduling items on sequence of stages for multi periods

‏2014-01-24T14:14:34Z |

I'm working with IBM ILOG OPTIMIZATION STUDIO v12.5.1, my problem is that I want to display the output result in an organized way like tuples but I know tuples are not valid for a multidimensional array and my decision variables are a three dimensional array.  I've two decision variables X[I] [j][k] and Y [I] [j][k], my model is a linear model.

and I kept having an error "unexpected end" also I tried doing nested loops and tuple triplets but it didn't work too.

 

I've been stucked with this for couple of weeks!!!!  ANY HELP???

 

Updated on 2014-01-24T14:17:06Z at 2014-01-24T14:17:06Z by khadeejah
  • ol
    ol
    51 Posts

    Re: scheduling items on sequence of stages for multi periods

    ‏2014-01-28T11:26:07Z  

    Hello,

    you can try something like this:

    execute DISPLAY {

    for (var i in Months) {

    writeln(" Month ", i, " ");

    for (var p in Products) {

    for (var c in Customers)

    write(Quantity[i][p][c], " / ");

    }

    }

    }

    Regards,

    Olivier

  • khadeejah
    khadeejah
    7 Posts

    Re: scheduling items on sequence of stages for multi periods

    ‏2014-01-28T13:23:12Z  
    • ol
    • ‏2014-01-28T11:26:07Z

    Hello,

    you can try something like this:

    execute DISPLAY {

    for (var i in Months) {

    writeln(" Month ", i, " ");

    for (var p in Products) {

    for (var c in Customers)

    write(Quantity[i][p][c], " / ");

    }

    }

    }

    Regards,

    Olivier

    Thanks Olivier for your reply, I've tried it and I had this error: syntax error, unexpected execute. Do you mind if you'd a look on the code attached.

    I appreciate your help.

    Attachments

  • ol
    ol
    51 Posts

    Re: scheduling items on sequence of stages for multi periods

    ‏2014-01-28T14:54:53Z  

    Thanks Olivier for your reply, I've tried it and I had this error: syntax error, unexpected execute. Do you mind if you'd a look on the code attached.

    I appreciate your help.

    first, do not try to invent your own C-like syntax as in   

    for (int t=-;t<periods;t++)

    Then you need a "}" to close the "{".

     

    It should be:


    execute DISPLAY {  
     for (var s in stages)
      for (var j in products)
         for (var t in periods)
           writeln(X[s][j][t]) ;
      }

  • khadeejah
    khadeejah
    7 Posts

    Re: scheduling items on sequence of stages for multi periods

    ‏2014-01-29T12:19:54Z  
    • ol
    • ‏2014-01-28T14:54:53Z

    first, do not try to invent your own C-like syntax as in   

    for (int t=-;t<periods;t++)

    Then you need a "}" to close the "{".

     

    It should be:


    execute DISPLAY {  
     for (var s in stages)
      for (var j in products)
         for (var t in periods)
           writeln(X[s][j][t]) ;
      }

    I tried it & again!  "syntax error, unexpected execute" !

     

  • ol
    ol
    51 Posts

    Re: scheduling items on sequence of stages for multi periods

    ‏2014-02-03T15:12:35Z  

    I tried it & again!  "syntax error, unexpected execute" !

     

    Hello,

    You need to close every "{" with a "}" (2 are missing).

    Regards

  • khadeejah
    khadeejah
    7 Posts

    Re: scheduling items on sequence of stages for multi periods

    ‏2014-02-04T23:32:37Z  
    • ol
    • ‏2014-02-03T15:12:35Z

    Hello,

    You need to close every "{" with a "}" (2 are missing).

    Regards

    execute DISPLAY{

    for var (s in stages)

    for var (j in products)

    for var (t in periods)

    writeln ("X[",s,"][",j,"][",t,"]=",X[s][j][t])

    writeln ("I[",s,"][",j,"][",t,"]=",I[s][j][t])}

     

    p.s: s,j,t are of int type

    I'd an error :processing failed, unexpected end of file found in scripting!

     

     

  • rdumeur
    rdumeur
    36 Posts

    Re: scheduling items on sequence of stages for multi periods

    ‏2014-02-19T14:18:01Z  

    execute DISPLAY{

    for var (s in stages)

    for var (j in products)

    for var (t in periods)

    writeln ("X[",s,"][",j,"][",t,"]=",X[s][j][t])

    writeln ("I[",s,"][",j,"][",t,"]=",I[s][j][t])}

     

    p.s: s,j,t are of int type

    I'd an error :processing failed, unexpected end of file found in scripting!

     

     

    Hi, here is the model with fixed unbalanced braces and without c-like syntax.

    {int} products = ...;
    
    {int} stages = ...;
    
    {int} parts = ...;
    
    int   Nbperiods = ...;
    range periods   = 1..Nbperiods;
    
    float dsj     [stages][products]= ...;
    float units   [periods][products]= ...;  
    float msj     [stages][products]= ...;
    float Ms      [stages]= ...;
    float Qs      [stages]= ...;
    float alpha   [stages][products]= ...;
    float Ss      [stages]= ...;
    float as      [stages]= ...;
    float delta   [products][parts]= ...;
    int   Beta  = ...;
    float vj      [products]= ...;
    int   Wst   = ...;
    
    
    dvar int+ X [stages][products][periods];
    dvar int+ I [stages][products][periods]; // Q: periods should be written as [ 0..Nbperiods]
    
    
    minimize 
            sum (j in products, s in stages, t in periods)(msj [s][j]* X [s][j][t]+
                                                 Ss[s]*X[s][j][t]*(dsj[s][j]/Beta)+
                                                 (Ms[s]*X[s][j][t]*dsj[s][j]/Qs[s])+
                                                  alpha[s][j]*I[s][j][t]);
                                                 subject to { 
     
    ctInventory: 
    
      forall( s in stages, j in products, t in periods,p in parts)
    {
      if(s==1)
      {
        sum (p in parts) 
        I[s][j][t] == I[s][j][t-1] + X[s][j][t] -( delta[j][p] *( X[s+1][j][t]));
    }
     else if ((s+1)==6){
    
     I[s][j][t] == I[s][j][t-1]+X[s][j][t]- units [j][t];
    } else{
      I[s][j][t] == I[s][j][t-1] + X[s][j][t] - X[s+1][j][t];}
    } 
    ctCapacity:
      forall (s in stages , t in periods)
          
      sum( j in products ) 
      dsj[s][j] * X[s][j][t] <= as[s];
            
    ctWarehouse:
      forall( s in stages, t in periods )
      {sum( j in products)
      vj[j]*I[s][j][t] <= Wst;}
      
    }
     
    execute DISPLAY {  
     for (var s in stages)
      for (var j in products)
         for (var t in periods)
           writeln(X[s][j][t]) ;
      } 
     
    

    I hope this helps.

    Cheers,

  • khadeejah
    khadeejah
    7 Posts

    Re: scheduling items on sequence of stages for multi periods

    ‏2014-02-22T05:10:50Z  
    • rdumeur
    • ‏2014-02-19T14:18:01Z

    Hi, here is the model with fixed unbalanced braces and without c-like syntax.

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">{int} products = ...; {int} stages = ...; {int} parts = ...; int Nbperiods = ...; range periods = 1..Nbperiods; float dsj [stages][products]= ...; float units [periods][products]= ...; float msj [stages][products]= ...; float Ms [stages]= ...; float Qs [stages]= ...; float alpha [stages][products]= ...; float Ss [stages]= ...; float as [stages]= ...; float delta [products][parts]= ...; int Beta = ...; float vj [products]= ...; int Wst = ...; dvar int+ X [stages][products][periods]; dvar int+ I [stages][products][periods]; // Q: periods should be written as [ 0..Nbperiods] minimize sum (j in products, s in stages, t in periods)(msj [s][j]* X [s][j][t]+ Ss[s]*X[s][j][t]*(dsj[s][j]/Beta)+ (Ms[s]*X[s][j][t]*dsj[s][j]/Qs[s])+ alpha[s][j]*I[s][j][t]); subject to { ctInventory: forall( s in stages, j in products, t in periods,p in parts) { if(s==1) { sum (p in parts) I[s][j][t] == I[s][j][t-1] + X[s][j][t] -( delta[j][p] *( X[s+1][j][t])); } else if ((s+1)==6){ I[s][j][t] == I[s][j][t-1]+X[s][j][t]- units [j][t]; } else{ I[s][j][t] == I[s][j][t-1] + X[s][j][t] - X[s+1][j][t];} } ctCapacity: forall (s in stages , t in periods) sum( j in products ) dsj[s][j] * X[s][j][t] <= as[s]; ctWarehouse: forall( s in stages, t in periods ) {sum( j in products) vj[j]*I[s][j][t] <= Wst;} } execute DISPLAY { for (var s in stages) for (var j in products) for (var t in periods) writeln(X[s][j][t]) ; } </pre>

    I hope this helps.

    Cheers,

    Hi rdumeur,

                      thanks for your clarifications, it worked. but I'd another error concerning defining I initial!, which is used for the first constraint and in my case I initial is at s=1, t=1, and all js. and since its a 3D array, I don't know how to insert its input data in the data file nor write its command in the mod file!, do you have any idea?

    thanks a lot,

  • rdumeur
    rdumeur
    36 Posts

    Re: scheduling items on sequence of stages for multi periods

    ‏2014-04-15T09:22:46Z  

    Hi rdumeur,

                      thanks for your clarifications, it worked. but I'd another error concerning defining I initial!, which is used for the first constraint and in my case I initial is at s=1, t=1, and all js. and since its a 3D array, I don't know how to insert its input data in the data file nor write its command in the mod file!, do you have any idea?

    thanks a lot,

    Hi Khadeeja,

    You probably noticed that your question was answered here :

    https://www.ibm.com/developerworks/community/forums/html/topic?id=026f11da-3765-4ad3-b44d-6b2e64bf4380&ps=25