article

Paul Toone avatar image
0 Likes"
Paul Toone posted

Experimenter Optimizer Example   

Introduction

This tutorial introduces the experimenter and optimizer found in FlexSim. These tools each help to answer the "what-if" questions for a model: What if the milling station were placed differently? What if more people were hired for a given shift? What if the order of these processes was changed? The experimenter allows you to try many different versions of your model and evaluate the performance of each one. Alternatively, the optimizer can automatically search through many different versions of your model, looking for the best one. They are both very powerful tools that enable you to learn about and improve your system.

Note: Using the optimizer requires the OptQuest license. Contact FlexSim for more information about obtaining this license.

What You Will Learn

This tutorial will walk you through the following steps:

  • Creating an experiment
  • Running an experiment
  • Viewing experiment results
  • Designing an optimization
  • Running an optimization
  • Viewing optimization results

Along the way, we will cover the definitions of related terms, such as:

  • Experiment variables
  • Performance measures
  • Scenarios
  • Optimizer variable types
  • Constraints
  • Objectives
  • Solutions

Step-By-Step Model Construction

For this tutorial, let us examine a very simple situation. A single worker must carry an item from a source to a processor. After the item finishes processing, the worker must carry it to a second processor that takes longer than the first. After the the second processor finishes the item, the worker then carries it to the sink.

Now let us suppose we want to maximize the throughput (which is also tied to revenue) of this system by adjusting the position of the processors. If each processor could be moved up to three meters right or left, where should each be placed? It would be very difficult to intuitively know how to place both processors to maximize throughput. In order to solve this problem accurately, we will use the experimenter and optimizer. Now, obviously this is a drastically simplified scenario, but often in real life you have situations where you want to see how various layouts affect overall throughput. This is a very simplistic implementation of such an experiment.

Step 1: Building the Model

Model

Create a new model using Seconds, Meters, and Liters for units.

Objects

Create a Source, two Processors, a Sink, a Dispatcher, and an Operator. Lay these objects out as shown below.

Positions

Set the location of the objects according to the table below:

Object X Position Y Position
Source1 -20.0 0.0
Processor2 -10.0 0.0
Processor3 0.0 0.0
Sink4 10.0 0.0
Dispatcher5 N/A N/A
Operator7 N/A N/A

Dispatcher5 and Operator7 do not need to be in a particular place, but they should not be in line with the rest of the objects.

Logic

Set the following logic:

  • Set Source1, Processor2, and Processor3 to Use Transport (available in the Quick Properties menu).
  • Set the process time of Processor2 to normal(10, 2) (also available in the Quick Properties menu).
  • Set the process time of Processor3 to normal(12, 3).
  • Set the reset position of Operator7 to its current position.

Step 2: Defining the Experiment

The remainder of this tutorial deals with using the Experimenter, found in the Statistics menu. The optimizer uses most of the functionality already present in the experimenter.

Creating Variables

Open the Experimenter window. Position the window so you can see the processors in the model as well as the window. Then, for Processor2 and then Processor3, follow these steps:

  • Click on the processor in the 3D view.
  • Click on the Position Reference button in the Quick Properties and set the position reference to Direct Spatials.
  • Click the down arrow on the Add button button.
  • Select Sample from the popup menu. This puts the cursor in sample mode.

Choose the sample option

  • Sample the X position field in the Quick Properties menu by clicking on it. This adds a new experiment variable.

  • Set the value of Scenario 1 for the new variable by double-clicking the cell and entering the new value.

Set scenario value

  • Set the name of the variable by double-clicking on the current name. Set the name to Proc2X for Processor2 and Proc3X for Processor3.

Set Variable Names

Creating Performance Measures

Go to the Performance Measures tab in the Experimenter window. From there:

  • Click the Add Button button to add a new performance measure.
  • Name the new performance measure Throughput.
  • Click the Drop-Down Button button and select the first option. A popup will appear.

Set Performance Measure 1

  • Select Sink4 for the object and Input for the statistic. To select the object simply type "/Sink4" (no quotes) in the object field or do the following:
    • Click the Add Performance Measure button.
    • Select Sink4 from the list of objects.
    • Click the Select button when you are finished.

Set PFM Reference

Designing the Experiment

Now that we've created the variables and performance measures, we'll set up some scenarios for our experiment. Go back to the experiment tab:

  • Create 5 scenarios by clicking on the Scenarios Add Button button 4 times.
  • Enter scenario names and values as follows:

scenariotable

Running the Experiment

Go to the Experiment Run tab. Hit the Run Experiment Button button. Each scenario will be run 5 times and the results of the Throughput performance measure will be collected at the end of each run. The status window will show which scenarios/replications are currently being run. FlexSim will run multiple scenarios simultaneously if your computer has a multi-core cpu.

Experiment Status

Once the experiment is finished, click the View Results Button button at the bottom. This will open a window where you can get data on the performance measures for the scenario. In this example we only have one performance measure, but if you had multiple you could see the results for each in this window. There are several options for how to display the data, including a Replications Plot, a Frequency Histogram, a Correlation Plot (for examining correlations between multiple performance measures), a Data Summary, and a Raw Data view.

Results Window

In this experiment, the best scenario was the "Close" scenario, which averaged right around 99 parts of throughput. The worst scenario was the "Far Apart" scenario, which averaged about 75 parts throughput.

Optimization

In addition to using the Experimenter to explicitly define scenarios, you can use the Optimizer. The optimizer will automatically create scenarios and then test those scenarios, trying to find a scenario that best meets an objective.

Designing the Optimization

Go to the Optimizer Design tab in the Experimenter window. You will see that the two variables created earlier are present; this is because the experimenter and optimizer share variables.

Optimizer Variables

However, the optimizer needs additional information about those variables. Specifically, you must specify:

  • Type - The type of a variable dictates what kinds of values are possible for a given variable. Continuous variables can have any value between the upper and lower bound.
  • Lower Bound - The lower bound specifies the lowest possible value the optimizer can set for the variable.
  • Upper Bound - The upper bound specifies the highest possible value the optimizer can set for the variable.
  • Step - For Discrete and Design variables, the step specifies the distance between possible values, starting from the lower bound.
  • Group - For permutation variables, the group specfies which set of permutation variables this particular variable belongs to.

For this optimization, we want to allow the processors to move three meters to either side. Since we are not limited to specific positions within that range, both position variables are Continuous. However, we need to set the lower and upper bounds of each variable. To edit values in the table, double-click on the cell of interest and enter in the new value. Enter in the values shown below:

Set Optimizer Variables

The final design step is to set the objective function. The objective function is present, but blank. Edit its name to be Revenue. Then click on the function field. A Drop-Down Button button will appear on the right side. Click on this button to bring up a list of all variables and performance measures. The objective function is a value derived from any or all of these values. Select Throughput; this will add that perfomance measure to the objective function, and put the cursor right and the end. Add the text * 500 so that Revenue is equal to Throughput * 500. Leave the direction on Maximize, because we want to maximize Revenue. Since we only have one objective, the search mode can remain on Single.

Objective

Step 3: Running the Optimization

Go to the Optimizer Run tab in the Experimenter window. Then:

  1. Set the Run Time to 10000. This is how long the optimizer will run each model configuration (called a solution) to evaluate it.
  2. Set the Wall Time to 0. This usually means how long the optimizer is allowed to run in real time. The value 0 means it has no time limit.
  3. Set Max Solutions to 50. This means the optimizer will try no more than 50 different solutions to find the optimal solution.
  4. Click the Optimize button.

Run Optimization

The Experimenter window will automatically switch to the Optimizer Results tab. The optimizer then begins running through the following loop:

  1. Determine values for Proc2X and Proc3X.
  2. Run a model with those values for 10000 seconds.
  3. Evaluate the performance measures.
  4. Calculate the objective function.
  5. Rank this solution.
  6. Use the information from this solution to create a new solution - new values for Proc2X and Proc3X.
  7. Repeat from Step 2.

Because the optimizer shares the multi-threaded capability of the experimenter, it can evaluate multiple solutions at the same time. As the optimization progresses, the Optimizer Results graph will update and show the optimizer's progress.

In-Progress Status

Once the optimizer evaluates 50 solutions, a message will appear stating why the optimizer stopped. In this case, it will say that the optimizer reached the maximum number of solutions. If something went wrong, the message will contain information about the error.

Step 4: Analyzing the Results

When the optimization is finished, the Optimizer Results chart should look something like this:

The Y Axis is called "Single Objective." For this example, it is synonymous with Revenue. The best solutions are highlighted. The circles with a lighter border around them represent better solutions. For a single objective, the top 10 solutions are marked this way.

As the optimization progressed, the optimizer got better and better at creating good solutions, so that the last 15 solutions were all very good. This is called convergence, and it is one way to tell if an optimization is finished; if the objective value has not improved for a while, it may be that it will not improve with further searching, and the current best solution should be used.

Answering the Original Question

The goal of this optimization was to figure out where to put the two processors. We can now very easily find the answer to this question. Hover over the best solution (the largest blue circle) on the chart; a small popup will appear.

Click on this solution to select it. Now, in the Graph Options panel, change the Y Axis to Proc3X, and the X Axis to Proc2X.

The best solution (and all the other best solutions) is found where Proc2X is greatest, and where Proc3X is least. Remember that all top 10 solutions produced the same results; in this case, having the two processors right next to each other is the best configuration for this model.

Setting the Model to the Best Solution

It can be very useful to set the model to match the best solution. To do this, click the Export Scenarios button. This takes all the selected solutions and creates experimenter scenarios for them. Go back to the Scenarios tab on the Experimenter window to view the new solution.

OptimalScenario

Now, from the "Choose default reset sceanrio" drop-down on the far right, select the new scenario. Then reset the model to apply those values to the 3D model.



flexsim users manual
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Article

Contributors

paul.t contributed to this article

Navigation

FlexSim 2016.1