Micro Computer Simulation Micro Saint for Windows MANUFACTURING MODEL DEVELOPMENT Model Description This model illustrates many of the key concepts used in simulating a manufacturing production line. The following exercises will build the model in several stages beginning with the basic task network and timing information for each task. We will then add task sequence information and assign one of two product types to each product entity that is generated. In the next stage we will add just-in-time logic to ensure that no task begins until the following task has nothing in its queue. Product entities are essentially pulled through the network from the end. Next, we will add a probability that some products will need to be reworked after going through the "Test" station. The "Rework" task will rout products back to the "Test" station, to the "Assembly 2" station, or all the way back to "Assembly 1". Products that need to be reworked will have priority over the other products for selection from the queues. In addition, when a product is sent back to "Assembly 2", if there is a product currently being worked on, that task is suspended and the rework is performed immediately. After the rework has been completed, the work on the product that was suspended is resumed. Simulation Concepts 1. Assembly line process with rework loop. 2. Just-in-time logic. 3. Entities selected from a queue based on priority rules rather than first-in first-out. 4. Suspending and resuming task execution. Micro Saint Sharp Features Covered Multiple Decision Types For generating multiple entities to execute the network. random() Built-in function for generating random numbers between 0 and 1. User-defined Functions For generating a product type value for each entity and to suspend and resume task execution. Job Queues Sorted on a priority value. Snapshots of Execution To collect information on product assembly time. suspend() Built-in function to suspend task execution for a particular entity. resume() Built-in function to resume a suspended task for a particular entity. Manufacturing Model 1 Micro Computer Simulation Micro Saint for Windows MANUFACTURING MODEL DEVELOPMENT - EXERCISE # 1 Exercise Description In this exercise, we will build the basic assembly line task network adding timing information for each task. The timing information for task 2 is variable depending on the product type value contained in a variable array named "prodtype". Elements in the array will contain a value of 1 or 2 to indicate the product type for each entity. This assignment will be made in the next exercise. Simulation Concepts 1. Development of a task network showing basic task sequence and the location of job queues. 2. Task timing information including mean time and standard deviation for a normal distribution. Micro Saint Sharp Features Covered Graphical User Interface Tools For developing the network diagram. Task Description Screen For entering task names and timing information. Manufacturing Model 2 Micro Computer Simulation Micro Saint for Windows MANUFACTURING MODEL Exercise #1- Build the Network - Add Timing Data Build the Network To build this model, you'll first create a network diagram which represents a production line. Two different product orders can be generated. The product is assembled in two steps using a Just-In-Time (JIT) or pull assembly process. Once assembled the product is tested, then packed and shipped. 1. From the Micro Saint Sharp File menu, select the New option to begin building this model. 2. Use the graphical model development tools on the blank Network Diagram window to build the task network. Place all of the tasks as shown in the diagram below. 3. Draw paths between the following tasks: From Task# 1 1 2 3 4 To Task# 1 2 3 4 5 4. Double click Task 1 to open its description window, enter the task name shown above, and then enter the task names for the other tasks in the network diagram. NOTE: You can use the left-pointing and right-pointing arrows at the top of the window to go to previous and next task windows. 5. Close the interface after entering all the task names (To close the interface, click on the “X” in the upper right hand corner of the dialog window). Task Timing The timing for all of the tasks in the network use a Normal Distribution Type. Since this is the default type, you won't have to change it. The timing parameters for all of the tasks are fixed values with the exception of Task 2. Task 2 uses a value based on the type of product that is being built. To define this, we'll use logical if-then-else statements as the mean and standard deviation expressions. 1. Add the entity attributes used up to this point (Right click on the Entity Attributes top node in the Tree View window and choose “Add Entity Attribute” from the menu) . The table below gives the information about each one. Manufacturing Model 3 Micro Computer Simulation Micro Saint for Windows Name ProdType Type Integer 2. Open each task and enter the timing expressions shown below in the appropriate expression field: Task # 1 2 Mean Time return 0.0; if (Entity.ProdType == 1) {return 5;} else {return 7.0;} Standard Deviation return 0.0; if (Entity.ProdType == 1) {return .5;} else {return 2.0;} 3 return 9.0; return 2.0; 4 return 14.0; return 3.0; 5 return 8.0; return 1.0; 3. Close the interface by clicking the X in the upper right hand corner of the dialog window. Manufacturing Model 4 Micro Computer Simulation Micro Saint for Windows MANUFACTURING MODEL DEVELOPMENT - EXERCISE # 2 Exercise Description In this exercise we will enter task sequence logic and we will build a user-defined function to randomly generate a product type value for each entity. At this point in the model development, task sequencing is very simple since only the first task has anything other than a single possible following task. The first task has a "Multiple" decision type. It is followed by itself as long as the number of entities is less than the variable value for "maxorders." This value will be established in another exercise. Each time task 1 executes it will also be followed by task 2. The user-defined function called "GenType" will assign a product type value of 1 to 40% of the products generated and a value of 2 to the other 60%. Product type values for each entity are stored in an entity attribute named "ProdType." Two variables, "Prod1" and "Prod2" keep track of how many of each type are generated. Simulation Concepts 1. Probabilistically assigning a value to entities that execute the task network. 2. Conditional routing of entities through the task network. 3. Generating multiple entities to execute the task network. Micro Saint Sharp Features Covered Entity.Tag A Micro Saint Sharp system variable, the value of which stays with (identifies) entities that travel through the task network. Array variables Used to keep track of entities. Model.Random() Micro Saint Sharp built-in function that generates a random number between 0 and 1. This number is used in logical expressions to probabilistically assign product type values. Manufacturing Model 5 Micro Computer Simulation Micro Saint for Windows MANUFACTURING MODEL Exercise #2- Task Sequence Logic - Multiple Product Types Task Sequence Logic All tasks have only one following task except Tasks 1 and 5. Task 1 is a spinner task and Task 5 has no following tasks. Next you'll enter expressions to define the task sequencing for Task 1. 1. To enter information about Task 1, double click its node in the network diagram. 2. To generate a new tag identifier for each order, place the typing cursor in the ending effect field of the Main tab and type the following expression: Entity.Tag ++; 3. Click on the “Paths” tab to edit the branching logic 4. The routing condition for Task 2 stays as the default expressions ("return true") so you don't have to change it. Change the expression in the "Decision Code" for Task 1 to the expression shown below: Frame Heading: Generate Orders (1) -> Assembly 1 (2) Generate Orders (1) -> Generate Orders (1) Decision Code: return true; return Entity.Tag < MaxOrders; 5. Close the interface by clicking the X in the upper right corner of the dialog window. Multiple Product Types There will be two product types developed on the manufacturing line: Type1 and Type2. Each order has a 40% probability of being assigned as a Type1 and a 60% probability of being assigned Type2. We will use a random number to probabilistically assign a type to an order that is received. Since all orders are assigned a product type, we'll add a function to the Function Library which assigns the "type" to the current tag. The function also increments the appropriate counter variable ("Prod1" or "Prod2") to keep track of how many of each type have been generated. Right click on the “Function” top node in the Tree View window and select “Add Function” to add a function. Name the function “GenType”, GenType assigns a product type to the current order (Tag entity attribute) using the expression Entity.ProdType = 1 or 2. Enter the following set of expressions in the function expression field to determine what type of product is being produced: x = Model.Random(); if (x <= .4) {Entity.ProdType = 1;} else {Entity.ProdType = 2;} if (Entity.ProdType == 1){Prod1 ++;} else {Prod2 ++;} 1. Close the interface. Manufacturing Model 6 Micro Computer Simulation Micro Saint for Windows 2. Open Task 1 and enter the GenType function call in the ending effect (after "Entity.Tag ++; ") to assign a type to each order as it is generated. The ending effect expressions for Task 1 should then be: Entity.Tag ++; GenType(); 3. Add the variables used up to this point (Right click on the Variables top node in the Tree View window and choose “Add Variable” from the menu) . The table below gives the information about each one. Name x Prod1 Prod2 MaxOrders Type Floating Point Integer Integer Integer 4. Save the model Manufacturing Model 7 Micro Computer Simulation Micro Saint for Windows MANUFACTURING MODEL DEVELOPMENT - EXERCISE # 3 Exercise Description In this exercise, we will enter the logic to control the flow of entities through the network. To have the model behave in a just-in-time fashion, we will use release condition rules and task's beginning and ending effects. The basic rule is that a task cannot execute unless there is nothing in the queue that is in front of the next task and that an operator is available at the current task. This means that queues will never have more than one entity waiting to execute a task at a time. However, the model is built to accommodate allowing more than one thing in the queues if the user desires. In this version of the model, we also only have one operator at each task or assembly process station. The number of operators could also be changed. As tasks begin execution, the variable representing the number of operators at that station is decremented by one. When the task completes execution, the operator variable is incremented by one. In the opposite way, when an entity enters a queue, the value of a variable representing the current size of the queue is incremented by one. When an entity leaves a queue to execute a task the value of the queue size variable is decremented. We will establish the number of operators for each task in the model and the number of orders to be processed (MaxOrders) as a scenario event in the Event Queue at time 0.0. For this version we will have only one operator at each station and we will generate only 50 orders. Also, at the beginning of task 2, we set an entity attribute called “ProdTime” equal to the simulation clock. At the end of the last task we reset the value of the entity attribute to the new clock time minus the original value, thus calculating a total assembly time for that product. To capture all of the assembly times, we assign the "Entity.ProdType" array element to a variable called "AssyTime". Then we store the value of the "AssyTime" variable each time the last task executes. We will also store the final values for the "Prod1" and “Prod2" variables at the end of the simulation run. Simulation Concepts 1. Pulling entities through the task network from the back end to simulate a just-in-time operation. 2. Establishing rules for task execution based on the size of queues in the model and the availability of operators. 3. Keeping track of the time it takes for each entity to travel through the task network. Micro Saint Sharp Features Covered Release Conditions Rules that allow a task to execute. Beginning Effects Expressions that change variable values as a result of a task beginning execution. Ending Effects Expressions that change variable values as a result of a task completing execution. Entering Effects Expressions that change variable values as a result of an entity entering a job queue. Manufacturing Model 8 Micro Computer Simulation Micro Saint for Windows Departing Effects Expressions that change variable values as a result of an entity leaving a queue to execute a task. Array Variables Used to keep track of the total model execution time for each entity that is generated. Snapshots of Execution Variable values stored in a results file at specified times during model execution. Manufacturing Model 9 Micro Computer Simulation Micro Saint for Windows MANUFACTURING MODEL Exercise #3- Controlling Product Flow (JIT) - Collecting Data Controlling Product Flow (JIT) Now, you will add control logic to the model to define how a JIT or pull process used to assemble the product. 1. Open task 2 through 5 and add expressions to flag the operators as being busy when the operator works on a product and free when the operator finishes. This can be accomplished using the expressions below: Task# 2 3 4 5 Beginning Effect Op2 --; Op3 --; Op4 --; Op5 --; Ending Effect Op2 ++; Op3 ++; Op4 ++; Op5 ++; NOTE: Use the "Copy" and "Paste" options on the Edit menu to reduce the amount of typing. 2. Define the release conditions such that no entity can be released into the next task until the queue for that task is empty. This defines that an operator at that station must be available to perform the task and also looks ahead to the next task to see if any products are already in the next task's queue. This is accomplished in the following manner: Task# 2 3 4 5 Release Condition return ((Op2 > 0) && (Q3Size < 1)); return ((Op3 > 0) && (Q4Size < 1)); return ((Op4 > 0) && (Q5Size < 1)); return (Op5 > 0); 3. Add Queues to tasks 2,3,4 and 5 by opening the task description dialog, clicking on the “Queue” tab and changing the queue type from “None” to “FIFO” 4. Add expressions to track the number of orders waiting in queues for tasks 3, 4, and 5. This can be accomplished using the expression below: Task# 3 4 5 Entering Effect Q3Size ++; Q4Size ++; Q5Size ++; Departing Effect Q3Size --; Q4Size --; Q5Size --; 5. Close the interface by clicking the x in the upper right corner of the dialog window. 6. Add a scenario event which sets up the initial conditions of the model (the number of operators and maximum number of orders for the simulation). Enter the following expressions in the Code field: Manufacturing Model 10 Micro Computer Simulation Micro Saint for Windows Op2 = 1; Op3 = 1; Op4 = 1; Op5 = 1; MaxOrders = 50; 7. Close the interface by clicking the x in the upper right corner. Collecting Data The data we're interested in collecting on the model is how many Type1 and Type2 products were produced and how long it takes to manufacture either type of product. To find out how long each order takes, we'll have to add some expressions to the model and create an entity attribute that will calculate how long it takes to produce each order. 1. Add a snapshot that stores the value of the variables "Prod1" and "Prod2" at the end of the run by selecting Snapshot in the Tree View window. Right mouse click and select “Add Snapshot”. 2. Double click on the new snapshot. Click in the Name: field and enter ProductTypes. 3. Click on the “Expressions” tab. Click the Add button. Enter the variable Prod1 in the Expression: field. 4. Click the Add button. Select “Expression2” in the Expressions list box. Enter the variable name Prod2 in the Expression: field. 5. Close the interface by clicking on the x in the upper right corner. 6. To track each order, open Task 2 and add the following beginning effect expression: Entity.ProdTime = Clock; 7. To calculate the time it takes for that product to be produced, open task 5 and add the following ending effect expressions: Entity.ProdTime = Clock - Entity.ProdTime; AssyTime = Entity.ProdTime; 8. Close the interface by clicking the x in the upper right corner. 9. Add a snapshot to store the values of "Entity.Tag" and "AssyTime" at the end of task 5 by selecting Snapshot in the Tree View window. Right mouse click and select “Add Snapshot”. 10. Double click on the new snapshot. Click on the “Expressions” tab. Click the Add button. Enter the variable Entity.Tag in the Expression: field. 11. Click the Add button. Select “Expression2” in the Expressions list box. Enter the variable name AssyTime in the Expression: field. 12. Close the interface by clicking on the x in the upper right corner. Manufacturing Model 11 Micro Computer Simulation Micro Saint for Windows 13. Add the following entity attributes: Name ProdTime Type Floating Point 14. Add the following variables: Name Op2 Op3 Op4 Op5 Q3Size Q4Size Q5Size AssyTime Manufacturing Model Type Integer Integer Integer Integer Integer Integer Integer Floating Point 12 Micro Computer Simulation Micro Saint for Windows MANUFACTURING MODEL DEVELOPMENT - EXERCISE # 4 Exercise Description In this exercise, we will add the probability that each entity will fail the "Test" task and need to be reworked. To do this we will add a new task to the model called "Rework" that will probabilistically route entities back into the network at different points to simulate different levels of rework required. Products (entities) that are rerouted back into the network will go into the queues if the task to which they are routed is currently executing. However, rework products in the queue will have priority over those in the normal flow for executing next. Simulation Concepts 1. Looping entities back to different points in the task network based on a probability value. 2. Giving entities that are being reworked a priority in being selected from the queue for task execution. Micro Saint Sharp Features Covered Probabilistic Decision Type To route products through three possible paths in the network representing rework loops. Sorted Job Queues Used to select items in a queue for execution of a task based on a priority value. Priority Expression Returns a value that is associated with each entity in a queue. In a sorted queue, the entity with the highest value is the one selected from the queue first. In the case of equal priority values, the model selects entities based on First In First Out rule. Manufacturing Model 13 Micro Computer Simulation Micro Saint for Windows MANUFACTURING MODEL Exercise #4- Rework Loops && Queue Priorities Modify the Existing Manufacturing Model Network In the next exercise, add a rework loop to the existing manufacturing model that checks to see if a product is defective. If so, it is routed to a disassembly (rework) task and then to the appropriate assembly process. Since defective products have priority, the product is sent directly to the appropriate assembly task.. 1. Use the graphical model development tools on the Network Diagram window to modify the network for this model. Add Task 6, name it "Rework," and draw the paths shown below. 2. Enter the task timing expressions for Task 6 shown in the table below: (These parameters are based on a Normal distribution for the task.) Task # 6 Mean Time return 7.0; Standard Deviation return 2.0; 3. Define an expression to set a flag that a product is being reworked in the ending effect of Task 6: Entity.Reworked = 1; 4. To keep a count of the number of products which needed to be reworked, add another ending effect expression to Task 6: Reworks ++; 5. Close the interface by clicking on the x in the upper right corner of the dialog window. Rework Loops && Queue Priorities With the modifications you just made, Task 4 now has two branches coming from it and Task 6 has three branches, so both those decision nodes need to be defined. We'll use a Probabilistic Decision Type for those decisions. Since this is the default Decision Type, you won't have to change it. You'll only have to enter the routing condition expressions as shown in the following steps: 1. Double click Task 4. Manufacturing Model 14 Micro Computer Simulation Micro Saint for Windows 2. Click on the “Paths” tab. 3. Change the decision type to “Probabilistic” 4. Replace the default following expressions ("return true;") in the "Decision Code" column with the following: Frame Heading: Test(4) -> Pack/Ship (5) Test(4) -> Rework(6) Decision Code: return .8; return .2; 5. Go to the task description window for Task 6 by clicking the right-pointing arrow. 6. Change the Decision Type: to Probabilistic 7. Replace the default following expressions ("return true;") in the "Decision Code" column with the following: Frame Heading: Rework(6) -> Assembly 1 (2) Rework(6) -> Assembly 2 (3) Rework(6) -> Test (4) Decision Code: return .1; return .6; return .3; 8. Close the interface. 9. To give reworked products a priority, open tasks 2, 3, and 4, click the “Queue” tab, and change the release order to "sorted" (instead of "FIFO") and enter the following in the “Queue Priority:” section. return Entity.Reworked; 10. Remove the priority of work flag by resetting the rework flag in the end of Tasks 2, 3, and 4. This is done by clicking on the “Main” tab in those task description interface(s) and entering the following ending effect expression: Entity.Reworked = 0; 11. Close the task description interfaces(s). 12. To collect data on how many products were reworked, add the "Reworks" variable to the snapshot “ProductTypes”. 13. Add the variable “Reworks” to the variable list as an integer. 14. Add the variable “Reworked” to the Entity Attribute list as integer. Manufacturing Model 15 Micro Computer Simulation Micro Saint for Windows MANUFACTURING MODEL DEVELOPMENT - EXERCISE # 5 Exercise Description In this exercise, we will add logic to the model that will actually suspend the execution of the task in one of the rework loops to do the rework immediately. When the rework has been completed, the entity that was originally executing the task resumes execution at the point that it was suspended. This is all done with two built-in Micro Saint Sharp functions (suspend() and resume()) and some creative use of temporary variables that keep track of the entity that was suspended so that same one can be resumed when the rework is completed. The built-in functions and the variables that keep track of the tag value of the entity that was suspended are embedded in expressions in user-defined functions that we will build in this exercise. Simulation Concepts 1. Suspending and resuming the execution of a task. 2. Keeping track of the entity that was executing a task before its execution was interrupted. Micro Saint Sharp Features Covered suspend() Micro Saint Sharp built-in function that suspends the execution of a particular tag in a particular task (suspend(task #, tag #)). resume() Micro Saint Sharp built-in function that resumes the execution of a particular task for a particular tag whose execution was suspended previously (resume(task #, tag #)). User-defined Functions Groups of Micro Saint Sharp expressions that are assigned a single name. When that function name is encountered in an expression, all of the expressions in the group are executed. Manufacturing Model 16 Micro Computer Simulation Micro Saint for Windows MANUFACTURING MODEL Exercise #5- Suspending Tasks Suspending Tasks We mentioned in the previous exercise that reworked products had priority over new orders. We still need to add the logic to suspend a task processing a current order so it can process the rework product. 1. To track the tag value of the most recent tag to enter the task, open Task 3 and add the following beginning effect expression: TagIn3 = Entity.Tag; 2. Also in the beginning effect of Task 3, add the following logic to act as a flag to determine if the task is currently working on a reworked product: if (Entity.Reworked == 1) {Reworking = 1;} 3. In the ending effect of Task 3 add the following expression to reset the flag: Reworking = 0; 4. Close the task description interface. We need to define two functions: one to track the order suspended and another to resume it when the task is finished reworking the defective product. "Suspend3" suspends Task 3 and stores the number of the currently suspended tag in the "SuspTag3" variable. It also increments "Op3" (the number of available operators) so that rework tags can enter the task. "Resume3" resumes Task 3 with the suspended tag and sets "SuspTag3" equal to zero. 5. Add the functions "Suspend3" and "Resume3" shown below. Suspend3: Key[0] = “ID”; Key[1] = “Tag”; Value[0] = “3”; Value[1] = TagIn3; Model.Suspend(Key, Value); SuspTag3 = TagIn3; Op3 ++; Resume3: Key[0] = “ID”; Key[1] = “Tag”; Value[0] = “3”; Value[1] = SuspTag3; Model.Resume(Key, Value); TagIn3 = SuspTag3; SuspTag3 = 0; 6. Close the function description interface. Manufacturing Model 17 Micro Computer Simulation Micro Saint for Windows 7. We want the function Suspend3 to execute when the tag is a rework product and Task 3 is currently busy. Open task 3, click on the Queue tab, and add the following expression in the Queue Priority field before the return code: if (Entity.Reworked == 1 && Reworking == 0 && Op3 == 0) {Suspend3();} NOTE TO INSTRUCTORS… The previous line of code does not work correctly but has been left as it is to be used as a debugging exercise at the discretion of the instructor. There are two solutions that have been found during this exercise by other classes. Solution 1: Add the expression ‘SuspTag3==0’ to the if statement so the entire statement reads: if (Entity.Reworked == 1 && Reworking == 0 && Op3 ==0 && SuspTag3 == 0) {Suspend3();} Solution 2: Move the entire statement from the sorting field to the entering effect field of the same Q. 8. Change the ending effect expression ("Op3 ++") to increment "Op3" when the task is not currently suspended, otherwise execute the Resume3 function. The ending effect expression should be changed to: if (SuspTag3 == 0) {Op3 ++;} else {Resume3();} 9. Close the task description interface. 10. Add the following variables to the variable list: Name TagIn3 SuspTag3 Reworking Key Value Manufacturing Model Type integer integer integer string string IsArray False False False True True ArrayDimensions 2 2 18