Sub topic 9
Choosing a solving method
This chapter assumes you can set up a Solver model with an objective cell, variable cells, and constraints. It also assumes you know that Goal Seek and Solver both search iteratively. Here you will learn what the three Solver methods do, which one fits which model, and the errors people make when they pick the wrong one.
Why the method matters
Solver does not have one algorithm. The Select a Solving Method drop-down in the Solver dialog chooses between three different search procedures. They have different strengths, and a wrong choice gives a wrong answer, a slow answer, or an error message.
The three methods are:
- Simplex LP solves linear programs. It finds the true global optimum, or it proves that none exists.
- GRG Nonlinear (Generalized Reduced Gradient) solves smooth nonlinear models. It finds a local optimum near its starting point.
- Evolutionary uses a population of candidate solutions and random mutation. It handles non-smooth models, but it gives no guarantee of optimality.
The deciding question is how the objective and the constraints depend on the variable cells. That is a property of your model's formulas, not of the business problem.
What "linear" means in a spreadsheet model
A model is linear when the objective cell and every constraint cell are a sum of variable cells, each multiplied by a constant. The product-mix model from earlier is linear:
- Profit = 20 × x + 30 × y
- Machine hours = 2 × x + 4 × y, which must be at most 100
- Total units = x + y, which must be at most 40
A model becomes nonlinear as soon as a variable cell is multiplied or divided by another variable cell, or is passed through a function such as IF, MAX, ABS, ROUND, PMT, NPV, IRR, or an exponent. Price multiplied by volume is nonlinear if both price and volume are variable cells. Price is a constant if only volume varies, so the model stays linear.
A common mistake is to assume that a model with simple-looking formulas is linear. Check each formula that depends on a variable cell, directly or through a chain of other cells.
Simplex LP
Simplex LP works because a linear problem has a special shape. The feasible region (the set of variable values that satisfy every constraint) is a polygon in two variables, or a polyhedron in more. The best value of a linear objective always sits at a corner of that shape. Simplex moves from corner to corner, improving the objective each time, until no neighbouring corner is better.
Consequences for your work:
- The answer is globally optimal. Starting values do not matter.
- Solver can report that the problem is infeasible (no point satisfies every constraint) or unbounded (the objective can grow forever).
- It is fast, even with thousands of variables.
- It supports sensitivity analysis. The Sensitivity Report gives shadow prices and allowable ranges, which are covered in the chapter on reading Solver reports.
Solver tests linearity when you press Solve with Simplex LP selected. If it finds a nonlinear dependence, it stops with the message "The conditions for Assume Linear Model are not satisfied." Treat this message as useful information. It tells you that your model is not what you thought it was. Do not switch methods to make the message go away until you have understood which formula broke linearity.
The Python example below is equivalent to a Simplex LP Solver model. It uses linprog from SciPy, and the optimum is 30 units of x and 10 units of y for a profit of 900.
from scipy.optimize import linprog
# Maximize 20*x + 30*y, so minimize the negative.
c = [-20, -30]
A_ub = [[2, 4], # machine hours per unit of each product
[1, 1]] # total units limited by a demand cap
b_ub = [100, 40]
res = linprog(c, A_ub=A_ub, b_ub=b_ub, bounds=[(0, None), (0, None)])
print(res.x, -res.fun)Both constraints are binding at the optimum: 2 × 30 + 4 × 10 = 100 machine hours and 30 + 10 = 40 units.
GRG Nonlinear
GRG Nonlinear is the default method, and it handles most financial models that are not linear. It works from the current values of the variable cells. It estimates the slope of the objective by making small changes to each variable, then moves in the direction that improves the objective. It repeats this until the slope is close to zero and the constraints are satisfied.
This has three practical effects.
- The starting point matters. GRG finds a local optimum, which is the best point in its neighbourhood. If the objective has several peaks, GRG may stop on a lower one. Run it from several different starting values. If the results agree, you can be more confident. If they differ, the model has multiple local optima.
- The model must be smooth. The slope must be defined at the points Solver visits. Functions with jumps, such as
IF,ROUND,VLOOKUPwith approximate match, or tax brackets, give flat or undefined slopes. GRG may then stop early, claiming it cannot improve, when it simply cannot see a direction. - Bounds help. GRG works much better when every variable cell has both a lower and an upper bound. Without bounds, Solver may try values such as negative prices or growth rates above 1,000%, which can cause errors like
#NUM!or#DIV/0!in the model.
GRG options worth knowing:
| Option | Effect |
|---|---|
| Multistart | Runs GRG from many random starting points. It needs bounds on every variable. It reduces the risk of a poor local optimum. |
| Use Automatic Scaling | Rescales variables and constraints that differ greatly in size. Leave it on if you mix values like 0.05 and 5,000,000. |
| Convergence | The smallest relative improvement Solver accepts as progress. A smaller value gives a more exact answer but takes longer. |
| Derivatives: Forward or Central | Central differences are more accurate for the slope and slower. Use them if Solver reports it cannot improve and you believe it can. |
Evolutionary
The Evolutionary method does not use slopes. It builds a population of candidate solutions, keeps the better ones, and creates new candidates by mutating and combining them. Because it only needs to evaluate the model, it works on formulas with jumps, lookups, and logical tests.
The trade-offs are:
- It is slower than the other two methods.
- It uses random numbers, so two runs can give different answers. Set a Random Seed in the options if you need a result you can reproduce.
- It never proves optimality. It stops when the best answer has not improved for a set time or number of iterations.
- It needs both bounds on every variable cell. Tight bounds make it much more effective.
- Constraints are handled less precisely, so check the final result for violations.
Use it for models with step functions, discrete choices, or lookup tables, and for problems where GRG repeatedly gets stuck. When you do, treat its answer as a good candidate to verify, not as proof.
Integer and binary variables
You can add the constraints int (integer) or bin (binary, 0 or 1) on variable cells. A binary variable is the standard way to model a yes-or-no decision, such as whether to fund a project in a capital allocation model.
Integer constraints change how the search works. Solver first solves a relaxed version, ignoring the integer requirement, then branches on fractional values. This is slower than a plain LP. The solver may stop within the Integer Optimality tolerance (1% by default), which means the reported solution can be up to 1% from the true best. Set this to 0 for a financial decision where the difference matters.
Rounding the result of a continuous solution is not a safe substitute. The rounded answer can violate a constraint or be far from the best integer answer.
A decision process
Work through these questions in order.
If you can restructure the model, do that first. Replacing an IF with a linear expression, or separating a variable from a lookup table, can turn an Evolutionary problem into a GRG problem, or a GRG problem into an LP. A faster and more reliable method is usually available.
Common errors
- Using GRG on a linear model. It usually finds the right answer, but it gives no sensitivity information of the same quality and no proof of optimality. If the model is linear, use Simplex LP.
- Forcing Simplex LP on a nonlinear model. Solver stops with the linearity message. Do not ignore it. If you turn off the linearity check, the answers are not trustworthy.
- Accepting GRG's first answer. Always test a second starting point for any model with a non-convex objective, such as an IRR, a ratio, or a model with fixed costs that switch on at thresholds.
- Leaving variables unbounded with Evolutionary or Multistart. Solver will refuse to run or will search badly.
- Treating the Evolutionary result as exact. It is a heuristic. Verify it independently, for example by testing neighbouring values by hand.
- Mixing very different scales. A variable of 0.001 next to a constraint of 50,000,000 hurts GRG's convergence. Rescale the model to units of thousands or millions, or keep Automatic Scaling on.
Summary of the comparison
| Property | Simplex LP | GRG Nonlinear | Evolutionary |
|---|---|---|---|
| Model must be | Linear | Smooth | Anything that calculates |
| Optimum type | Global, proven | Local | Best found, not proven |
| Starting values matter | No | Yes | Less, but results vary by run |
| Bounds required | No | Recommended | Required |
| Speed | Fastest | Fast | Slowest |
| Typical use | Product mix, blending, allocation with linear costs | Pricing, IRR targets, WACC-based funding mix | Step costs, lookup tables, scheduling |
Exercise
A capital allocation model has 12 candidate projects. Each has a fixed NPV and a fixed cost, and a budget limit applies. Each decision cell is binary (fund or do not fund), and the objective is the sum of NPV for funded projects. Which method should you choose, and why? What changes if one project's cost depends on a lookup table keyed to the funding level of another project?
Show answer
Use Simplex LP with the bin constraint on each decision cell. The objective (sum of NPV × decision) and the budget constraint (sum of cost × decision) are linear in the variable cells, so Simplex with integer handling gives a provably best answer. Set Integer Optimality to 0 if a 1% gap matters. If one cost depends on a lookup keyed to another project's decision, the model is no longer linear, because the lookup creates jumps. Simplex LP will report that the linearity conditions are not met. Either restructure the model (for example, add an explicit linear cost term) to keep it linear, or use Evolutionary with bounds on every decision cell, a fixed random seed, and an independent check of the result.
Exercise
You run GRG Nonlinear on a model that maximizes a project's NPV by changing the discount-rate-linked financing mix. Starting from 30% debt, Solver returns 52% debt. Starting from 80% debt, it returns 71% debt. What does this tell you, and what do you do next?
Show answer
Two different results from different starting points mean the objective has more than one local optimum, or a flat region where GRG stops early. Neither result can be trusted as the best. Next, put lower and upper bounds on the debt share (for example 0% to 100%), turn on Multistart so Solver tries many starting points, and compare the objective values of the answers. Keep the answer with the best objective that satisfies all constraints. If results still vary, check for IF or lookup formulas in the cost-of-capital calculation that create jumps, and consider Evolutionary.