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
|
|||
|
|||
flexsim engine shutdown
I have a model where I have a processor pulling from 7 different queues randomly. It all seems to work ok until I get an error message that says the FlexSim engine will shut down. I’ve uploaded my model so any help would be appreciated.
I guess I'm in position where I have an infinite sendmessage() situation. I guess I don't know a way around it though...
__________________
"A bird is an instrument working according to mathematical law, which is within the capacity of man to reproduce." -Leonardo da Vinci, 1502 Last edited by Gavin Douglas; 02-06-2013 at 03:36 PM. |
#2
|
|||
|
|||
Gavin,
What is happening is your processor is sending a message to itself in the else statement of its OnMessage trigger, but it isn't changing any data. This means that if it ever gets into the else statement where it sends the message it will always go to the else statement and you are caught in an infinite loop. As a side note, it is generally advisable to use senddelayedmessage() in 0 time instead of sendmessage(). Sendmessage() interrupts the code that is currently executing, whereas senddelayedmessage() will not be sent until that code has finished executing. |
The Following User Says Thank You to Cameron Pluim For This Useful Post: | ||
Jörg Vogel (02-13-2013) |
#3
|
|||
|
|||
Looking at the code below:
int aa= uniform (1,7,1); int b= content (inobject (current,aa)); if (b>0) openoutput (inobject (current,aa)); else sendmessage (current,current); if I do enter the else condition then I will be changing the value of aa which should keep me out of an infinite loop?? I'm trying to randomly pull from 7 queues but only if there is product available. And it does crash when there is product avail.
__________________
"A bird is an instrument working according to mathematical law, which is within the capacity of man to reproduce." -Leonardo da Vinci, 1502 |
#4
|
||||
|
||||
You´ve built an infinite loop when content of all conected objects is 0.
Quote:
But wouldn´t it be better to solve it with some logic in the inobjects?
__________________
Hemmi |
#5
|
|||
|
|||
I fall into an infinate loop before all of the object contents are 0. It works well for a while then crashes.
What I'm trying to do is pull from 7 separate queues randomly according to a uniform distribution. I need to keep pulling items as long as they exist in the queues and stop when the queues are empty. Any advice on how you would do it?
__________________
"A bird is an instrument working according to mathematical law, which is within the capacity of man to reproduce." -Leonardo da Vinci, 1502 |
#6
|
|||
|
|||
Gavin,
I was looking through the code again, and it looks like you are using uniform(1,7,1) when you should be using duniform(1,7,1) because it only returns discrete numbers whereas the uniform() returns all real numbers in the range. |
#7
|
||||
|
||||
Why don't you just write a Random Available Pull From Port option?
Attached is an example model showing this. This code was taken from SendTo Random Available Port and modified to check the input ports instead of the output ports for pulling. Code:
double arraysize = nrip(current); doublearray openports = makearray(arraysize); int nrofportsopen = 0; for( int index = 1; index <= arraysize; index++) { if(ipavailable(current,index)) { nrofportsopen++; openports[ nrofportsopen ] = index; } } double returnvalue; if(nrofportsopen > 0) { int returnindex = duniform(1, nrofportsopen); returnvalue = openports[returnindex]; } else returnvalue = 0; return returnvalue; |
The Following User Says Thank You to Phil BoBo For This Useful Post: | ||
Gavin Douglas (02-07-2013) |
#9
|
||||
|
||||
I even found a solution, but it´s not quiet as simple as the others.
But maybe you see, what had been the trouble in your way.
__________________
Hemmi |
The Following User Says Thank You to Sebastian Hemmann For This Useful Post: | ||
Gavin Douglas (02-07-2013) |
Thread | Thread Starter | Forum | Replies | Last Post |
I want to look for the flexsim demo about automobile plant, especially engine machining and assembly line... | syseo | Pre-sales Questions | 0 | 12-11-2012 05:30 AM |
Flexsim engine has stopped working | Peter Walters | Gripes and Goodies | 3 | 07-23-2012 09:51 AM |
Using Flexsim as a simulation engine? | Kenny Macleod | Q&A | 2 | 11-19-2008 03:15 PM |
How does a Simulation Engine work ? | Vinay Mehendiratta | Q&A | 2 | 02-14-2008 01:01 PM |