Flexsim Tutorial
Bill KP Chan HW 1-6
Flexs im Con cept s & T erm in ol og y
• Model • Objects
- Fixed Resources
- Mobile Resources (task executors) - Flowitems - ports - triggers - task sequences • Libraries • Model Views
Models, Objects and Flowitems
•
Model
- A collection of Flexsim objects representing
an actual system -
with just enough detail to answer
the questions you are concerned with!
•
Object
- A building block with
inherited
behavior, and
user-definable
attributes
,
variables
, and
visual
properties
.
•
Flowitem
– the entities that flow through a model
such as products, customers, paperwork, phone
calls, etc.
Model
Flexsim Model
• A Flexsim
model
is a system of
queues
,
processes
, and
transportation
.
–
Queues
develop naturally in a model when
upstream arrival rates exceed the
downstream processing rates.
–
Processing
is simply a forced time delay on
the object being processed.
Object Classification
•
FixedResources
– objects which send
and/or receive
flowitems
ex.
Object Classification
•
Flowitems
-
The entities that are
passed from one fixed resource to
another within a model.
• Flowitems are actually Flexsim Objects.
• Flowitems hold information that can be
set and queried in the model.
– This information can do anything from
defining process times to making routing
decisions, and anything in between.
Model Behavior
Most modeling behaviour is defined on
the
fi xed re so ur ces
in a model:
– how long to process the flowitem
– where to send the flowitem next
– call a shared resource (operator) for
processing the flowitem
Object Port Connections
•
Out pu t/Inp ut Por ts
-
Output-to-Input port
connections define possible
flowitem
routes to/from
Fix ed Reso ur ces
.
Object Port Connections
•
Cente r Ports
-
for referencing purposes,
typically used to point to a
TaskExecuter
to be
called for the processing or transportation of a
Concept of Triggers
•
When key events occur on an
object
, a
trigger
is fired.
•
The user may specify a variety of things to
happen when a trigger fires (trigger logic).
•
There are triggers when a flowitem enters
or exits an object. There are triggers when
a process time finishes or a repair time is
complete.
•
Each type of object has a unique set of
triggers.
Triggers
• An opportunity to define
and customize system
behaviour at a specific
event occurrence.
– Write/read information to/from a flowitem.
– Change visual properties of flowitems or objects. – Send Messages to other
Tasks and Tasksequences
•
task
– a single instruction or action to be
performed by a
TaskExecuter
object.
ex.
LOAD flowitem
•
tasksequence
– a series of
tasks
to be
performed in sequence.
ex. TRAVEL to queue
LOAD flowitem
TRAVEL to processor
UNLOAD flowitem
Library
•
Library
-
a list of class objects to
be used in building a model.
•
Instance
– a copy of one of the
library objects - created in the
model when an object is dragged
from the library icon grid into a
Model Views
Perspective >
> Ort ho gr aph ic
• Additional Views:
– Planar
A
view
is a window into the model. You can have several
views open at the same time. Each view is a
different
Basic Steps of Modeling in Flexsim
1 - Create a layout using library objects
2 - Make port connections
3 - Edit the look and behavior of objects
4 - Compile and run the simulation
Mouse Operations
• View Window Navigation:
– Translate:
left click-drag
– Tilt and Rotate:
right click-drag
– Zoom:
left&right click-drag (or scroll wheel)
• Object:
– Translate in X and Y:
left click-drag on object
– Translate in Z:
right&left click-drag on object
•
Highlighted
= yellow box: left click
•
Selected
= red box: shift-click or ctrl-click
– select multiple objects by shift or ctrl click-dragging a
bounding box around a group of objects
Model 1
• Purpose
– Introduction to the 5 basic steps of model building
using a single queue, single server system (post
office).
• Description
– people arrive at a post office every 60 seconds, on
average. The statistical probability distribution
which best simulates the inter-arrival pattern is an
exponential distribution with a location value of 0
and a scale value of 60.
• Drag objects from the Library (icon grid) and drop them into the Orthographic Model View window using your mouse.
• Reposition, resize, or rotate objects as desired using mouse.
Flowitem Flow
•
Flowitems
are passed from one object to the
next in zero time regardless of where in the
model layout the objects are located.
• To create time delay in the flowitem flow, add
conveyors or task executers for
transport
.
– Convey time depends on the conveyor’s length and
speed.
– Transport time between objects depends on the
distance between the objects, plus the task
executer’s speed, acceleration, & deceleration.
To scale or not to scale?
1. Choose the time and distance unit that will be most common in your model.
• time: milliseconds, seconds, minutes, hours, days, weeks, months, years, etc.
• distance: inches, feet, meters, kilometers, miles, etc.
2. Once you have chosen your time and distance units, make the mental connection that EVERY mea sur ement in you r model must be set in your chosen units.
Flexsim is a “unitless” platform. Time & length
units are “user-definable” – consistency is the
key!
Port Connections
• Objects can have an
unlimited
number of
ports.
• A port connection is needed for
each
possible routing choice in the model.
• The actual port that a flowitem passes
through depends on the selected rule for
the object that is either doing the pushing
or the pulling.
Step 2. Make port connections
• While pressing the “
A” key, click-and-drag
port connectionsbetween the objects.
• Direction is important! Drag from thesending object to the receiving
object.
• These
output to inputport connections are needed between
the objects in your model that send and receive
flowitems.
Viewing port connections
• Display of port
connections can be
toggled on/off within
the “View Settings”
view sidebar.
• The size of the port
connectors can be
adjusted with the
+/-buttons.
Keys used for Port Connections
Q
Q
W
W
Disconnect
Connect
Step 3. Edit the objects
•
Properties Window
– Right click then choose Properties
– Used to edit and view general info on all objects
• Visual shape, size, orientation, location • Name a local toggles
• Port connections • Labels
• Statistics
•
Parameters Window
– Double click (or right click then choose Parameters)
– Used to edit object specific behaviour
Properties Window
•
Every ob ject has th e
same se t o f p ro pert ies
tabs
• Visual Tab
– Look and size
• General Tab
– Port connections – Display switches
• Objects can be repositioned,
resized, and reoriented from
the Properties window.
• Additionally, objects can be
manipulated from within the
model view.
– Reposition an object by left-click dragging the object to a new location.
– Be sure “Edit | Resize and Rotate Object” is checked
• Left-click drag on the arrows to resize.
– Up and right are larger – Down and left are smaller
• Right-click drag on the arrows
Parameters Window
• Each object class has its
own Parameters Window
• Parameters affect the time
that flowitems stay in an
object and how they are
routed from object to object.
•
Applywill accept changes
•
OKwill accept changes and
close the window
Parameter tabs
• Parameters are grouped into tab pages by category
• Every fixed resource object will have a “
Flow
” tab
Understanding the Basic Pick List
• The pick list
• The code template (friendly editing)
Understanding the Trigger Pick List
• The current code/selection
• Add a pick-option to the code
• Clear all of the existing code
• The code template (friendly editing)
Code Template
• Blue text in the
Template
may be
Code
replaced with any valid
number, string or
• The statistical probability
distribution which best
simulates the inter-arrival
pattern is an
exponential
distribution
with a
location value of
0
and a
scale value of
60
.
Step 4. Compile and
Run the Simulation
• Compile the model (for
models with C++ only)
• Reset, Run
• Control run speed with the
slide control (has no effect
Step 5. View the results
• Create a Full, Summary or
State Report using the
“Statistics” menu
• Other reporting features to be discussed later:
– VisualTool Object • Dynamic text – Recorder Object
• Time plots, histograms, pie charts, historical and
statistical tabular data
– Object Properties Statistics Tab – Triggers writing to GlobalTables
Summary Report
• Display a tabular
report for all objects
in model (or just
those that are
red-selected
).
• Choose from a list
of standard system
variables to include
in report.
Flexsim State Report
• State profile is listed
for all objects in the
model (or just those
that are
red-selected
).
• Displays amount of
time or percentage
of total simulation
time an object was
Full Report
• Requires Full History to be enabled
– Statistics | Full History On
• Records data as the model runs
• Data is saved in a database • Flexsim Chart makes charts
Model 1 Follow Up
• Questions
– What’s the maximum and average time
people wait in line?
– How many unhappy customers?
– What’s the utilization of the service window?
– How many customers were serviced?
Model 2
• Purpose
– learn how to duplicate objects
– see affects of adding a second service window
– introduction to the “Send to port” field (Flow tab)
• Description
– add another service window to the post office
• Questions
– answer the questions asked in Model 1 - Preview
– if the windows differ by the type of service they can
provide and 40% of the people need to use window
1 and 60% need to use window 2, how does the
queue time increase?
Editing Selected Objects
• Group editing can be performed on selected objects using
the “
Edi t Select ed Obj ect s
” menu in the view’s sidebar.
• Only one object can be
given view window.
highlighted
(YELLOW box) in a
• Multiple objects can be
selected
(RED box)
The Flexsim Object Library
• The Flexsim Family Tree
– Fixed Resource – Task Executer – Dispatcher • Model 3 – Sink – Queue – Conveyor – Flow Node – Processor - Transporter
- Task Executer Teams - Network Node - Recorder - Visual Tool - Multiprocessor - Seperator - Combiner - Rack - Operator
Flexsim Family Tree
Flexsim Flexsim
Flexsim
Flexsim Object Object Object Object
Fixed Resource Fixed Resource
Fixed Resource
Fixed Resource DispatcherDispatcherDispatcherDispatcher NavigatorNavigatorNavigatorNavigator Network Network NodeNetwork NodeNetwork NodeNode Visual Visual ToolVisual ToolVisual ToolTool Recorder Recorder Recorder Recorder Traffic Control Traffic Control Traffic Control Traffic Control Source Source Queue Queue Sink Sink Rack Rack T
Taassk k EExxeeccuutteer r NNeettwwoorrk k NNaavviiggaattoorr
Operator Operator Transporter Transporter Crane Crane ASRS Vehic le ASRS Vehic le Robot Robot
Flexsim Standard Objects
• Flexsim currently has 25
objects in its discrete object
library.
• Your ability to model will be
determined by how well you
understand these 25 objects
and more importantly, the three
main superclasses:
– Fixed Resource – Task Executer – Dispatcher
• Extensive coverage of the
Flexsim Object Library is found
in the
Flexsim
Users Ma nu al.FixedResource Superclass
• FixedResource objects are the backbone of a simulation
model. They’re used to define the product flow.
• FixedResources can:
– push or pull flowitems
– process flowitems (forced delay)
– queue up flowitems (accumulate up to a max content) – call for an operator to be utilized (for process / setup)
TaskExecuter Superclass
• TaskExecuters execute tasksequences.
• A tasksequence is a list of tasks which are to be completed in the order listed.
• A task is an activity such as loading, unloading, traveling, delaying, or simply being utilized.
• When a TaskExecuter receives a tasksequence, it will start executing the tasks one after another until the tasksequence is either finished or preempted by a preempting tasksequence of higher priority .
• Tasksequences are created and dispatched automatically when th“Use Transport” or “Use Operator” boxes are checked on a FixedResource.
• Cust om taskseque nces can also be created and dispatched using commands (taught later).
• The Dispatcher receives tasksequences and either queues them up, or dispatches the tasksequences immediately to other Dispatchers and/or TaskExecuters connected to its output ports.
• A tasksequence may preempt the current tasksequence part way through the current list of tasks. The preemption can either
temporarily interrupt the current tasksequence or permanently destroy the current tasksequence as well as any other
tasksequences waiting in the preempted TaskExecuter’s tasksequence queue.
Model 3
• Purpose
Build a model which uses several objects in the Flexsim library
• Description:
A part enters a Separator every 20s where it is split into 3 separate parts. Each part moves down one of three separate lines:
1. The first part moves via an “s”-shaped conveyor to a Combiner where a total of 8 parts are packed on a pallet (supplied by another Source). The loaded pallet is then conveyed to a Sink.
2. The second part is conveyed to a Queue where it is then carried by an
Operator to a MultiProcessor object where 3 separate processing steps are performed. The first step can complete on it’s own in 3 seconds. The second step requires an operator (same operator that delivered the part) and takes 4 seconds, and the third step can complete on its own in 5 seconds. A Transporter then picks up the part and takes it to a Rack where it is stored. 3. The third part travels via FlowNodes to a Queue where 10 are accumulated before being released, one at a time, to a Processor with a 20 second cycle time. They are then placed in a Queue where a Robot transfers one part at a time over to a Sink.
Build Model 3 in Four Phases
• Phase 1: Create Flow
– Create flow with FixedResource Class objects only (neglect TaskExecuters).
• Phase 2: Add TaskExecutors
– Add TaskExecutors: Operator, Transporter and Robot.
• Phase 3: Network Node Paths
– Add a NetworkNode path to control the travel path of the Transporters.
Phase 1 Description
• Phase 1:
– Obtain flow with FixedResource Class objects only (neglect TaskExecuters).
Source
• The Source is used to
introduce flowitems into
the model.
• The arrival rate of
flowitems will be based
on an Inter-Arrival Time,
Arrival Schedule or
Sink
• The sink is used as an exit point for flowitems.
• FlowItems can only ‘exit’ the model via the Sink
• Your last chance to record information about th
Queue
• The Queue is used to
stage FlowItems for
downstream operations.
• Queues are used in the
model wherever
work-in-process (WIP) exists
Conveyor
• Used to convey flowitems from one location in the model
to another location.
• Time to convey depends on the conveyor’s length
divided by its speed.
• Can be accumulating or not. If not, all parts on the
conveyor stop when a part at reaches the end of the
conveyor and is blocked (like a Belt conveyor).
• Conveyors can take the actual length of the flowitems
and the Conveyor sections into account when calculating
accumulation and available space.
• You can define a combination of many straight and
curved sections all on one conveyor object!
Flow Node
• The FlowNode is used in a model where it is
desirable to have flowitems move along a
designated path to another object in the
model consuming time as they move.
• One use would be to move people (flowitems)
down an open corridor or in a building.
Processor
• A Processor is used anytime an operation is
performed on a FlowItem.
• A Processor can be any kind of machine or
station; anything that would take
time
to
manipulate a FlowItem.
• The FlowItems must stay in the Processor for
the sum of the Setup Time and the Process
Time plus any Blocked Time. The dwell time
may also include time waiting for an operator,
time waiting for a transporter and time waiting for
the Processor to be repaired if broken down.
Order of Execution
(pushed flowitem)
OnEntry
flowitem enters Setup Time Pick Operator OnSetupFinish
Process Time
MultiProcessor
• The MultiProcessor allows you to perform several operation steps at one location.
• Each operation can have a
different process time, and use a different number of operators. • A MultiProcessor is a good
object to use when you have large flowitems that move to a spot where several operations are performed before it moves again.
• Only 1 flowitem at a time is allowed in the MultiProcessor.
Combiner
• The Combiner is used to pack or join flowitems
• When using the pack option, the flowitems which enter ports 2 and higher are placed inside of the flowitem which entered port 1.
• When using the join option, the flowitems which enter ports 2 and higher are destroyed, and the flowitem which entered port 1
represents the “assembled” part.
• Note: Component rows are added automatically for each input port connections made for ports 2 and higher.
Separator
• The Separator is used to separate (unpack) or to split
(make copies of) flowitems.
• It can unpack flowitems that were previously combined
using the Combiner.
• Flowitems can be split into a specific number or call from
a table.
Rack
• The Rack is used to store flowitems in a
specific column and row (bay and level).
• You can toggle between three different
visual displays of the Rack by holding the
“X” key and clicking on the Rack.
Phase 2 Description
• Phase 2:
Operator
• An Operator will model human tasks such as machine setup or manual assembly.
• The Operator can also be used to transport FlowItems from one FixedResource to another.
Transporter
• A Transporter is used in a model where a fork truck, AGV or some other transport vehicle might be used.
• It is used to transport FlowItems from one FixedResource to anothe • The Transporter can travel in x, y and z directions.
• During offset travel the forks lift or lower in the z direction as neede to pick or place flowitems.
• Transporters can load many FlowItems from multiple locations and then unload the FlowItems separately to multiple locations.
Forming a TaskExecuter team
Output
Center
Dispatcher TaskExecutersInput
• Phase 3:
– Add a NetworkNode path to control the travel path of the Transporter.
NetworkNodes
• NetworkNodes are used to define the path a
TaskExecutor will follow when executing its travel tasks
• A network path is made up of a group of interconnected
NetworkNodes.
• A TaskExecuter is assigned to move on the network by
connecting it to any NetworkNode in the path. The
Connecting NetworkNodes
• Click-and-drag a
connection while
pressing the “A” key.
• When connected you
will see a black line
between the nodes.
Two green direction
indicators show that
travel is allowed in
both directions.
Connecting a Fixed Resource to the Network
• Click-and-drag a
connection, while
holding the “A” key,
between a NetworkNode
and the object where the
load takes place.
Connecting a TaskExecutor
to the Network
• Click-and-drag a
connection between the
TaskExecutor and a
NetworkNode while
pressing the “A” key.
• A red line will indicate
that the connection has
been made. The line
does not connect to any
port.
Single Direction Paths
• A path can be restricted
to travel in a single
direction by pressing
the “Q” key and
click-dragging in the direction
you want to disallow
travel.
Non-Passing Paths
• A non-passing path can
be toggled by using the
“A” key and
click-and-dragging between two
nodes that are already
connected.
• The direction indicator
turns yellow, showing a
non-passing direction.
• “A” dragging a red or
yellow direction will
No t rave li ng
Direction Indicator Context Menu
“X” clicking a direction indicator with the mouse button will also toggle through the different direction modes.
Use the “Travel
Networks” section of Rather than “A” dragging the path to toggle path type, you can right click a direction indicator and choose from a context menu.
Spline Control Points
• To create a curved
path select “Curved”
from the direction
indicator context
menu.
• Spline control points
will appear on the
path.
• Drag the spline
control points to
5. A
1. a
2. A
3. A
• The display options for the
network can be toggled by
holding down the “X”
and then clicking on any
NetworkNode.
NetworkNode View Modes
Paths Tab
• Each path from a NetworkNode can be edited in many ways. • Different direction modes can be
set using the “Connection Type” dropdown list.
• Minimum spacing between travellers can be defined. • A maximum speed can be set
for this path connection.
• A Virt ual Distance can be set. Virtual distance is a forced distance value. Using virtual distance, you can give a path an artificial length.
Phase 4 Description
• Phase 4:
– Add a 3D pie chart to show the status of the Operator – Add 3D text to show the content of the Rack
Recorder
• The Recorder is used to display and record
statistical information.
• The Recorder can display 3D charts and
graphs from object data or tables.
• Enable the object to record data for Content
and Staytime graphs (Statistics tab of
VisualTool
• The VisualTool is one of
the most versatile Flexsim
Objects.
• VisualTool can be used as
a prop to display planes,
cubes, columns, spheres,
imported objects (2D CAD
or 3D shapes), 3D text and
even presentation slides
(bmp, jpg).
• The VisualTool can also
act as a container for other
Flexs im Hiera rchy
<understanding the tree structure>
And
The Mod eli ng Lang uage
What is a Node?
• Basic data structure of Flexsim is a hierarchal tree
– main tree (model and project related objects and data)
– view tree (GUI related objects and picklists)
– model tree (model related objects and data)
• The node is the basic building block of a tree
Node Structure
• Nodes have a name
• Nodes can have a data item
– number
– string
– object
• If nodes
have
object data, use
>
to view a
separate node list containing the object info
(data members and member functions)
• If nodes
contain
sub nodes, use + to expand
and view the child nodes
Node Symbols
Standard Folder
Object
Object data
Function (C++)
Function (FlexScript)
What is a function?
functionname(
argument1,
argument2,
etc)
• An argument can be:
– Numerical value – String (“text“)
– Pointer (*) to an object or node
• Function example:
colorrandom(item)
General Rules
• language is case sensitive (A does not equal a)
• no specific format is required (free use of spaces, tabs and line
returns is encouraged for “readable” code)
• text strings are entered between quotes.
“mytext”
• parenthesis follow a function call and commas separate the
arguments of the function.
moveobject(object1, object2);
• a function or command will always end with a
SEMI-COLON (;)• parenthesis can also be used freely to make associations in
your math and logic statements. Ex: ((x+3)*2)
• curly braces { } are used to define a block of statements.
• to comment the rest of a line use
// and ty pe not e here• multi-line comments start with /* and end with */.
• don’t use spaces or special characters in name definitions
(
_is ok).
Logic Statements - Available Help
– Existing Pick List options are great examples
– Commands
Variable Types
• int
• double
• string
• treenode
integer
(1, 2, 3, 14324)
double precision
(2.5, 3.14159)
text string
(“Anthony was here.”)
Declaring and Setting Variables
• int index = 1;
• double weight = 175.8;
• string category = “groceries”;
Math Operators
• x + y
• x - y
• x * y
• x / y
• sqrt(x)
• pow(x,y)
• round(x)
• frac(x)
• fmod(x,y)
• min(x,y)
• max(x,y)
x plus y
x minus y
x times y
x divided by y
square root of x
x to the power of y (x
y)
x rounded to the nearest integer
returns the decimal portion of x
returns the remainder of x/y
returns minimum of x and y
returns maximum of x and y
Comparing
• x > y
• x < y
• x >= y
• x <= y
• x == y
• x != y
x greater than y
x less than y
x greater than or equal to y
x less than or equal to y
x equal to y
Relating
• &&
• ||
• !
logical AND
logical OR
logical NOT
Updating
•x = y
•x += y
•x -= y
•x *= y
•x /= y
set x to y
set x to x plus y
set x to x minus y
set x to x times y
set x to x divided by y
Basic Object Referencing
• current -
the current object, the owner of the code
• item -
the involved flowitem that triggered the event
• model() -
references the model tree
• rank(
node, ranknum)
rank(current,3)
• node(“relativepath”, object)
node(“/Operator1”,model())
• inobject(
object, portnum)
inobject(current,1)
• outobject(
object, portnum)
outobject(current,1)
• centerobject(
object, portnum)
centerobject(current,1)
• first(
object)
first(current)
Basic Object Statistics
• content(
object
)
• getinput(
object )
• getoutput(
object
)
Object Spatial Attributes
• xloc(
object
)
yloc(
object
)
zloc(
object
)
• setloc(
object, xnum, ynum, znum
)
• xsize(
object
)
ysize(
object
)
zsize(
object
)
• setsize(
object, xnum, ynum, znum
)
• xrot(
object
)
yrot(
object
)
zrot(
object
)
• setrot(
object, xdeg, ydeg, zdeg
)
Itemtypes
• itemtype
– all
flowitems
have an attribute
called
itemtype
. It’s a numeric identifier used
to distinguish one “type” of flowitem from
another in processing and routing decisions in
a model.
Basic Object Attributes
• getname(
object
)
• setname(
object, “name”
)
• getitemtype(
flowitem
)
• setitemtype(
flowitem, num
)
• setcolor(
object, red, green, blue
)
• color
red
(
object
) –
blue,green,random...
– How can you find the names of other color
functions?
Prompts and Printouts
• syntax
– pt(
text string
)
– pf(
float value
)
– pd(
discrete value
)
– pr( )
– msg(
“window title”, “message text”, button type
)
Processor Parameters
• Understanding the edit fields of the Processor
object will help you understand Flexsim.
• You should be able to answer the following
four questions about each edit field:
– what is its purpose?
– when is it evaluated?
– what are its access variables?
– what does it return?
Access Variables & Returns
Edit Field Access Variables Returns Setup Time current, item, port delay time Process Time current, item delay time
MTBF current delay time
MTTR current delay time
Send To Port current, item port number Pull From Port current port number Pull Requirement current, item, port true/false (1/0) Request Transport From current, item, port numeric pointer Pick Operator current, item numeric pointer
OnReset current N/A
Code Exercise 1
• Purpose
– Gain experience in writing code in the Code Edit windows.
– Introduction to special comments used to define Code Templatewindows. – Introduction to the bernoulli command.
bernoulli(num probability, num succeed-value, num fail-value, [num stream])
• Description
– Do not use code templates for these exercises (write your own code, beginning with most basic available option)!
– See next slide for model layout description.
– Using the “Send To Port” field of the Conveyor, send 30% of the flowitems to port 1 and 70% to port 2 (Use the bernoulli
Logical ‘if’ Statement
if (
test expression)
{
code block}
else
{
code block}
if (content(item) == 2)
{
colorred(item);
}
else
{
colorblack(item);
}
Code Exercise 2
• Purpose
– Learn how to both set and read the itemtype of a flowitem using code.
– Introduction to the Flowitem Bin
• Description
– Uses same layout as Exercise 1.
– Set the itemtype of flowitems as they exit the Source.
– 60% of the flowitems are itemtype 7, the rest are itemtype 3. – Using an “if” statement in the “Send To Port” field of the
The Flowitem Bin
• Sources create copies
of objects in the
Flowitem Bin
• Any changes made to
objects in the Bin
affect the flowitems
that are created by
Sources
• Used to create labels,
set size, color, shape,
etc.
Labels
•
labels
– information can be
stored on flowitems (and
other modeling objects) in the
form of labels.
•
Flowitems and other Flexsim
objects can have an
•
examples
–
getlabelnum( item, “serialnumber” )
–
setlabelnum( item, “serialnumber”, 5 )
–
getlabelstr( current, “category” )
–
setlabelstr( current, “category”, “groceries” )
–
inc( label(item, “stepnum”), 1 )
• The increment command only works with number data nodes
Object Labels
• syntax
– getlabelnum(
object, “labelname”
)– setlabelnum(
object, “labelname” , value
)– getlabelstr(
object, “labelname”
)– setlabelstr(
object, “labelname” , string
)int type = getitemtype(item); switch (type) { case 1: { coloryellow(item); break; } case 5: { colorred(item); break; switch ( switchvariable ) { case casenum: { code block break; } case casenum2: { code block break;
Code Exercise 3
• Purpose
– Learn how to both set and read the labels on a flowitem using code.
• Description
– Uses same layout as Exercise 1.
– Create a numeric label named “routing” on the Textured Colored Box in the FlowItem Bin (see toolbar).
– Set the “routing” label of flowitems as they exit the Source with a random number between 1 and 4 (use duniform() command). – Use a switch() statement in the “Send To Port” field of the
Conveyor to send flowitems according to the following rules:
• Label values 1 and 3 go to port 2 • Label values 2 and 4 go to port 1
• Questions
– Can you change the color of the flowitems based on their label value using code?
Logical ‘while’ Statement
wh il e (
test expression
)
{
code block
}
while (content(current) > 0)
{
destroyobject(last(current));
}
Logical ‘for’ Statement
for (int index=1; index<=content(current); index++) {
colorblue(rank(current,index)); }
A
for loop
allows you to repeat a block of code a set
number of times. The head of the for loop defines the
repeat conditions:
1. specify a changing variable & give it an initial value 2. set a condition to exit the loop
3. how to treat your variable at the end of each iteration
Avoid infinite loops by ensuring that the test e xpr essi on will
for (start expression; test expression; count expression) {
//code block
Code Exercise 4
• Purpose
– Learn how to write your own “for” loop.
• Description
– A Combiner packs 8 boxes on a pallet.
– Use an infinite supply of pallets from one Source and an infinite supply of boxes from another Source.
– The Combiner sends to a Conveyor which then sends to another Conveyor.
– Using the OnExit trigger of the first Conveyor, write a “for” loop which changes the color of all the boxes on the pallet.
Model 4 - Concepts
• Itemtypes
• Push vs. Pull
Order of Execution
(pulled flowitem)
Pull From Pull Requirement Flowitem becomes available upstream Setup Time delay Pick OperatorSend To Port OnEntry
OnSetupFinish
Process Time Pick Operator
delay Request possible delay OnExit if true delay
Model 4
• Purpose
– Learn how to use pull logic in defining routings based on a flowitem’s itemtype.
• Description
– Electronic components need to be tested after manufacture.– There are two types of components that arrive in a queue at random with the mix being 40% of one and 60% the other. – The inter-arrival time of components is exponential(0,30,1) – There are two testers for component 1 and three testers for
Model 5 - Concepts
• Global Tables
• Labels
• Triggers
Global Table Commands
• gettablenum(
“tablename”, rownum, colnum
)
• settablenum(
“tablename”, rownum, colnum, value
)
• gettablestr(
“tablename”, rownum, colnum
)
Model 5
• Purpose
– Small example of using a Global Table to define product routings. – Learn how to use a label to keep track of what step the flowitem is on.
• Description
– 3 different products (uniformly distributed) enter a 5 station work cell. – Products are processed at the following stations in the order specified
• Product 1 needs to be processed at station 1,3, and 2. • Product 2 needs to be processed at station 1, 2, and 4. • Product 3 need to be processed at station 2,4,3, and 5.
– Use a global table to make sure the products are sent to the right station in the proper sequence.
Model 6 - Concepts
• Labels and Itemtypes
• Empirical Distributions
• Trigger sequence
Model 6
• Purpose
– Learn how to assign and use labels on flowitems for routing and processing purposes. Learn how to use an empirical distribution to assign itemtypes.
• Description
– Parts arrive in a queue exponentially every 30 seconds. There are four part types (1,2,3,4) distributed (20%, 30%, 40%, 10%)
respectively (see dempirical in Flexsim Command Summary).
– The parts are processed on one of four machines. Each machine is dedicated to a single part type. The processing times at each
machine is uniform(100,120) seconds for first time parts, and uniform(120,130) seconds for rework parts.
– After the parts are machined, they are put in a queue and wait to be tested. The test time is a constant 10 seconds. Parts that pass, leave the model, failed parts are routed back to the first queue to be
reworked. 10% of the parts fail.
– Parts being reworked are given priority in the queue.
• Questions & Bonus
– Where is the bottleneck?
Model 7 - Concepts
• TaskSequence Priority
Model 7
• Purpose
– Learn how to use an Operator to both carry and process flowitems
• Description
– Parts arrive at a queue every 20 seconds exponentially
distributed and need to be carried by the operator to one of 3 machines, whichever is first available.
– The operator needs to setup the part which takes 10 seconds. – The part will then process for 20 seconds on its own.
Model 8 - Concepts
• Send To Port
Model 8
• Purpose
– Learn how to use the “Break To” Requirement field on TaskExecuters.
• Description
– A Source continuously sends Flowitems randomly to 3 Queues. – Flowitems are assigned an itemtype 1,2,3 uniformly distributed. – All three Queues can hold all three itemtypes.
– A Transporter carries Flowitems to three Queues that each hold 1 itemtype.
– These Queues then go to Processors and a Sink. – The Transporter can carry up to 5 items at a time.
– The Transporter should only carry items that have the same itemtypeat any time.
• Questions & Bonus
– Experiment with the other available “Break To” Requirement pick-options. How does the Transporter behave?
Model 9 - Concepts
• TaskExecuter Teams
• TaskSequence Preemption
• Time Tables
Model 9
• Purpose
– More practice working with teams, priorities and preempting
• Description
– A single work cell has 5 machines.
– Each part must be processed at each of the 5 machines – There are 3 operators who work in the cell as a team.
– The operators need to carry each part to the next machine as well as set up the machine for that part.
– Setup times are 5 seconds and process times are 15. – New parts arrive in the system every 25 seconds.
Model 10 - Concepts
• Update Combiner Component List OnEntry
• Excel Imports and Exports ~ Multi-Table
Custom Excel Import/Export
Example:
excelopen(“C:\mybook.xls”); excelsetsheet(“Sheet1”);
double thenum = excelreadnum(1,1); excelwritenum(5,2,thenum)
excelclose(true);
This opens a link to a workbook called “mybook,” and stores a value read from row 1, column 1 from Sheet1, then writes the stored value to row 5, column 2. The link with Excel is then closed.
See alsoexcelimporttable()and excelexporttable()
Rules:
You must call excelopen() once per workbook. Only one workbook can be open at a time. The user must call excelclose() before trying to open another workbook.
Before reading from the open file, excelsetsheet() must also be called to point to the appropriate worksheet. This command may be called several times to point to
different sheets in the active workbook.
See Flexsim’s browser based help for more information. Press the “?” button in the lower left corner of the Automatic Excel Import to open the contextual help.
Model 10
• Purpose
– Learn how to manipulate the Components List table on a Combiner object to do custom packing on the fly
– Learn how to import and use a Source arrival schedule
• Description
– A small distributor has 10 product types that he ships to the same 5 customers.
– Each customer has a different order profile.
– The distributor has a large supply of each of the 10 products so all he has to do is wait for an order to come through the door.
Model 10 Daily Arrival Schedule
1 5 OrderE 14400 Customer 5 1 4 OrderD 10800 Customer 4 1 3 OrderC 7200 Customer 3 1 2 OrderB 3600 Customer 2 1 1 OrderA 0 Customer 1 Quantity ItemType ItemName ArrivalTimeMor e Ad vanc ed Conc ept s and
Models…
Model A1 - Concepts
• Closing and Opening Output/Input Ports
• Message Sending
Basic Object Control
• closeinput(
object
)
,
openinput(
object
)
• stopinput(
object
)
,
resumeinput(
object
)
• closeoutput(
object
), openoutput(
object
)
• stopoutput(
object
), resumeoutput(
object
)
• sendmessage(
toobject, fromobject, parameter1, parameter2,
parameter3 )
Order of Execution
(Messages)
sendmessage() delay OnMessage trigger of receiving object senddelayedmessage() OnMessage trigger of receiving objectModel A1
• Purpose
– Learn how to control product flow and send delayed messages.
• Description
– Assume an infinite supply of A and B components.
– The two components must be glued together with epoxy which takes lognormal(0,2.6,0.8) seconds.
– The assembled parts must wait in a staging area for at least 15 seconds for the epoxy to cure before they can enter the paint booth.
– It takes lognormal(0,2.5,0.5) seconds to paint each part separately.
Model A2 – Concepts
• Abstract Model Application
• Global Variables
• For Loop
Model A2
• Purpose
– Gain experience in building an abstract model
– Learn to write behavior logic in a trigger field using code
• Description
– Items arrive at a warehouse each day to be stored. – Orders arrive at a warehouse each day to be pulled.
– The average number of items and orders received each day is 10, but both are exponentially distributed.
– There are only 5 types of items (and therefore orders) received. The type of received items and orders is uniformly distributed 1 through 5 on a daily basis. – Whenever an order arrives it must search for a matching item and remove it. – Whenever an item arrives it must search for a matching order and remove it. – 1 model time unit = 1 day.
• Questions & Bonus
– How big must the warehouse be, so there is always room to store the itemsreceived each day? – Plot the number of unsatisfied orders each day for an entire year.
Model A3 - Concepts
• Custom TaskSequences
• Global TaskSequences
• Global Variables
TaskExecuter Control
•
Simple Commands
requestoperators(
preempting
taskexecuter, station, involvedobj, nrofops, priority,
)
freeoperators(
taskexecuter, involvedobj
)
•
Cust om Bui lt TaskSe qu enc e
Sample Code for tasksequence
treenode forklift = centerobject(current, 1);
treenode srcin = centerobject(current, 2);
treenode destination = centerobject(current, 3);
treenode item = first(origin);
treenode ts = createemptytasksequence(forklift, 0, 0);
inserttask(ts, TASKTYPE_TRAVEL, srcin, NULL);
inserttask(ts, TASKTYPE_FRLOAD, item, srcin);
inserttask(ts, TASKTYPE_TRAVEL, destination, NULL);
inserttask(ts, TASKTYPE_FRUNLOAD, item, destination);
dispatchtasksequence(ts);
Task Types
TASKTYPE_LOAD: flowitem, pickup
TASKTYPE_FRLOAD: flowitem, pickup, [outputport]
TASKTYPE_UNLOAD: flowitem, dropoff
TASKTYPE_FRUNLOAD: flowitem, dropoff, [inputport]
TASKTYPE_UTILIZE: involved, station, [state]
TASKTYPE_STOPREQUESTFINISH: stoppedobject, NULL
TASKTYPE_TRAVEL: destination, NULL
TASKTYPE_TRAVELTOLOC: NULL, NULL,xloc,yloc,zloc, [endspeed]
TASKTYPE_TRAVELRELATIVE: NULL, NULL,xloc,yloc,zloc, [endspeed]
TASKTYPE_BREAK: NULL, NULL
Global Task Sequences
• Global Task Sequences are reusable task
sequences
• No code is used to define them
• Two steps to create a global task sequence:
– Define references (static and dynamic)
• Objects that are used as involved1 or involved2 in the sequence
– Define the tasks in the sequence
• Call createglobaltasksequence() to use them
Define References
• References are objects that are used as
involved1 or involved2 • Static references are
fixed in the task sequence
– No limit on static references
Define Tasks
• Tasks can be dragged from the list
• Tasks can be added, deleted or reordered with the buttons • Use the fields on the
right to define each task
Model A3
• Purpose
– Learn how to manually build your own tasksequences
• Description
– The model consists of a Source, three Processors in series, and a Sink.
– An operator must pick up a part from the source, carry it to the first processor, be utilized for the process time, carry the part to the next processor, etc. until finally dropping it off at the sink. – Use Global Object Pointers instead of center port connections.
Model A4
• Purpose
– Learn how to create custom built task sequences
• Description
– The model consists of a Source, an Operator, a NetworkNode and a Sink.
– An operator must pick up a part from the source, carry it to the sink and travel to the NetworkNode location after dropping it off at the sink.