Sub topic 3
Choosing a solving method
This chapter assumes you know Excel cell references, formulas, absolute and relative addressing, and basic financial statements. It also assumes the Solver add-in is installed.
Choosing a solving method
Solver offers three methods. Pick the one that matches the shape of your model.
- Simplex LP solves linear models, where the objective and constraints are straight-line relationships. For a linear model it finds the global optimum.
- GRG Nonlinear handles smooth nonlinear models, such as formulas with powers or ratios. It can stop at a local optimum, so test the result from a different starting point.
- Evolutionary handles models with IF logic, lookups, or step functions. It is slow and gives no guarantee of optimality.
Solver in practice
Every Solver model has three parts: an objective cell, variable cells, and constraints. In a product-mix model, the variables are units of each product, the objective is total contribution, and the constraints are machine hours and demand caps. Funding-mix and capital-allocation models follow the same pattern, with a budget or leverage limit as the constraint.
A linear product-mix check
The following script solves a two-product mix outside Excel. Run it to confirm a Simplex LP result.
from scipy.optimize import linprog
c = [-20, -30] # negated because linprog minimizes
A_ub = [[2, 4], # machine hours per unit of each product
[1, 1]] # total units allowed
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)The output is [30. 10.] 900.0, so the best mix is 30 units of product x and 10 of product y.
Reading Solver results
Solver reports its outcome in a status message. "Solver found a solution. All constraints and optimality conditions are satisfied." means the result is valid. "Solver could not find a feasible solution." means no values satisfy every constraint, so review the constraints first.
Request the Answer, Sensitivity, and Limits reports. The Answer report lists final values and shows which constraints are binding. Check each result by substituting the variable values back into the model.
Goal Seek, Solver, or data table
Use Goal Seek when one input must reach one target. Use Solver when several variables or constraints apply. Use a data table when you want to see how an output changes across a range of inputs.
Keeping solved models reliable
Put every assumption in an input cell and keep numbers out of formulas. Avoid circular references unless you turn on iterative calculation on purpose. Scale variables to similar sizes, because Solver converges poorly when one variable is in millions and another is a fraction. Add a check cell that confirms each constraint holds.
Automating target-seeking
You can run Goal Seek from VBA. The macro reports failure instead of leaving an unsolved value in the model.
Sub SolveBreakEven()
Dim ok As Boolean
ok = Range("B5").GoalSeek(Goal:=0, ChangingCell:=Range("B1"))
If Not ok Then MsgBox "Goal Seek did not find a solution."
End SubTo check the same break-even result in Python, use a root-finding method.
from scipy.optimize import brentq
def profit(units):
return units * (50 - 30) - 15000
print(round(brentq(profit, 0, 10000), 2))The script prints 750.0, which matches the Goal Seek answer.
Exercise
A product sells for 50, costs 30 per unit to make, and has 15000 in fixed costs. How many units bring operating profit to zero?
Show answer
750 units. Each unit contributes 20, and 750 × 20 = 15000.