ATTENTIONThis FlexSim Community Forum is readonly. 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, mobilefriendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threadedconversationstyle forum like the one below, so be sure to read our Answers Best Practices. 
flexsim.com 

FAQ  Downloads  Calendar  Search  Mark Forums Read 
Q&A Using Flexsim and building models 

Thread Tools  Display Modes 
#1




control the source input "By the time of the day"
Hi,
I have a question on source: I would like the source to make the flowitem as the attached jpg. I tried to use "b=By the time of the day" from picklist, but I don understand how's it works. treenode current = ownerobject(c); /**By Time of Day:*/ int second = 1; int minute = 60; int hour = 3600; int day = 86400; int shift = 28800; /** \nModel Time Unit: */ int timeunits = /**/second/**/;/** (second, minute, hour, day)\n*/ int timeinseconds = fmod(time()*timeunits, day); hour = trunc(timeinseconds / hour); shift = trunc(timeinseconds / shift) + 1; /**\n*/ /**/if(shift == 2 && hour != 12) return exponential(0,5,1); else return exponential(0,15,1);/**/ /**\n\nshift 1 = hour 07, shift 2 = hour 815, shift 3 = hour 1623 This assumes that the simulation starts at hour 0*/ does it mean that if i change exponential distribution to normal distribution, the 3 peaks will appear at hour 34, 1112, 1920? Regards, Kelvin 
#2




No, the exponential distribution as with all the statistical distributions are a distribution over a possible range of values as determined by random probabilities, so please don't confuse them as a distribution of values spread over a time period.
The "By Time of Day" option is just showing you an example of how you will need to write your own conditional expression ("if" statements, or "switch" statements or whatever) to define the interarrival time based on what time of the day it is. The example they give as shown below can be interpreted as saying if it is shift 2 or in other words, the simulation time is between hours 8 and 15 of each day, and the time is not hour 12, then the interarrival time will be defined by exponential(0,5,1) otherwise the interarrival time will be defined by exponential(0,15,1). Code:
if(shift == 2 && hour != 12) return exponential(0,5,1); else return exponential(0,15,1); 
The Following User Says Thank You to Cliff King For This Useful Post:  
KelvinHo (05132008) 
#3




Kelvin,
Here is a model that has what I think you are looking for. The source has a custom built inter arrival time that uses the time of day to lookup an inter arrival time from a table. Each line of code is commented to help you understand what I did if you want to edit it. The following are required fields in the code template field: Table Name  Name of the global table Model Time Unit  The unit of measure for the sim time Table Lookup Time Unit  The unit of measure for the first column (lookup) of the table Table Value Time Unit  The unit of measure for the second column (value) of the table Good Luck, Brandon
__________________
thats not normal. 
The Following User Says Thank You to Brandon Peterson For This Useful Post:  
KelvinHo (05132008) 
#4




Thanks Brandon, it's exactly what I want, and this should be a useful script for many users.
Kelvin 
Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
error message "Clock overflow, running stopped"  Martin Kooijman  Q&A  11  04172008 10:29 AM 
about "no select" and "show parameter window from side bar"  qin tian  Gripes and Goodies  3  03212008 08:10 AM 
can "do not release item" commend be used in source?  KelvinHo  Q&A  2  03102008 12:30 AM 
Which variable stores "Properties > General >Flags > Protected" information?  KelvinHo  Q&A  1  03062008 06:18 AM 
"Getting Started" and "Tutorial" models for v4.01  Cliff King  Product Announcements  0  12102007 07:34 PM 