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 01-13-2010
KelvinHo KelvinHo is offline
Flexsim User
 
Join Date: Jan 2008
Location: Hong Kong
Posts: 129
Downloads: 18
Uploads: 1
Thanks: 44
Thanked 23 Times in 7 Posts
Rep Power: 171
KelvinHo will become famous soon enough
Default Mergesort problem

Hi all,

I have a problem to due with mergesort as shown in the attached sample model, thus seek for some help......

In the model, as it seems that the send requirement is evaluted realtime, so when queue 3 is full, a flowitem pass queue 3 and heading to queue 4, but before arrive queue 4, if queue 3 becomes available again, the flowitem will target to queue 3 again thus go to the end of the mergesort.

But I want the shpt to go to queue 4 even queue 3 becomes avaialable once the shpt passed the exit point of queue 3.


I typed below code in send requirement of the merge sort

/**custom code */

int destport = 1;

if (content(outobject(current, 1)) == 5)
{destport = 2;
if (content(outobject(current, 2)) == 5)
{destport = 3;
if (content(outobject(current, 3)) == 5)
{destport = 4;
}}}

return destport == port;


Thanks.
Kelvin
Attached Files
File Type: zip mergesort problem.zip (47.7 KB, 216 views)
  #2  
Old 01-13-2010
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 684
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default

Kelvin,

The send requirement is executed everytime a product is at an exit. So you are right when it then evaluates that it can go to 1 it will get that destination even if it is at 2.

Actually you did too much. If you leave the send requirement to standard (always send) and change the max capacity of the queues to 5, you will have your functionality
  #3  
Old 01-13-2010
KelvinHo KelvinHo is offline
Flexsim User
 
Join Date: Jan 2008
Location: Hong Kong
Posts: 129
Downloads: 18
Uploads: 1
Thanks: 44
Thanked 23 Times in 7 Posts
Rep Power: 171
KelvinHo will become famous soon enough
Default

Quote:
Originally Posted by Steven Hamoen View Post
Kelvin,

The send requirement is executed everytime a product is at an exit. So you are right when it then evaluates that it can go to 1 it will get that destination even if it is at 2.

Actually you did too much. If you leave the send requirement to standard (always send) and change the max capacity of the queues to 5, you will have your functionality
Thanks Steve,

I know use always send will work in this demo, but I just extracted the problem in my building model which not all exits would be used in the merge sort as each flowitem would hv it own possible exit
  #4  
Old 01-13-2010
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 684
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default

Ok I didn't understand that complety. Then some extra comments. The send requirement is executed for every product and for every exit. And it has to return either a true or false.

So you might try some code like this:

treenode current = ownerobject(c);
treenode item = parnode(1);
int port = parval(2);
/**By Itemtype: */
/**Send the item if its itemtype matches the port.*/

if(
( getitemtype(item) == port && content(outobject(current, 1)) < 5 ) ||
getitemtype(item) < port
)
{
return 1;
}
else
{
return 0;
}


This code sends the right item to the right port based on the itemtype and space in the queue. But if it has passed the destination port it will go to any port. Hope this helps.

Last edited by Steven Hamoen; 01-13-2010 at 07:37 AM.
  #5  
Old 01-14-2010
David Chan David Chan is offline
Flexsim Distributor
 
Join Date: Sep 2007
Posts: 326
Downloads: 74
Uploads: 0
Thanks: 217
Thanked 73 Times in 44 Posts
Rep Power: 218
David Chan has a spectacular aura aboutDavid Chan has a spectacular aura aboutDavid Chan has a spectacular aura about
Default

I am not sure this work. Instead of push from the upstream, you can pull.
__________________
Advent2 Labs
David
  #6  
Old 01-15-2010
KelvinHo KelvinHo is offline
Flexsim User
 
Join Date: Jan 2008
Location: Hong Kong
Posts: 129
Downloads: 18
Uploads: 1
Thanks: 44
Thanked 23 Times in 7 Posts
Rep Power: 171
KelvinHo will become famous soon enough
Default

It seems adding the condition

getitemtype(item) < port

in the if statement works.....


Thread Thread Starter Forum Replies Last Post
Problem with installation (new problem) David Chan Installation 2 03-13-2009 10:41 AM
Trouble with mergesort... Paul Dowling Q&A 6 02-23-2009 11:20 PM
Not overlapping when MergeSort Conveyor... syseo Q&A 0 10-26-2008 07:24 AM
MergeSort Spacing Rule For Recirculation Sung Kim Q&A 2 01-21-2008 09:26 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.