Lateral Shipments

All topics specific to modeling questions in Enterprise Dynamics
Post Reply
giannis
Posts: 10
Joined: Wednesday 04 May, 2011 - 11:53

Lateral Shipments

Post by giannis »

Hellow I wanted to model lateral shipment for a Supply chain model
I've written a script but that works for one atom but I cannot subtract
as many atoms as i want from the queue with a surplus the sciprt is the following:


Code: Select all

do(
 
 Setinvent(1,1,invent(1,1)-1),
 
 if(Content(c)=0,  
   do(
 
   var([maxN],vbValue,0),
   var([maxP],vbValue,0),
   var([icounter],vbValue,0),
   var([icounter2],vbValue,0),
 
   {Find maximum surplus queue}
   set(maxN,Max(invent(1,1),invent(2,1),invent(3,1),invent(4,1))),
   For(icounter:=1,icounter<5,Inc(icounter),if(maxN=invent(icounter,1),maxP:=icounter,0)),

     {If enough inventory sutract 15 atoms}
     
     if(maxN>20,
     For(icounter2:=1,icounter2<16,Inc(icounter2),
           do(
         SetLabel([Destination],1,First(AtomByName(invent(maxP,2),Model)))
         MoveRequest(First(AtomByName(invent(maxP,2),Model)),2),
         Trace([one more]), 
                  )

         )
        )
 
     )
   )
 )

The problems is that even thought it enters the For loup (The tracers is printed 15 times) the move request
is executed only once.

I've tried to use repeat but it only executes one time

Code: Select all

do(
 
 Setinvent(1,1,invent(1,1)-1),
 
 if(Content(c)=0,  
   do(
 
   var([maxN],vbValue,0),
   var([maxP],vbValue,0),
   var([icounter],vbValue,0),
   var([icounter2],vbValue,0),
 
   {Find maximum surplus queue}
   set(maxN,Max(invent(1,1),invent(2,1),invent(3,1),invent(4,1))),
   For(icounter:=1,icounter<5,Inc(icounter),if(maxN=invent(icounter,1),maxP:=icounter,0)),

     {If enough inventory sutract 15 atoms}
     
     if(maxN>20,
     Repeat(
       do(
          SetLabel([Destination],1,First(AtomByName(invent(maxP,2),Model)))
         MoveRequest(First(AtomByName(invent(maxP,2),Model)),2),
         Trace([one more]), 
                  ),15


         )
        )
 
     )
   )
 )
Thank you in advance
Ioannis Goniadis
JeroenSteenbakkers
Posts: 16
Joined: Tuesday 11 January, 2011 - 09:34

Re: Lateral Shipments

Post by JeroenSteenbakkers »

hello giannis,

i understand you situation. there are some reasons that is not working properly.

its correct that you are doing 15 move requests. but you are doing this for the same atom every time. namely the first atom in the Queue (with the maximum stock). all the moverequests will be handled after this code is execute so you should perform the 15 move request on 15 product (in the queue). you can use "rank" for instance.

if you use "moveatom" this will work immediately, and the current code is sufficient.

the reason that the repeat loop is not working, is because the first parameter of the repeat funtions is the amount of loops to perform and not the code.

good luck...
giannis
Posts: 10
Joined: Wednesday 04 May, 2011 - 11:53

Re: Lateral Shipments

Post by giannis »

Thank you a lot for the help
Ioannis Goniadis
Post Reply