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
FAQ Downloads Calendar Search Mark Forums Read

Q&A Using Flexsim and building models

Reply
 
Thread Tools Display Modes
  #1  
Old 04-23-2008
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: 169
KelvinHo will become famous soon enough
Default 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 0-7, shift 2 = hour 8-15, shift 3 = hour 16-23
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 3-4, 11-12, 19-20?

Regards,

Kelvin
Attached Thumbnails
Click image for larger version

Name:	1.jpg
Views:	337
Size:	20.1 KB
ID:	225  
Reply With Quote
  #2  
Old 04-23-2008
Cliff King's Avatar
Cliff King Cliff King is offline
Vice President Technical Services
 
Join Date: Jul 2007
Location: Utah
Posts: 272
Downloads: 158
Uploads: 14
Thanks: 102
Thanked 304 Times in 110 Posts
Rep Power: 410
Cliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud of
Default

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);
Reply With Quote
The Following User Says Thank You to Cliff King For This Useful Post:
KelvinHo (05-13-2008)
  #3  
Old 04-23-2008
Brandon Peterson's Avatar
Brandon Peterson Brandon Peterson is offline
The Flexsim Consultant
 
Join Date: Jul 2007
Location: Salt Lake City, Utah
Posts: 382
Downloads: 29
Uploads: 6
Thanks: 192
Thanked 516 Times in 235 Posts
Rep Power: 488
Brandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant future
Default

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
Attached Files
File Type: zip Interarrival time by time of day.zip (38.3 KB, 397 views)
__________________
thats not normal.
Reply With Quote
The Following User Says Thank You to Brandon Peterson For This Useful Post:
KelvinHo (05-13-2008)
  #4  
Old 05-13-2008
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: 169
KelvinHo will become famous soon enough
Default

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

Kelvin
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT -6. The time now is 03:36 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.