ATTENTIONThis 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 |
#1
|
||||
|
||||
Pulling from a Queue vs Sorting the Queue
All,
This model was created to demonstrate to another group how to use pull logic to pull the lowest itemtype value from a queue and how that same task can be done by sorting the queue on entry. The top group of objects uses pull logic to pull the flowitem in the queue with the lowest itemtype value (darkest color) first. The bottom group uses the on entry trigger of the queue to sort the flowitems as they enter so that the items with the lowest itemtype values are on the bottom (first). The pull requirement code is fired for each item in the up stream object until the code returns TRUE. When searching for a low, high, or other value it is very easy to write inefficient code. The pull logic in the top processor was written to be efficient. It does this by only searching for the item with the lowest itemtype value during the execution for the first item. It then saves the rank of the lowest value item in a label on the processor. The remaining executions of the pull requirement code will only check to see if the rank of the item it is checking for is equal to that label value. This way you are not executing a search algoithm for each flowitem. This seems to be a very common problem that people run into. The purpose of this model was to show two of the many different ways that this problem can be solved and to show how to write more efficient code in the pull requirement field. Let me know if there are any questions or comments, Brandon
__________________
thats not normal. Last edited by Brandon Peterson; 06-17-2008 at 12:24 PM. |
The Following 4 Users Say Thank You to Brandon Peterson For This Useful Post: | ||
Tom David (06-17-2008) |
#2
|
||||
|
||||
Brandon this is an excellent example, and you always do such a nice job of organizing and documenting your example models.
There's two excellent points I think you make with this example:
|
The Following 3 Users Say Thank You to Cliff King For This Useful Post: | ||
Tom David (06-17-2008) |
#3
|
||||
|
||||
Cliff,
Here is a model that answers your questions below. This model has three sources and queues that feed one processor. The processor's job is to pull the item with the lowest item type. If there is more than one item with that itemtype then it is to take the one what has been waiting the longest. The processor has some custom code on the Pull From Port and Pull Requirement fields. Please note that the Pull requirement could have been left at the default "Any Port" and the code to decide the port could have been done in the Pull Requirement field. While this model isn't exactly like either of Cliff's examples it can be easily modified to do either. If someone would like to see either of them exactly or would like to see how all of the code in this model could have been done on the Pull Requirement field please let me know. As always the code is commented like crazy and I appreciate any of your questions or comments, Brandon P.S. - This model was not included in the Zip file that had all of the other XT example models in another post.
__________________
thats not normal. |
The Following 2 Users Say Thank You to Brandon Peterson For This Useful Post: | ||
zhang xin (12-26-2009) |
Thread | Thread Starter | Forum | Replies | Last Post |
a question on queue | KelvinHo | Q&A | 15 | 11-09-2011 07:16 AM |
Queue Sorting | Jeff Nordgren | Q&A | 12 | 05-22-2008 03:21 PM |
Queue (standard, LIFO, FIFO) | Tom David | Q&A | 2 | 05-15-2008 10:30 AM |
How to get interval average,max,etc of a queue content ? | qin tian | Q&A | 5 | 02-14-2008 10:11 PM |
Queue stacking | Paul Dowling | Q&A | 2 | 11-27-2007 11:57 PM |