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
|
|||
|
|||
Percent choice for GlobalTaskSequence
Hello! I am having some trouble with my model, and would love any advice I can get.
In my model, there is one source, and ultimately three destinations for the material to be moved to. The transporter must perform a number of activities along the way to each destination. There are fixed percentages for which items will be sent to which destination, and three transporters to perform the work. In attempt to model this, I wrote three seperate globaltasksequences (one for each destination). I then tried to incorporate the dispatch of the task sequence into a percentage script. (Script shown below). The problem I keep having is that all three transporters are moving and behaving together as one unit, instead of as three seperate units. I have attached a demo of the model to work with (and see whats happening). The script I am executing: treenode item = parnode(1); treenode current = ownerobject(c); int port = parval(2); // establish random percent conditions double percent1 = 80; // Queue 3 at 80% double percent2 = 95; // Queue 4 at 15% (sum) double percent3 = 100; // Queue 5 at 5% (sum) double randomnum = uniform(0,100,1); //define all percent case task sequences string tsname1 = /**/"Q3_Delivery"/**/; string tsname2 = /**/"Q4_Delivery"/**/; string tsname3 = /**/"Q5_Delivery"/**/; treenode dispatcher = /**/Dispatcher15/**/; /** \nDynamic Parameter 1: */ treenode dp1 = /**/item/**/; /** \nDynamic Parameter 2: */ treenode dp2 = /**/current/**/; /** \nDynamic Parameter 3: */ treenode dp3 = /**/outobject(current, port)/**/; /** \nDynamic Parameter 4: */ treenode dp4 = /**/NULL/**/; /** \nDynamic Parameter 5: */ treenode dp5 = /**/NULL/**/; treenode ts1 = createglobaltasksequence(tsname1, dispatcher, dp1,dp2,dp3,dp4,dp5); treenode ts2 = createglobaltasksequence(tsname2, dispatcher, dp1,dp2,dp3,dp4,dp5); treenode ts3 = createglobaltasksequence(tsname3, dispatcher, dp1,dp2,dp3,dp4,dp5); //globaltasksequence case pick by percentage if( randomnum<=percent1) dispatchtasksequence(ts1); else if( randomnum<=percent2) dispatchtasksequence(ts2); else if( randomnum<=percent3) dispatchtasksequence(ts3); return 0; Thanks for any help! |
#2
|
||||
|
||||
Hi. Peter. Your model display three transporters to move indenpendently.
I tested your model.
What's the meaning of your saying 'like one unit'? Three transporters is moving to three destinations indenpently each other. I attach the snap shot. I did not touch any part your model in V6.0. Please check it again. |
#3
|
|||
|
|||
They all three start moving at the same time, and only one of them will actually have loaded the item (other two just move on without it).
After posting I saw the same thing you saw, and determined that it is because the supply queue is dispatching all three task sequences at the same time, instead of by the percent distribution I was trying to do. I think its because there is nothing telling the script to stop executing after the first "if", and so for any number under 80 it will execute all three task sequences. I fixed the problem by having the supply queue distribute to three individual queues at the percentages I wanted, and then had each of those supply via a dedicated global task sequence. This seems to have solved the problem, but I would still be curious to see if there was a way to handle this all with a single script. Something like what I was trying to do, but done properly |
#4
|
||||
|
||||
Without looking at your model, have you thought about a CALLSUBTASK? Then every tasksequence can make individual decisions based on the status of the objects when your reach a certain point in your tasksequence.
|
#5
|
||||
|
||||
Hello Peter,
everything is fine with your code. If you want to execute only one tasksequence you have to dispatch only one tasksequence. Everytime a Flowitem enters the queue and it can be released a tasksequence is dispatched. To release only one tasksequence close the output of the Queue when you dispatch a tasksequence. The next item entering the queue stays there as long as the output port is closed. Jörg |