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 02-06-2013
Gavin Douglas Gavin Douglas is offline
Flexsim User
 
Join Date: Feb 2008
Posts: 65
Downloads: 1
Uploads: 0
Thanks: 27
Thanked 1 Time in 1 Post
Rep Power: 152
Gavin Douglas is on a distinguished road
Default 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...
Attached Files
File Type: fsm 2014.fsm (33.3 KB, 86 views)
__________________
"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  
Old 02-06-2013
Cameron Pluim Cameron Pluim is offline
Steelcase, Inc.
 
Join Date: Apr 2012
Location: MI
Posts: 30
Downloads: 27
Uploads: 11
Thanks: 5
Thanked 34 Times in 20 Posts
Rep Power: 120
Cameron Pluim will become famous soon enoughCameron Pluim will become famous soon enough
Default

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  
Old 02-07-2013
Gavin Douglas Gavin Douglas is offline
Flexsim User
 
Join Date: Feb 2008
Posts: 65
Downloads: 1
Uploads: 0
Thanks: 27
Thanked 1 Time in 1 Post
Rep Power: 152
Gavin Douglas is on a distinguished road
Default

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  
Old 02-07-2013
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

You´ve built an infinite loop when content of all conected objects is 0.

Quote:
for(int aa = 1; aa <= nrip(current); aa++)
{
int b = content(inobject(current,aa));
if(b>0) openoutput(inobject(current,aa));
}
should check all contents once!
But wouldn´t it be better to solve it with some logic in the inobjects?
__________________
Hemmi
  #5  
Old 02-07-2013
Gavin Douglas Gavin Douglas is offline
Flexsim User
 
Join Date: Feb 2008
Posts: 65
Downloads: 1
Uploads: 0
Thanks: 27
Thanked 1 Time in 1 Post
Rep Power: 152
Gavin Douglas is on a distinguished road
Default

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  
Old 02-07-2013
Cameron Pluim Cameron Pluim is offline
Steelcase, Inc.
 
Join Date: Apr 2012
Location: MI
Posts: 30
Downloads: 27
Uploads: 11
Thanks: 5
Thanked 34 Times in 20 Posts
Rep Power: 120
Cameron Pluim will become famous soon enoughCameron Pluim will become famous soon enough
Default

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  
Old 02-07-2013
Phil BoBo's Avatar
Phil BoBo Phil BoBo is offline
Flexsim Development
 
Join Date: Jan 2008
Posts: 756
Downloads: 109
Uploads: 18
Thanks: 385
Thanked 1,483 Times in 525 Posts
Rep Power: 1174
Phil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond repute
Default

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;
Attached Files
File Type: fsm pull_random_available.fsm (31.3 KB, 78 views)
The Following User Says Thank You to Phil BoBo For This Useful Post:
Gavin Douglas (02-07-2013)
  #8  
Old 02-07-2013
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

The Pull Requirement you use is "Round Robin if available", this doesn´t do what you want?
__________________
Hemmi
  #9  
Old 02-07-2013
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

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.
Attached Files
File Type: fsm Uniform.fsm (66.3 KB, 76 views)
__________________
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


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.