Flexsim Basic Course

123
1 Basic Training Course

Transcript of Flexsim Basic Course

Page 1: Flexsim Basic Course

1

Basic Training Course

Page 2: Flexsim Basic Course

2 2

Course Outline

• Chapter 1. Simulation basics

• Chapter 2. Flexsim basics

• Chapter 3. Flexsim terminology

• Chapter 4. Flexsim modeling steps

• Chapter 5. Flexsim object library

• Chapter 6. Commands and constructs

• Chapter 7. Concepts and models

Page 3: Flexsim Basic Course

3

Chapter 1

Simulation Basics

Page 4: Flexsim Basic Course

4 4

What is Simulation?

Simulation is the imitation of a system,

based on knowledge or assumptions

about the behavior of the parts of that

system,

with the purpose of obtaining insight in

the behavior of the whole system.

Page 5: Flexsim Basic Course

5 5

Problems solved with simulation

• Service problems – the need to process customers and their requests at the highest level of satisfaction for the lowest possible cost.

• Manufacturing problems – the need to make the right product at the right time for the lowest possible cost.

• Logistic problems – the need to get the right product to the right place at the right time for the lowest possible cost.

Page 6: Flexsim Basic Course

6 6

Simulation uses • improve equipment utilization

• reduce waiting time and queue sizes

• allocate resources efficiently

• eliminate stock-out problems

• minimize negative effects of breakdowns

• minimize negative effects of rejects and waste

• study alternative investment ideas

• determine part throughput times

• study cost reduction plans

• establish optimum batch sizes and part sequencing

• resolve material handling issues

• study effect of setup times and tool changeovers

• optimize prioritization and dispatching logic for goods and services

• train operators in overall system behavior and job related performance

• demonstrate new tool design and capabilities

• manage day-to-day operational decision making

• plc controls, real-time monitoring

Page 7: Flexsim Basic Course

7 7

Discrete Event Simulation

• Used to model systems which change state at discrete points in time as a result of specific events

• State variables: – machine status (idle, busy, down, etc.)

– queue content

– operator availability, etc.

• System events: – order arrival

– product movement

– machine process start

– machine breakdown, etc.

Page 8: Flexsim Basic Course

8

Chapter 2

Flexsim Basics

Page 9: Flexsim Basic Course

9 9

Flexsim Basics

• A Flexsim model is basically a system of queues, processes, and transportation.

• Processing is simply a forced delay.

• Transportation is the movement of an

entity from one resource to another.

• Queues develop naturally in a model

when upstream arrival rates exceed the

downstream processing rates.

Page 10: Flexsim Basic Course

10 10

Flexsim Basics

• Modeling objects typically include: – fixed resources (i.e. queue, machines)

– shared resources (i.e. operators)

– mobile resources (i.e. forklifts, elevators).

• Entities flow through the model from one fixed resource to another. We call these entities “flowitems” in Flexsim.

• Flowitems hold information (i.e. labels and itemtypes) that can be set and queried in the model to define process times and make routing decisions.

Page 11: Flexsim Basic Course

11 11

Flexsim Basics

• Sometimes an operator must be available before the processing time for a flowitem can start, and sometimes the processing time starts immediately upon entry into the fixed resource.

• Sometimes the flowitems are carried to the

next fixed resource via a mobile resource,

and sometimes they are simply moved

instantaneously.

Page 12: Flexsim Basic Course

12 12

Flexsim Basics

• Most modeling information is defined on the fixed resources in a model. Such as:

– how long to process the flowitem

– where to send the flowitem next

– call a shared resource (operator) for

processing the flowitem

– call a mobile resource to transport the

flowitem to the next fixed resource

Page 13: Flexsim Basic Course

13

Chapter 3

Flexsim Terminology

Page 14: Flexsim Basic Course

14 14

Flexsim Terminology

• model – a collection of object instances representing an actual system -with just enough detail to answer the questions you are concerned with.

• object – a model building block with inherited behavior, and user-definable attributes, variables, and visual properties.

• library – a list of class objects to be used in building a model. Instances are created in the model when an object is dragged from the library icon grid into one of the view windows (orthographic, perspective)

Page 15: Flexsim Basic Course

15 15

Flexsim Terminology

• flowitem – the entities that flow through a model such as products, customers, paperwork, phone calls, etc. are called flowitems.

• FixedResource class – objects which receive and send flowitems – Processor

– Queue

– Conveyor

• TaskExecuter class – shared resources and mobile resources that perform assigned tasks – Operator

– Transport

Page 16: Flexsim Basic Course

16 16

Flexsim Terminology

• task – a single instruction or action to be performed by a TaskExecuter object.

• tasksequence – a group of tasks to be

performed in a set order. A tasksequence is

sent to either a Dispatcher or TaskExecuter

object. A Dispatcher will queue a

tasksequence as necessary and send it to a

TaskExecuter as they become available.

TaskExecuters will execute the tasks of the

tasksequence.

Page 17: Flexsim Basic Course

17 17

Flexsim Terminology

• 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.

• labels – information may also be stored on flowitems (and other modeling objects) in the form of labels. You may define as many labels on a flowitem or object as you would like. Labels have a name and data. The data may be numeric, string, list, or table

Page 18: Flexsim Basic Course

18 18

Flexsim Terminology

• ports – objects have output, input and center ports. Output-to-input port connections define possible flowitem routes. Center port connections are for referencing purposes, and are typically used to define which taskexecuter will be called for processing or transportation. Port connections are made and broken by holding a letter down on the keyboard while click-and-dragging from one object to another.

Page 19: Flexsim Basic Course

19 19

Flexsim Terminology • triggers – when key events occur on an object, a

trigger is fired. The user may specify a variety of things they want to have happen when a trigger fires. There are triggers for when a flowitem enters or exits an object. There are triggers for when a process time finishes or a repair time is complete. Each type of object has a unique set of triggers.

• message – information sent from one object to another. When the message is received, a trigger is fired. A message is sent with a command. Messages may be sent immediately (sendmessage), or after a specified period of time (senddelayedmessage).

Page 20: Flexsim Basic Course

20 20

Flexsim Terminology

• variables – Objects have system variables such as process time, maximum capacity, speed, etc. that can be defined uniquely for each instance. The Parameters window for an object is typically used to edit variables.

• attributes – Objects have physical attributes such as size, location, rotation, 3D shape, color, etc. that may be defined uniquely for each instance. The Properties window for an object is typically used to edit attributes.

• toolbox – a collection of tools that are global in nature and therefore are not associated with any one object in the model.

Page 21: Flexsim Basic Course

21

Chapter 4

Flexsim Modeling Steps

Page 22: Flexsim Basic Course

22 22

Basic Steps of Modeling in Flexsim

1 - Create a layout using library objects

2 - Make port connections

3 - Edit look and behavior of objects

4 - Compile and run the simulation

5 - View the results

Page 23: Flexsim Basic Course

23 23

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.

– the service time at the one and only service window in the post office is lognormal(31,3.1,0.5) seconds.

– if the queue for the service window exceeds 20 people, new arrivals are routed out of the model as “unhappy customers”.

• 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?

Page 24: Flexsim Basic Course

24 24

Model 1 Layout

Page 25: Flexsim Basic Course

25 25

Step 1. Create a layout • 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.

Page 26: Flexsim Basic Course

26 26

To scale or not to scale?

• Flowitems are passed from one object to the next in zero time regardless of where objects are located.

• Convey time depends on the conveyor’s length and speed.

• Transport time between objects depends on the distance between the objects and speed, accel, decel.

• Grid size can be modified in the Settings menu.

• Length units are “user-definable” – consistency is the key!

• The VisualTool object can be used to display a CAD drawing as the floor plan for the model.

• After scaling the imported image/shape, the modeling objects can be placed on the layout and sized to match.

Page 27: Flexsim Basic Course

27 27

Mouse operations

• View Window: – 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

– X,Y,Z rotation: right click-drag on object

– Resize X and Y: left click-drag on yellow dot

– Resize Z: right&left click-drag on yellow dot (or use scroll wheel when object is highlighted)

Page 28: Flexsim Basic Course

28 28

Highlighting and Selecting Objects

• Only one object can be highlighted (yellow box) in a given view window.

• Multiple objects can be selected (red box) across views using shift-click-drag and/or ctrl-click-drag.

• Group editing can be performed on selected objects using the “Edit Selected Objects” menu on the Model View windows.

Page 29: Flexsim Basic Course

29 29

Step 2. Make port connections • While pressing the “A” key, click-and-drag port connections

between the objects.

• These output to input port connections are needed between the

objects in your model that send and receive flowitems.

Page 30: Flexsim Basic Course

30 30

The purposes of port connections

• Output to input port connections are typically used for passing flowitems.

• Center port to center port connections are typically used for calling operators and transporters.

• Center port connections are a handy way to reference other objects when writing code (i.e. outobject(current,1)

references the object connected to output port 1)

• Output to input port connections provide automatic “handshaking” that is used in passing flowitems – Flowitems are either pushed or pulled when port

connections are open at both ends.

– Opening ports may trigger events on the connecting objects (useful in developing object behavior).

Page 31: Flexsim Basic Course

31 31

Keys used for port connections

A

Q W

S

Disconnect

Connect

Outputs to Inputs Center to Center

Page 32: Flexsim Basic Course

32 32

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.

Page 33: Flexsim Basic Course

33 33

Viewing port connections

• Display of port connections can be turned off by using the “Settings” option in the Model View.

• The size of the ports can also be adjusted with the “Settings” option (although not recommended)

Page 34: Flexsim Basic Course

34 34

Full Port Display

• Input ports on left

• Output ports on right

• Center ports on

bottom

• Ports are numbered

top to bottom

• “V” click to display

input and outputs

• “C” click to display

center ports

Page 35: Flexsim Basic Course

35 35

Step 3. Edit the objects

• Parameters Window – Double click (or right click then choose Parameters)

– Used to edit object specific stuff

• Properties Window – Right click then choose Properties

– Used to edit and view general info on all objects

• Model Tree View – All objects in the model listed in a hierarchal tree.

– Contains the underlying data structure for an object

– ALL info is contained in the tree (all other gui’s are simply filters on the tree)

Page 36: Flexsim Basic Course

36 36

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.

• Apply will accept changes

• OK will accept changes and close the window

• Cancel will close the window without accepting changes

• Properties button opens the Properties Window

Page 37: Flexsim Basic Course

37 37

Parameter tabs • Parameters are grouped into tab pages by category

• Every fixed resource object will have a “Flow”, and a

“Triggers” tab (although some objects will have more

triggers than others)

Page 38: Flexsim Basic Course

38 38

Understanding the Pick List Combo Box

• The pick list

• The code template (friendly editing)

• The code edit (may use Flexscript and C++)

Page 39: Flexsim Basic Course

39 39

Code Template

• Brown text may be replaced with any valid Flexscript.

• These templates

can be customized

through the Code

Edit window (to be

taught later).

Page 40: Flexsim Basic Course

40 40

Properties Window

• Every object has the same set of properties tabs

• Visual Tab – Look and size

• General Tab – Port connections

– Display switches

• Labels – User defined attributes

• Statistics – Throughput, states,

queuing, and stay times

– Graphs, charts, readouts

Page 41: Flexsim Basic Course

41 41

Step 4. Compile and Run the simulation

• Compile the model (create an executable runtime)

• Reset, Run

• Control run speed with the slide control (has no effect on the simulation results)

• Experimenter is used to define run length, number of iterations, and number of scenarios

Page 42: Flexsim Basic Course

42 42

Step 5. View the results

• Create a Standard Report or State Report using the “Stats” menu

• Other reporting features to be discussed later: – VisualTool

• Dynamic text

– Recorder • Time plots, histograms,

pie charts, historical and statistical tabular data

– Triggers writing to GlobalTables

– Object Properties > Statistics Tab

Page 43: Flexsim Basic Course

43 43

Standard Report

• Display a tabular report (csv file in Excel) for all objects in model (or just those objects selected red).

• Choose from a list of standard system variables to include in report.

• Or type in your own variables to add to the report

Page 44: Flexsim Basic Course

44 44

Standard Report View

Page 45: Flexsim Basic Course

45 45

Flexsim State Report

• Percentage of total simulation time an object was in each of its states.

• CSV format (default viewer is Excel).

• State profile is listed for each object currently selected in the model.

Page 46: Flexsim Basic Course

46 46

Model 2

• Purpose – learn how to duplicate objects

– see affects of adding a second service window

– introduction to the “Send to port” field

• Description – add another service window to the post office

• Questions – answer the questions asked in model 1

– 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?

Page 47: Flexsim Basic Course

47 47

Chapter 5

The Flexsim Object Library

Page 48: Flexsim Basic Course

48 48

Flexsim Family Tree

Page 49: Flexsim Basic Course

49 49

Flexsim Standard Objects

• Flexsim has 25 objects in the entire library

• Your ability to model will be determined by how well you understand these basic 25 objects and their 3 superclasses

Page 50: Flexsim Basic Course

50 50

FixedResource superclass

• FixedResource objects are the backbone of a simulation model. They define the flow of the model. Since flow is defined by the connecting of output to input ports, FixedResources are always connected together using the “A” key.

• FixedResources can: – push or pull flowitems

– process flowitems (forced delay)

– queue up flowitems (accumulate up to maxcontent)

– call for an operator to be utilized

– call for a transport to carry flowitems to next resource

Page 51: Flexsim Basic Course

51 51

Dispatcher superclass

• The Dispatcher receives tasksequences and either queues them up, OR dispatches the tasksequences immediately to downstream Dispatchers and/or TaskExecuters.

• A tasksequence is a list of tasks that must be executed in a defined order one after the other.

• Common tasks are actions such as travel, load, unload, utilize, sendmessage, delay and break.

• One tasksequence may preempt another tasksequence part way through the current one’s list of tasks. The preemption can either temporarily interrupt the current tasksequence or permanently destroy the current tasksequence and all sequences in queue.

• Tasksequences are created and dispatched automatically when the “Use Transport” or “Use Operator” boxes are checked on a FixedResource type object.

• Tasksequences can also be created and dispatched using commands in triggers or elsewhere in your model.

Page 52: Flexsim Basic Course

52 52

TaskExecuter superclass

• TaskExecuters are subclasses of the Dispatcher and therefore know how to receive, queue up, and dispatch tasksequences.

• In addition, TaskExecuters have the ability to

execute the tasksequences that they receive.

• The Operator, Transporter, Elevator, Robot,

Crane, and ASRSvehicle are all subclasses of

the TaskExecuter and therefore have similar

functionality.

Page 53: Flexsim Basic Course

53 53

Model 3 • Purpose

Simple model which uses several objects in the library

• Description: A part enters a Separator every 20 seconds where it is split into 3

separate parts. 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.

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 process can complete on its own in 5 seconds. A Transporter then picks it up and takes it to a Rack where it is stored.

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.

Page 54: Flexsim Basic Course

54 54

Model 3 Layout

Page 55: Flexsim Basic Course

55 55

Model 3 Follow-up Work

Once you have finished the model, do the following:

• Create a Network path for the transport to follow when travelling

between the MultiProcessor and the Rack.

• Use a 3D status pie chart to show the state profile for the operator.

• Use 3D text to display the content of the Rack.

• View the model in the perspective view and experiment with

different background colors.

• Learn how to apply new 3D shapes to the objects in your model.

• Move the objects associated with each of the three flows into a

separate VisualTool to create an hierarchal model.

Page 56: Flexsim Basic Course

56 56

Connecting Dispatchers and TaskExecuters

Page 57: Flexsim Basic Course

57 57

NetworkNode

• A NetworkNode is used to define the path a TaskExecutor will follow when executing its travel tasks.

• A path is made up of a group of NetworkNodes

connected together by using the “A” key.

• At least one NetworkNode needs to be connected to

each load and unload station (FixedResource) using the

“A” key.

• A Task Executor is assigned to a path by connecting it

to any NetworkNode in the path using the “A” key.

Page 58: Flexsim Basic Course

58 58

Connecting NetworkNodes

• Click-and-drag a connection while pressing the “A” key

• When connected you will see a green path between the nodes denoting travel is allowed in both directions.

Page 59: Flexsim Basic Course

59 59

Connecting Paths to the Model

• Click-and-drag a connection while pressing the “A” key between the NetworkNode and the object where the load takes place.

• A blue line will show the connection. The line does not connect to any port.

Page 60: Flexsim Basic Course

60 60

Connecting a TaskExecutor to a Path

• 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.

Page 61: Flexsim Basic Course

61 61

Single Direction Paths

• A path can be restricted to travel in a single direction by pressing the “Q” key and clicking-and-dragging in the direction you want to disallow travel.

• A red line (right side rule) will show the restricted direction.

Page 62: Flexsim Basic Course

62 62

Non-Passing Paths

• A non-passing path can be defined by using the “A” key and click-and-dragging between two nodes that are already connected.

• Non-passing path segments turn a yellow color.

No traveling

Travel but no passing

Page 63: Flexsim Basic Course

63 63

Path Spline Points

• Every path has a spline point in the center of the path by default.

• Spline points allow paths to be curved.

• Add spline points by pressing “X” and clicking on an existing spline point.

• Delete spline points by selecting them and pressing “Del”

Page 64: Flexsim Basic Course

64 64

Hide Splines, Paths and NetworkNodes

• The display options for a path system can be toggled by holding the “X” key down and then clicking on any NetworkNode in the path system.

Page 65: Flexsim Basic Course

65

Chapter 6

Basic Modeling Functions and Logic Statements

Page 66: Flexsim Basic Course

66 66

Available Help – Hints

– Commands

– Sample Models (Help menu)

– Existing picklist options

– Any C++ book (if you’re so inclined)

Page 67: Flexsim Basic Course

67 67

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)

• numbers are double precision unless otherwise specified.

• 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.

• curly braces (ie { }) are used to define a block of statements.

• to comment out the rest of a line use //

• don’t use spaces or special characters in name definitions (_ is ok).

• names may include numbers, but may not begin with a number.

Page 68: Flexsim Basic Course

68 68

Math Operators

• x+y

• x-y

• x*y

• x/y

• sqrt(x)

• pow(x,y)

• round(x)

• frac(x)

• fmod(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 (xy)

x rounded to the nearest integer

returns the decimal portion of x

returns the remainder of x/y

Page 69: Flexsim Basic Course

69 69

Comparing

• x > y

• x < y

• x >= y

• x <= y

• x == y

• x != y

• comparetext(string1,string2)

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

x not equal to y

string1 matches string2

Page 70: Flexsim Basic Course

70 70

Relating

• &&

• ||

• !

• min(x,y)

• max(x,y)

logical AND

logical OR

logical NOT

returns minimum of x and y

returns maximum of x and y

Page 71: Flexsim Basic Course

71 71

Updating

• x = y

• x += y

• x -= y

• x *= y

• x /= y

• x ++

• x --

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

add 1 to x

subtract 1 from x

Page 72: Flexsim Basic Course

72 72

Variable Types

• int

• double

• string

• fsnode*

integer

double precision

text string

pointer to a Flexsim tree node

Page 73: Flexsim Basic Course

73 73

Declaring and Setting Variables

• int index = 1;

• double weight = 175.8;

• string category = “groceries”;

• fsnode* forklift = centerobject(current,1);

Page 74: Flexsim Basic Course

74 74

What is a Node?

• Basic data structure of Flexsim is a hierarchal tree

– main (model and project related objects and data)

– view (gui related objects and picklists)

• The node is the basic building block of a tree

• Nodes hold all the information behind the scenes

for objects, gui’s and data.

Page 75: Flexsim Basic Course

75 75

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

Page 76: Flexsim Basic Course

76 76

Node Symbols

Standard Folder

Object

Object data

Function (C++)

Function (FlexScript)

Page 77: Flexsim Basic Course

77 77

Sample Model Tree

Page 78: Flexsim Basic Course

78 78

Basic Object Referencing

• current

• item

• rank(node,ranknum)

• inobject(object,portnum)

• outobject(object,portnum)

• centerobject(object,portnum)

• model()

the current object

the involved flowitem

rank(current,3)

inobject(current,1)

outobject(current,1)

centerobject(current,1)

model()

Page 79: Flexsim Basic Course

79 79

Basic Object Attributes

• getname( object )

• setname( object, “name” )

• getitemtype( object )

• setitemtype( object, num)

• setcolor( object, red, green, blue )

• colorred( object ) – blue,green,random...

Page 80: Flexsim Basic Course

80 80

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 )

Page 81: Flexsim Basic Course

81 81

Basic Object Statistics

• content( object )

• getinput( object )

• getoutput( object )

• int inventory = content(current);

• int produced = getoutput(current);

Page 82: Flexsim Basic Course

82 82

Object Labels • syntax

– getlabelnum( object, “labelname” )

– setlabelnum( object, “labelname” , value )

– getlabelstr( object, “labelname” )

– setlabelstr( object, “labelname” , string )

– label( object, “labelname” )

• examples

– getlabelnum( item, “serialnumber” )

– setlabelnum( item, “serialnumber”, 5 )

– getlabelstr( current, “category” )

– setlabelstr( current, “category”, “groceries” )

– inc( label(item, “stepnum”), 1 ) only works with number data nodes

Page 83: Flexsim Basic Course

83 83

Global Tables

• gettablenum( “tablename”, rownum, colnum )

• settablenum( “tablename”, rownum, colnum, value )

• gettablestr( “tablename”, rownum, colnum )

• settablestr( “tablename”, rownum, colnum, string )

Page 84: Flexsim Basic Course

84 84

Logical ‘if’ Statement

if (test expression)

{

code block

}

else

{

code block

}

if (content(item) == 2)

{

colorred(item);

}

else

{

colorblack(item);

}

Page 85: Flexsim Basic Course

85 85

Logical ‘while’ Statement

while (test expression)

{

code block

}

while (content(current) > 0)

{

destroyobject(last(current));

}

Page 86: Flexsim Basic Course

86 86

for (start expression;

test expression;

count expression)

{

code block

}

for (int index = 1;

index <= content(current);

index++)

{

colorblue(rank(current,index));

}

Logical ‘for’ Statement

Page 87: Flexsim Basic Course

87 87

switch ( switchvariable )

{

case casenum:

{

code block

break;

}

default:

{

code block

break;

}

}

int type = getitemtype(item); switch (type) { case 1: { coloryellow(item); break; } case 5: { colorred(item); break; } default: { colorgreen(item); break; } }

Logical ‘switch’ Statement

Page 88: Flexsim Basic Course

88 88

Code Exercise 1

• Purpose – Gain experience in writing C++ code in the Code Edit

windows.

– Introduction to PROSESTART and PARAMSTART statements and how they define the Template windows.

– Introduction to the bernoulli command.

• Description – See layout slide for model description. – Using the “Send To Port” field of the Conveyor, send

30% of the flowitems to port 1 and 70% to port 2.

Page 89: Flexsim Basic Course

89

Code Exercises 1,2,3 Layout

Page 90: Flexsim Basic Course

90 90

Code Exercise 2

• Purpose – Learn how to both set and read the itemtype of a flowitem

using C++

• Description – See layout slide for model description.

– 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 Conveyor, send flowitems with itemtype 7 to port 1, and those with itemtype 3 to port 2.

• Questions – Can you change the color of the Flowitems based on their

itemtype using code?

Page 91: Flexsim Basic Course

91 91

Code Exercise 3 • Purpose

– Learn how to both set and read the labels on a flowitem using C++

• Description – See layout slide for model description.

– 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

• 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

itemtype using code?

Page 92: Flexsim Basic Course

92 92

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.

• Questions

– Can you change the 3D shapes of the boxes on the pallet with the setobjectshapeindex() command?

Page 93: Flexsim Basic Course

93

Exercise 4 Layout

Page 94: Flexsim Basic Course

94 94

Chapter 7

Concepts and Models

Page 95: Flexsim Basic Course

95 95

Modeling Concepts

• FlowItem Bin

• Arrivals (interarrival time, schedule,

sequence, initial stock)

• Labels and itemtypes

• GlobalTables

• Distributions (empirical, continuous)

Page 96: Flexsim Basic Course

96 96

Modeling Concepts

• Push versus pull

• MTBF/MTTR

• Time Tables

• Experimenter and Optimizer

• Manual tasksequence creation

• 3D shapes and animation

• Importing CAD layouts

Page 97: Flexsim Basic Course

97 97

Modeling Concepts

• Data import and export

• Data capturing and reporting

• Fly through presentations

• Debugging tips

• Global object pointers

• Flow control (close and open ports)

• Messaging (delayed messages)

Page 98: Flexsim Basic Course

98 98

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 component 2. Components will go to the first available tester.

– Service times are all between 120 and 150 seconds uniformly distributed.

• Questions – Are all testers equally utilized?

– Can you model this with push or pull?

– Try assigning colors to the itemtypes.

Page 99: Flexsim Basic Course

99

Model 4 Layout

Page 100: Flexsim Basic Course

100 100

Model 5 • 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 every 30 seconds exponentially distributed.

There are four part types distributed as follows: 20%, 30%, 40%, 10%.

– The four part types are each processed on one of four dedicated machines. 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 – Where is the bottleneck?

– Can you change the color and shape of failed parts?

Page 101: Flexsim Basic Course

101 101

Model 5 Layout

Page 102: Flexsim Basic Course

102 102

Model 6 • Purpose

– Learn how to us 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.

– The operator needs to setup the part which takes 10 seconds.

– The part can then run for 20 seconds on its own.

– When the part finishes, it will leave the system.

– One operator will run all three machines.

• Questions – See if you can get the operator to stay for setup once he has

carried the product to the machine.

Page 103: Flexsim Basic Course

103

Model 6 Layout

Page 104: Flexsim Basic Course

104 104

Model 7 • 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 itemtype at any time.

• Questions

– Experiment with the other available “Break To” Requirement pick-options. How does the Transporter behave?

Page 105: Flexsim Basic Course

105

Model 7 Layout

Page 106: Flexsim Basic Course

106 106

Model 8 • Purpose

– More practice working with Operators, 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.

• Questions – What’s the throughput rate per hour?

– Experiment with priorities and preempting to try and improve the throughput rate.

– Assign each operator to a different timetable so their breaks and lunches are staggered.

Page 107: Flexsim Basic Course

107

Model 8 Layout

Page 108: Flexsim Basic Course

108 108

Model 9 • Purpose

– Small example of using a Global Table to define product routings.

– Learn how to use a label to keep track of what step its on.

• Description – 3 different products (uniform) enter a 5 station work cell.

– 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.

– Use a single Queue who’s output ports are connected to each of the 5 stations and to a Sink. Each of the five stations have their output port also connected to the input ports of the Queue.

• Questions – Can you change all flowItems in the model to a common color

depending on step?

Page 109: Flexsim Basic Course

109

Model 9 Layout

Page 110: Flexsim Basic Course

110 110

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 distributer 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.

– Products are placed on a pallet and then conveyed out.

– Use the next two tables to build the model.

• Questions – Can you think of other uses for the Combiner?

– If time permits, try importing the tables from Excel.

Page 111: Flexsim Basic Course

111

Model 10 Layout

Page 112: Flexsim Basic Course

112 112

Model 10 Order Table

0 0 3 1 1 prod 10

2 1 4 2 1 prod 9

0 3 3 3 2 prod 8

3 2 2 0 0 prod 7

0 2 0 4 2 prod 6

1 0 3 3 3 prod 5

2 3 1 2 1 prod 4

2 1 0 1 0 prod 3

1 2 1 0 2 prod 2

4 1 3 2 1 prod 1

Customer 5 Customer 4 Customer 3 Customer 2 Customer 1

Page 113: Flexsim Basic Course

113 113

Model 10 Daily Arrival Schedule

10 5 E 14400 Customer 5

10 4 D 10800 Customer 4

10 3 C 7200 Customer 3

10 2 B 3600 Customer 2

10 1 A 0 Customer 1

Quantity ItemType ItemName ArrivalTime

Page 114: Flexsim Basic Course

114 114

Model 11 • Purpose

– Gain experience in building an abstract model

– Learn to write some C++ in a trigger field

• 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 – How big must the warehouse be, so there is always room to store the items

received each day?

– Plot the number of unsatisfied orders each day for an entire year.

– What’s the average number of days an order waits to be satisfied?

Page 115: Flexsim Basic Course

115 115

Model 11 Layout

Page 116: Flexsim Basic Course

116 116

TaskExecuter Control

• requestoperators( taskexecuter, station, involvedobj, nrofops, priority, preempting )

• freeoperators( taskexecuter, involvedobj )

• createemptytasksequence( taskexecuter, priority,

preempting)

• inserttask(tasksequence, tasktype, involved1, involved2,

parameter1, parameter2, parameter3 )

• dispatchtasksequence( tasksequence )

Page 117: Flexsim Basic Course

117 117

Sample code for tasksequences fsnode *forklift = centerobject(current,1);

fsnode *origin = centerobject(current,2);

fsnode *destination = centerobject(current,3);

fsnode *item = first(origin);

fsnode *ts = createemptytasksequence(trans,0,0);

inserttask(ts, TASKTYPE_TRAVEL, origin, NULL);

inserttask(ts, TASKTYPE_FRLOAD, item, pickup);

inserttask(ts, TASKTYPE_TRAVEL, destination, NULL);

inserttask(ts, TASKTYPE_FRUNLOAD, item, destination);

dispatchtasksequence(ts);

Page 118: Flexsim Basic Course

118 118

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

TASKTYPE_DELAY: NULL, NULL, delaytime, state

TASKTYPE_SENDMESSAGE: receiver, NULL, param1,param2,param3

TASKTYPE_MOVEOBJECT: flowitem, container, port

TASKTYPE_DESTROYOBJECT: object, NULL

Brown parameters are required, Gray parameters are optional

** use profiletasksequence(ts) to print to console full description of ts

Page 119: Flexsim Basic Course

119 119

Model 12 • 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.

• Questions – How many operators does it take to make 1000 pieces a day?

Page 120: Flexsim Basic Course

120 120

Model 12 Layout

Page 121: Flexsim Basic Course

121 121

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 )

• senddelayedmessage( toobject, delaytime, fromobject, parameter1, parameter2, parameter3 )

• stopobject( object ), resumeobject( object )

• moveobject( object, containerobject )

Page 122: Flexsim Basic Course

122 122

Model 13 • 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.

– After each part is painted and exits the paint booth, the booth must be purged for 3 seconds before another part can enter.

• Questions – What is the average and maximum time a part waits in queue?

Page 123: Flexsim Basic Course

123

Model 13 Layout