Hi guys, I'm still struggling with my model.
The model shoul move in drain all the entities that stayed in the buffer for 600 seconds or more. I tryed with
is i:integer; do variable1:=buffer.numMU; for i:= 1 to variable1 loop if eventcontroller.simTime-buffer.cont.entrytime >= 600 then buffer.cont.move(drain); end; print buffer.cont; next; self.methcall(30); end;
but it doesn't work well. I attach the model too.
Any help is much appreciated
Solved! Go to Solution.
A drain has a capacity of one. So you cannot move multiple parts at once onto the drain.
The following method waits until the drain is empty before moving the next part:
is i:integer; do variable1:=buffer.numMU; if buffer.cont /= void and eventcontroller.simTime-buffer.cont.entrytime >= 600 then for i:= 1 to variable1 loop waituntil Drain.empty prio 1; buffer.cont.move(drain); print buffer.cont; next; end; self.methcall(30); end;
For performance reason I moved the if condition out of the for loop.
thank for your answer.
Your seggestion about the drain capacity is great!
Actually the code you posted do not calculate the time for all the entities, but only for the first.
Anyway, based on your seggestion, I fixed it. Here is the code for future users reference:
is i:integer; do variable1:=buffer.numMU; if variable1 >0 then for i:= 1 to variable1 loop if eventcontroller.simTime-buffer.cont.entrytime >= 600 then waituntil Drain.empty prio 1; buffer.cont.move(drain); end; print buffer.cont; next; end; self.methcall(30); end;
Actually you don't need the drain at all.
You could simply delete the entity and avoid using waituntil.
depends on the statistics you need.
If you need the amount of parts, it would be easy to use a Variable object were you increase the sum by one each time you destroy a MU.
Sorry for the delay but my timezone does not help the matter.
As Ralf said you can create all your statistics using variables or tablefiles. If you use tablefiles is even easier to pass this informantion into charts.
But it will really be related to your needs. I may suggest you do a little more trial by error on your own so you get the gist of it.
More suggestions from my side, to add to your list of ideas.
1) You could consider to set a dwell time of 600 seconds for your buffer. Any MU that exits the buffer in a regular way has been there for 10 minutes. If the MUs are to be consumed before by some other process, you need to program it, though.
2) To prevent coding (condition checking) I would place an unlimited buffer in front of your Drain.
Thak you for yut answers.
I will try to reduce the number of suspending methods as you suggested. In addition I would like to understand is I can just increase the number of maximum suspended methods in the software preference; is it a good option?
first you should check the number of suspended methods (Debugger...). It is very bad, if you suspend the same method several times. This causes a chaotic behavior of your model.
You should only increase the number of suspended methods, if you have a big number of different methods or if you use the wait command in many methods.
freelance simulation specialist