Optimizing a Design with Monte Carlo Simulation

Performance and cost trade-offs are a constant in engineering design.  Optimizing a design to balance these competing forces can be challenging to quantify and we often have to resort to experience or intuition.  One of the traditional cost drivers is specifying tolerances.  Part dimensions are naturally random variables since each part manufactured will not be exactly the same.  At the same time, there might be performance considerations related to fit that have to be considered.

When we have random variables, trying to optimize a design to minimize cost and maximize performance can be like hitting a moving target.  When we encounter a situation like this, a good option is to combine an optimization algorithm with Monte Carlo simulation.  Simulation gives a picture of the possible outcomes while the optimization algorithm adjusts things we control (decision variables) to achieve a good solution.

To illustrate the process, we'll look at an assembly where we are balancing assembly rejection where the parts don't fit together with performance considerations where we don't want a loose fit.

Design Optimization Example

Let's say we are designing the assembly shown below.  Four parts must fit inside a machined pocket in part 5.  We want to minimize the number of times where the four parts won't all fit inside the pocket.  We also want to avoid a loose fit.

Section A-A

Before we proceed, there are some assumptions and information required.  First of all, we need to know the variation of the processes used to manufacture the parts.  Assuming that the parts follow a normal distribution and we know the standard deviation of parts, we can model the dimensions of each part as a random variable.

To simplify things, we also assume that each interior part and the pocket of part 5 is perfectly square.  With this assumption, there are four possible causes of an interference fit.

  • The combined heights of 1 and 3 are too tall for the pocket.
  • The combined heights of 2 and 4 are too tall for the pocket.
  • The combined widths of 1 and 2 are too wide for the pocket.
  • The combined widths of 3 and 4 are too wide for the pocket.

Since the corners are rounded, we can ignore any interaction between 1 and 4, or 2 and 3.  Note the open space at the center of the assembly.

Modeling the Assembly

We can model the fit in a spreadsheet.  Again, we are assuming the dimensions of each part follow the normal distribution and we know the standard deviation of parts produced by each manufacturing process.

In the model, we are calculating the four clearances that we discussed earlier.  There are also a couple of constraints that we need to impose.  First, it makes sense to make the pocket height and width the same dimension.  This is modeled in cell B19.

The second constraint relates to the looseness of fit.  To simplify, we will impose a total clearance of ≤ 0.06.  This is the sum of the clearances calculated in cells B13:B16.

Finally, we will simulate the fit using an indicator variable in cell B20.  If all of the clearances in cells B13:B16 are positive, then cell B20 will return 1.  If any of B13:B16 have an interference fit, then cell B20 will return 0.  When the simulation is run, all outcomes are either 1 or 0.  The percentage of outcomes that are 0 gives an indication of the percentage of assemblies that don't fit together.

Simulating and Optimizing at the Same Time

Simulation Master allows for optimization with simulation.  If you want to learn more about optimization with simulation, read this article before proceeding.  The optimization will be set up with the following parameters.

  • The objective measure is the thing we're trying to optimize.  In this case, we are trying to maximize the mean of the model output.  Recall that the model output is cell B20, where 1 is a clearance fit, and 0 is an interference fit.  Therefore, we want as many ones as possible.
  • Optimization with simulation is a loop within a loop.  The outer loop is the optimization loop.  Each solution proposed by the optimization algorithm is simulated.  In the example, each potential solution is simulated and the one with the highest mean output is selected.  For each optimization loop, we will simulation each possible solution 500 times.  This isn't very many trials, but this operation is extremely intensive so we need to limit the trials.
  • The maximum number of optimization loops is 200.
  • We are looking to change the pocket height and width to balance rejection with performance.  These nominal dimensions are decision variables.  A decision variable is something we can control.  These decision variables are located in cells E6 and E11.  The optimization algorithm changes cells C6 and C11 to find the optimum solution.
  • We are imposing a constraint that pocket height and width are the same.  This is modeled in cell B18.  We want the difference between height and width to be zero.
  • There is also a constraint in cell B19 that the total clearance is less than or equal to .06.  This results in a maximum average clearance of .015 between adjacent parts.

Now we'll run the simulation.  After the optimization is done, we'll run a final simulation with the best decision variable values for 25,000 trials.

The rejection rate (assemblies that don't fit) is determined by finding the number of outcomes that are less than 1 (zero).  From the screenshot below, 0.788% of the outcomes did not fit together.

Clicking on the Optimization tab we can see the optimization results.  The final solution has a constraint violation for constraint 1.  We wanted the height and width of the pocket to be equal.  There is a .001 difference between the two.  This is not unusual because holding a constraint to a specific value is difficult to do.  This is an equality constraint where the constraint is equal to a specific number.  Whenever possible, an inequality constraint is preferred.  An inequality constraint allows for values ≤ or ≥ a value.  This allows for more possible solutions.

What we can do is either split the difference between the height and width of the pocket, or select one of the dimensions and assign it to both.


Any time you have random variables that are balanced with a competing objective it can be difficult to instinctively decide how to proceed.  By combining simulation with optimization, optimizing a design can be done in a logical manner.

Excel is a registered trademark of Microsoft Corporation.  Used with permission from Microsoft.