ATTENTION

This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices.


flexsim.com

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 08-10-2010
shafizad shafizad is offline
ProcSim Consulting
 
Join Date: Jul 2010
Location: Switzerland
Posts: 75
Downloads: 18
Uploads: 0
Thanks: 90
Thanked 2 Times in 2 Posts
Rep Power: 126
shafizad is on a distinguished road
Default Batch Behavior Q.

Hi,
I would like to know why in this simple model, on the second day the batch is not released when it is complete?
Generally, my purpose is
Wanted
I want to have control over how many times (say counter=2) my batch in the queue is released in one working day(say 6-16).if at the end of working day(16 p.m.), the batch is not complete, simply release it.

Model
A source, queue and sink is placed (pls, c.f. attachment).
Global Variable: a Global Variable is defined (namely "counter"). the counter is responsible for counting how many times the batch is complete. here I want a maximum of two batches to be released for a day.

Time table: A time table for queue is defined that Ondown, it clears the contents of the queue and adds one to the counter and Onresume it puts counter=0 and openinput of queue.

VISUAL TOOL: Operational time is shown as Working day and OFF is schedule down.

Queue: On the Endcollection,I have increased counter and if(counter ==2) closeinput.
On the entry,the code is if(counter ==2) closeinput.
__________________________________________________ _______
It doesn't do what I like on the second day and afterwards. the first day is alright. the second day, it reaches the batch size and doesn't release the batch (at about 2 Day 15hr)?? (what is it waiting for?).

This would be more strange if you choose "Flush Contents between batches".
thanks.
Attached Files
File Type: zip bathcomplex.zip (32.0 KB, 227 views)
  #2  
Old 08-10-2010
Sebastian Hemmann's Avatar
Sebastian Hemmann Sebastian Hemmann is offline
Flexsim User
 
Join Date: Sep 2009
Location: Braunschweig (Germany)
Posts: 439
Downloads: 52
Uploads: 0
Thanks: 472
Thanked 217 Times in 154 Posts
Rep Power: 319
Sebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to behold
Default

Hi,

just had a short look at your modell. Purely couldn´t spend to much to it. But what I found, that on day 2 you closed the input of the queue and never open it again. So probably you can set it in the timetable or any trigger to open the input of queue again. This will make it an little easier to see what you want.

Greetings
__________________
Hemmi
The Following User Says Thank You to Sebastian Hemmann For This Useful Post:
shafizad (08-10-2010)
  #3  
Old 08-10-2010
shafizad shafizad is offline
ProcSim Consulting
 
Join Date: Jul 2010
Location: Switzerland
Posts: 75
Downloads: 18
Uploads: 0
Thanks: 90
Thanked 2 Times in 2 Posts
Rep Power: 126
shafizad is on a distinguished road
Default

Quote:
Originally Posted by Sebastian Hemmann View Post
Hi,

just had a short look at your modell. Purely couldn´t spend to much to it. But what I found, that on day 2 you closed the input of the queue and never open it again. So probably you can set it in the timetable or any trigger to open the input of queue again. This will make it an little easier to see what you want.

Greetings
you might be right, but it doesn't change the status of it having a complete batch available and not releasing it?
  #4  
Old 08-10-2010
Sebastian Hemmann's Avatar
Sebastian Hemmann Sebastian Hemmann is offline
Flexsim User
 
Join Date: Sep 2009
Location: Braunschweig (Germany)
Posts: 439
Downloads: 52
Uploads: 0
Thanks: 472
Thanked 217 Times in 154 Posts
Rep Power: 319
Sebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to behold
Default

So I´m not sure at all. Only hint I can give you is, that "stopobject" normaly turns off the object at all. Most information the object gets while being in this state, get lost. That is why sometimes strange things happen, after using this command. In your model most logic works directly in the border to this function.
I tried a little, but didn´t find a working solution till now. For this I have to know more about what really should happen. And I will need more time, what is the bigger problem actually.
Probably it is possible to find a solution in which only the ports are opened/ closed by sended messages, even of timetable.
The batch process should work the same way. Only waits until the content reachs a level, opens output and afterwards closing it again. So you can turn this of an build a little level filling in triggers of queue. Flush contents realises, that the queue has to get empty, until the input port releases new items. This you will not need in your example anyway. Because all items leave queue at the same time.
__________________
Hemmi
The Following 2 Users Say Thank You to Sebastian Hemmann For This Useful Post:
Tom David (08-11-2010)
  #5  
Old 08-11-2010
Tom David's Avatar
Tom David Tom David is offline
Flexsim User
 
Join Date: Aug 2007
Location: Schwaebisch Gmuend, Germany
Posts: 430
Downloads: 157
Uploads: 47
Thanks: 486
Thanked 450 Times in 233 Posts
Rep Power: 520
Tom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant future
Default

For me this sound like the issues which occur if Queue are used and a number of items arrive at the same time in the Queue fire several events/triggers. Flexsim takes a number of items and fires the events (kind of batch processing) which can end in strange behavior. I remember several threads about this subject in this forum (Queue, Batch, Source – Queue combination, Control input/output at a Queue, etc.).

Anyway, I had a look into the model.
To be honest, I am not sure if I fully understand what you are trying to do, even if you explain it.
I understand that you want to control the number of batches of the queue for a working day, let’s say only two per day should be released. If at the end of the day the batch is not complete just release all items in the Queue.

In your model I see that at the end of the day you clear the contents of the Queue. In other words you destroy the items and do not release them. Check the input of the Sink, which is 30 (one batch).
So if you want to release the items you need some code here and I would think a loop and releaseitem() would do the job.

Seeing that you use clearcontents(), in my eyes it is possible, that because you destroy the items something goes wrong inside the Queue functionality. Are the statistics updated correct for the Queue in this case? I did not check it in deep, but I could imagine that here is the problem (e.g. with the batch). I had a look into the tree and I see that the Queue is empty, but the variable “currentbatchsize” is 9. Here is for sure a problem.

The way I would probably try to solve the task would be to control the Queue by myself with delayed messages. Close the output of the Queue at the start (OnReset sends a delayed message to closeoutput()). OnEntry check how many items are in the Queue and if the batch size is reached, send a delayed message to openoutput(). Or another way could be to realeaseitem() 30 times, where I would test how the downstream objects behave (maximum content, etc.). OnExit after 30 items left, I would send a delayed message to closeoutput() again. The control of the output might be not necessary if the releaseitem() is used, because the output will always be closed.
If you use a time table and use stop and resume object you should check your control of the output, because I guess internal the commands open and close input/output.
At the end of the day (time table) you could just release all items in the Queue or also need to control the output depending which construct you use (releaseitem() or control output).
What I am trying to prevent is using the batch functionality on the Queue as you can see and make an own control.

I just wrote this out of my head so I did not do any testing. But I hope that this will give you some hints, what you could try to solve the task. If this will not solve the problem, I hope I will find some time to build a model for it, but I do not like to promise it.

As you can see I agree with Sebastian which is on the "same" track as I am. So controling the Queue and not using the batch functionality might be a step in the right direction.
__________________
tom the (A)tom: "We have solved our problems ... now we have to fight the solutions."
The Following 3 Users Say Thank You to Tom David For This Useful Post:
shafizad (08-11-2010)
  #6  
Old 08-11-2010
shafizad shafizad is offline
ProcSim Consulting
 
Join Date: Jul 2010
Location: Switzerland
Posts: 75
Downloads: 18
Uploads: 0
Thanks: 90
Thanked 2 Times in 2 Posts
Rep Power: 126
shafizad is on a distinguished road
Default

Quote:
Originally Posted by Sebastian Hemmann View Post
So I´m not sure at all. Only hint I can give you is, that "stopobject" normaly turns off the object at all. Most information the object gets while being in this state, get lost. That is why sometimes strange things happen, after using this command. In your model most logic works directly in the border to this function.
I tried a little, but didn´t find a working solution till now. For this I have to know more about what really should happen. And I will need more time, what is the bigger problem actually.
Probably it is possible to find a solution in which only the ports are opened/ closed by sended messages, even of timetable.
The batch process should work the same way. Only waits until the content reachs a level, opens output and afterwards closing it again. So you can turn this of an build a little level filling in triggers of queue. Flush contents realises, that the queue has to get empty, until the input port releases new items. This you will not need in your example anyway. Because all items leave queue at the same time.
I would say that what I would like the triggers of Ondown and Onresume to do is just to open and close input port of queue. that's why I tried to use
Ondown: closeinput + clearcontents and Onresume: counter=0 and openinput.

So the problem with Stopobject and Resumeobject do not interfere.It doesn't work unfortunately.

I am not sure if the problem comes from clearcontents because I have tried other commands like while(objectexists(last(current))) {moveobject and destroyobject ...} that work as good as clearcontents. however, the same old problem exists.
  #7  
Old 08-11-2010
shafizad shafizad is offline
ProcSim Consulting
 
Join Date: Jul 2010
Location: Switzerland
Posts: 75
Downloads: 18
Uploads: 0
Thanks: 90
Thanked 2 Times in 2 Posts
Rep Power: 126
shafizad is on a distinguished road
Default

Quote:
Originally Posted by Tom David View Post
For me this sound like the issues which occur if Queue are used and a number of items arrive at the same time in the Queue fire several events/triggers. Flexsim takes a number of items and fires the events (kind of batch processing) which can end in strange behavior. I remember several threads about this subject in this forum (Queue, Batch, Source – Queue combination, Control input/output at a Queue, etc.).

Anyway, I had a look into the model.
To be honest, I am not sure if I fully understand what you are trying to do, even if you explain it.
I understand that you want to control the number of batches of the queue for a working day, let’s say only two per day should be released. If at the end of the day the batch is not complete just release all items in the Queue.

In your model I see that at the end of the day you clear the contents of the Queue. In other words you destroy the items and do not release them. Check the input of the Sink, which is 30 (one batch).
So if you want to release the items you need some code here and I would think a loop and releaseitem() would do the job.

Seeing that you use clearcontents(), in my eyes it is possible, that because you destroy the items something goes wrong inside the Queue functionality. Are the statistics updated correct for the Queue in this case? I did not check it in deep, but I could imagine that here is the problem (e.g. with the batch). I had a look into the tree and I see that the Queue is empty, but the variable “currentbatchsize” is 9. Here is for sure a problem.

The way I would probably try to solve the task would be to control the Queue by myself with delayed messages. Close the output of the Queue at the start (OnReset sends a delayed message to closeoutput()). OnEntry check how many items are in the Queue and if the batch size is reached, send a delayed message to openoutput(). Or another way could be to realeaseitem() 30 times, where I would test how the downstream objects behave (maximum content, etc.). OnExit after 30 items left, I would send a delayed message to closeoutput() again. The control of the output might be not necessary if the releaseitem() is used, because the output will always be closed.
If you use a time table and use stop and resume object you should check your control of the output, because I guess internal the commands open and close input/output.
At the end of the day (time table) you could just release all items in the Queue or also need to control the output depending which construct you use (releaseitem() or control output).
What I am trying to prevent is using the batch functionality on the Queue as you can see and make an own control.

I just wrote this out of my head so I did not do any testing. But I hope that this will give you some hints, what you could try to solve the task. If this will not solve the problem, I hope I will find some time to build a model for it, but I do not like to promise it.

As you can see I agree with Sebastian which is on the "same" track as I am. So controling the Queue and not using the batch functionality might be a step in the right direction.
Thanks a lot.
you're absolutely right in currentbatchsize is not zero. so I simply added this line to the Ondown trigger of timetable: setvarnum(downobject,"currentbatchsize", 0);
and it works as I like.

Before I thought if the content in a queue is set to zero, it has the same meaning as currentbatchsize. now, I find out that this is not the case. clearcontents puts CurContent at zero but doesn't change the currentbatchsize.
  #8  
Old 08-11-2010
shafizad shafizad is offline
ProcSim Consulting
 
Join Date: Jul 2010
Location: Switzerland
Posts: 75
Downloads: 18
Uploads: 0
Thanks: 90
Thanked 2 Times in 2 Posts
Rep Power: 126
shafizad is on a distinguished road
Default The final working model

just for interested.
I want to control the number of batches of the queue for a working day, let’s say only two per day should be released. If at the end of the day the batch is not complete just release all items in the Queue.

thanks to the contributers such as Tom and Sebastian.
  #9  
Old 08-11-2010
shafizad shafizad is offline
ProcSim Consulting
 
Join Date: Jul 2010
Location: Switzerland
Posts: 75
Downloads: 18
Uploads: 0
Thanks: 90
Thanked 2 Times in 2 Posts
Rep Power: 126
shafizad is on a distinguished road
Smile I forgot to attach the working final model

Description:
the model tries to control the number of batches of the queue for a working day, let’s say only two per day should be released. If at the end of the day the batch is not complete just release all items in the Queue.

The comments in the code.
model
http://rapidshare.com/files/412318020/twobatches.fsm

(MD5: 0EC1D60744543C8CAE113D337673AFAE)

______________
there is sth wrong with zip attachment.
The Following User Says Thank You to shafizad For This Useful Post:
Tom David (08-11-2010)
  #10  
Old 08-11-2010
Sebastian Hemmann's Avatar
Sebastian Hemmann Sebastian Hemmann is offline
Flexsim User
 
Join Date: Sep 2009
Location: Braunschweig (Germany)
Posts: 439
Downloads: 52
Uploads: 0
Thanks: 472
Thanked 217 Times in 154 Posts
Rep Power: 319
Sebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to behold
Default

@ shafizad

If at the end of the day, a proper third batch isn´t complete, what should happen then? Or isn´t this relevant because of never possible?
In my opinion the only reason for controlling batches would be to reduce them and see what will happen. But if the number of items stay constant, the batchsize has to be changed.
__________________
Hemmi
  #11  
Old 08-16-2010
shafizad shafizad is offline
ProcSim Consulting
 
Join Date: Jul 2010
Location: Switzerland
Posts: 75
Downloads: 18
Uploads: 0
Thanks: 90
Thanked 2 Times in 2 Posts
Rep Power: 126
shafizad is on a distinguished road
Default pls, could u re-state ur question

Could u reformulate ur question? I am not sure if I understand what u mean.

There are two cases that could happen.
1- two batches are completely released in the working day ( before the day ends) 2- one batch is released and the next one is in progress.

the (1) problem is addressed by adding the counter at OnEndcollection trigger.
the (2) problem is addressed by Timetable triggers.
  #12  
Old 12-13-2010
Sebastian Hemmann's Avatar
Sebastian Hemmann Sebastian Hemmann is offline
Flexsim User
 
Join Date: Sep 2009
Location: Braunschweig (Germany)
Posts: 439
Downloads: 52
Uploads: 0
Thanks: 472
Thanked 217 Times in 154 Posts
Rep Power: 319
Sebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to behold
Default

Sorry for this long time between my replies.
My question only had been:
When your 2.batch is released but there are still arriving items, what should happen with them when day is over?
1. Sending a "smaller" 3. batch the standard way?
2. Destroy without counting?
3. Sending the "smaller" 3. batch to another way?
4. This can´t happen.
Or anything else, not in my mind?
__________________
Hemmi

Tags
onendcollection, queue batch, timetable


Thread Thread Starter Forum Replies Last Post
Batch connection changes KelvinHo Q&A 2 02-05-2010 03:01 PM
TaskExcuter BreakTime Behavior Sung Kim Q&A 6 10-09-2009 11:22 AM
Batch Processor? Anthony Timmiss Q&A 7 08-19-2009 10:11 AM
Batch production (Batch size for processor) Patrick Cap Q&A 12 03-27-2009 12:14 AM
strange behavior of ts prioity? zhang xin Q&A 7 03-23-2009 02:32 AM


All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.