Mathematical optimization, often shortened to optimization, is the search for the best decision among all decisions the rules allow. You describe the choices as decision variables, the goal as an objective, and the rules as constraints. A solver, which is an algorithm, then finds the values that maximize or minimize the objective while it respects every constraint. That complete description is an optimization problem.
The search needs an algorithm because trying every option is hopeless. Ten decisions with ten options each produce ten billion combinations, and checking one combination per second would take about 317 years. Nobody has that long, so a solver rules out whole regions of combinations at once instead.
This page explains the building blocks, the main problem types, how solvers work, how to handle uncertain inputs, and where Analytica fits.
What are decision variables, objective functions, and constraints?
Decision variables are the quantities you control, such as how much energy to buy from each source or how many plants to build. The objective function is the single number you want to minimize or maximize, such as total cost or expected profit. Constraints are the rules every answer must obey, such as a demand to meet, a budget, or a physical limit. A set of decisions that satisfies every constraint is feasible, and the best feasible set is the optimum.
Consider a hypothetical utility that must supply 1,000 gigawatt-hours (GWh) of electricity next year at the lowest cost. It can buy gas at $40,000 per GWh, wind at $60,000 per GWh up to 600 GWh, and solar at $70,000 per GWh up to 300 GWh. A regulation caps emissions at 100,000 metric tons of carbon dioxide, and gas emits 400 metric tons per GWh.
The decision variables are the GWh bought from gas, wind, and solar. The objective function is total cost, which equals 40 times the gas GWh plus 60 times the wind GWh plus 70 times the solar GWh, in thousands of dollars. The constraints are the 1,000 GWh demand, the emissions cap (gas limited to 250 GWh), and the two contract limits.
The optimum buys 250 GWh of gas, 600 GWh of wind, and 150 GWh of solar for $56.5 million. Without the emissions cap, the cheapest plan buys 1,000 GWh of gas for $40.0 million. The cap therefore costs $16.5 million and removes 300,000 metric tons of emissions, an average of $55 per metric ton.
An influence diagram draws this structure with decision nodes that feed an objective node, and in Analytica, constraint nodes hold the rules.
Which type of problem do you have: linear, integer, or nonlinear?
The shape of the equations decides which algorithms apply, so the first step is to identify the problem type. The utility example is a linear program, because the objective and every constraint add up decision variables, each times a constant. The table below lists the common types, each with its typical form, an example, and the family of algorithms that handles it.
| Problem type | What it looks like | Typical example | Solver family |
|---|---|---|---|
| Linear programming (LP) | Linear objective and constraints, with variables that take any value in a range | The generation mix above, blending, shipping | Simplex or interior point |
| Integer programming and mixed integer programming (MIP) | Some or all variables must be whole numbers or yes/no choices | Whether to build a plant, which units to run each hour | Branch and bound |
| Quadratic and conic programming | Squared terms in the objective or cone-shaped constraints, with linear structure otherwise | Portfolio risk against return | Interior point (barrier) |
| Nonlinear optimization (NLP) | A curved objective or curved constraints | Efficiency curves, economies of scale, physical laws | Gradient-based local search or global search methods |
| Constraint programming | Logical and scheduling rules, such as one task cannot start before another ends | Shift rosters, timetables | Constraint propagation with search |
| Stochastic optimization | Uncertain inputs, with some decisions coming before the outcome | Capacity contracts that precede the demand outcome | Scenario-based LP or MIP |
Start with the simplest type that describes the facts, because each step down the table makes the search harder. For a deeper reference on each type, see the NEOS Guide to Optimization.
Three questions sort most problems. If any decision must be a whole number or a yes/no choice, the problem is an integer or mixed integer programming problem. If any equation curves, so that doubling a variable does not double its effect, the problem is nonlinear, or quadratic when the curve is a square. If any input is uncertain, stochastic optimization applies on top of whichever type remains.
How does a computer find the best answer?
The simplex method, which George Dantzig devised in 1947, exploits a fact about linear programs. At least one optimal solution always lies at a corner of the feasible region, so the method moves from corner to corner, each time to a better neighbor, until no neighbor improves. In the utility example, the optimum sits where the emissions cap, the wind limit, and the demand requirement all bind. Interior point methods take a different route, cutting through the interior of the region toward the optimum.
Integer problems need branch and bound. The solver first ignores the whole-number rule and solves the relaxed problem. If a variable comes out fractional, such as 2.5 plants, the solver splits the problem into two, one that allows at most 2 plants and one that requires at least 3, and solves each. It discards any branch that cannot beat the best whole-number answer found so far.
Linear solvers also report a shadow price for each constraint. In the example, the emissions cap has a shadow price of $75 per metric ton because tightening the cap by 1,000 metric tons adds $75,000 when solar replaces gas at the margin.
Nonlinear problems add a hazard. A solver follows the slope uphill or downhill and stops when no direction improves, so it finds the nearest peak and not necessarily the highest one. In a convex problem, every local optimum is also the global optimum, but a nonconvex problem can have many peaks, so analysts often start the search from several points.
An optimization solver packages these methods behind one interface, and the NEOS Server lets you try one problem on different solvers online.
Why does the way you write the problem matter so much?
A solver answers the question you wrote, not the question you meant. A model with a missing constraint returns a confident plan that breaks a rule, and a badly structured model may never finish. Formulation, turning a decision into variables, an objective, and constraints, therefore matters more than the software that runs it.
Three habits keep models solvable. First, keep the model linear wherever the facts allow, for example, by approximating a gentle curve with a straight line over the relevant range. Second, give every variable realistic lower and upper bounds, such as the 600 GWh wind limit, because bounds shrink the space the search must cover. Third, avoid unnecessary integers, since thirty yes/no decisions already allow 230 = 1,073,741,824 combinations.
Treat a decision as continuous when whole numbers do not matter, for example when you buy energy in GWh instead of whole plants. Then test the model on a small case you can check by hand. The utility example works for this purpose, because its answer follows from simple arithmetic.
What happens when the inputs are uncertain?
Real inputs vary. Demand, fuel prices, rainfall, and equipment failures all move, and the usual shortcut replaces each with its average and solves once. That shortcut repeats the Flaw of Averages, because the plan that is best for the average case is rarely best across the cases that can occur. The Monte Carlo simulation page explains the flaw in more detail.
Extend the hypothetical utility. Next year’s demand will be 900 GWh or 1,100 GWh with equal probability; the utility must sign the wind and solar contracts before anyone knows which, and each GWh of unserved demand costs $200,000. The plan optimized for the average demand of 1,000 GWh signs 600 GWh of wind and 150 GWh of solar, and the model reports a cost of $56.5 million. If demand reaches 1,100 GWh, gas hits its 250 GWh emissions limit, 100 GWh goes unserved, and the cost climbs to $76.5 million.
Stochastic optimization builds the uncertainty into the search. It chooses the contracts, which are the first-stage decisions, to minimize the expected cost across the demand cases, and it treats gas dispatch and shortfalls as second-stage decisions that adjust to each outcome. The table compares the two plans.
| Plan | Wind (GWh) | Solar (GWh) | Cost if demand is 900 GWh | Cost if demand is 1,100 GWh | Expected cost |
|---|---|---|---|---|---|
| Optimized for average demand | 600 | 150 | $52.5 million | $76.5 million | $64.5 million |
| Stochastic optimization | 600 | 250 | $55.5 million | $63.5 million | $59.5 million |
The average-demand plan promised $56.5 million but costs $64.5 million in expectation, which is $8.0 million more than it promised. The stochastic plan buys 100 GWh more solar as insurance and saves $5.0 million against the average-demand plan.
A real model replaces the two demand cases with many Monte Carlo samples. Robust optimization offers a second approach because it protects against the worst case within a defined set of scenarios rather than the average. Before building a large stochastic model, run a sensitivity analysis to identify which uncertain inputs drive the best decision, and describe those inputs using risk-analysis methods.
How do simulation, search, and decision analysis differ?
Simulation shows what happens for a given decision. It runs the uncertain inputs through a model and reports the range of outcomes. Optimization searches for the best decision under a stated objective and constraints. Decision analysis frames the choice before either one starts, by defining the alternatives, the uncertainties, the objectives, and the decision maker’s attitude toward risk.
The three combine. Decision analysis defines what best means, optimization proposes the best decision for that definition, and Monte Carlo simulation tests whether the proposal holds up across uncertain futures. The strongest models use all three, and the stochastic example above already combines the last two.
Who developed the field, and when?
Leonid Kantorovich developed linear programming techniques in 1939 and shared the 1975 Nobel Memorial Prize in Economic Sciences with Tjalling Koopmans. Dantzig devised the simplex method in 1947, and the word programming in linear programming meant planning, not computer code. John von Neumann’s duality theory, developed in the same period, showed that every linear program has a companion problem whose solution yields the shadow prices.
Ailsa Land and Alison Doig described branch and bound in 1960, the search strategy behind integer programming. Narendra Karmarkar introduced an interior point method in 1984. Commercial and open-source solvers now package all of these methods.
How do you build and solve these models in Analytica?
Analytica draws a decision problem as an influence diagram, so the diagram doubles as the model structure. The utility example needs three decision nodes for gas, wind, and solar, one objective node for cost, and constraint nodes for demand, the emissions cap, and the contract limits. The Analytica Optimizer selects the solver best suited to the problem automatically, across linear, mixed integer, quadratic, and nonlinear programs.
The standard engines handle linear and quadratic problems with up to 8,000 variables, including up to 2,000 integer variables, conic problems with up to 2,000 variables, and nonlinear problems with up to 500 variables. Plug-in engines, including Gurobi and Knitro, handle larger problems with few or no changes to the model, and the Solver engines page lists them. Lumina’s comparison of optimization and solver software reviews the options side by side.
Intelligent Arrays add dimensions such as time and scenarios to a model without copying its structure. To make demand uncertain, specify it as a chance variable with a probability distribution, which Lumina’s Optimizer page describes as the route to stochastic optimization. Monte Carlo simulation and sensitivity analysis then run on the same model.
Where do utilities use these models?
Electric utilities use optimization for planning and operations, and Lumina’s energy and power page describes related work. The list below names six common problems.
- Economic dispatch. Choose how much each generator produces in each period to meet demand at the lowest cost.
- Unit commitment. Decide which units run in each period, which makes it a mixed-integer problem because a unit is either on or off.
- Capacity expansion. Choose which plants to build and when, under uncertain demand, fuel prices, and policy. Navigant Consulting built a model of the Pacific Northwest’s electricity future in Analytica that combines linear programming for dispatch with nonlinear optimization for capacity planning.
- Transmission planning. Decide which grid links to add or upgrade.
- Storage scheduling. Decide when to charge and discharge batteries or reservoirs against prices and demand.
- Grid flow balancing. Match supply and demand across a network of lines.
Each problem has the same three parts, which are decisions, an objective, and constraints.
Further reading
The sources below cover linear programming, operations research, stochastic programming, and the Analytica Optimizer.
- Dantzig, G. B. Linear Programming and Extensions. Princeton University Press, 1963.
- Hillier, F. S., and G. J. Lieberman. Introduction to Operations Research. McGraw-Hill.
- Birge, J. R., and F. Louveaux. Introduction to Stochastic Programming. 2nd ed. Springer, 2011.
- Lumina Decision Systems. Analytica Optimizer Guide. Analytica Docs.
Dantzig’s book comes from the originator of the simplex method, Hillier and Lieberman’s textbook covers the wider field, and Birge and Louveaux’s covers stochastic programming.
Frequently asked questions
What is the difference between optimization and simulation?
Simulation shows what happens for a decision you choose, and optimization searches for the best decision. A simulation of the utility example would report the cost of one contract mix across many demand outcomes. An optimization would search across contract mixes for the one with the lowest expected cost. Most useful models combine the two.
What is a solver in optimization?
A solver is the software algorithm that searches for the best values of the decision variables. You supply the model, meaning the variables, the objective, and the constraints, and the solver returns the best values it can find or reports that no values satisfy the constraints. Different solvers specialize in different problem types, such as simplex-based solvers for linear programs and branch-and-bound solvers for integer problems.
Linear vs nonlinear optimization: how do I tell?
A problem is linear when the objective and every constraint are linear combinations of decision variables, each times a constant, so doubling a variable doubles its effect. If any term squares a variable, multiplies two variables, or applies a curve such as a logarithm or an efficiency table, the problem is nonlinear. Nonlinear problems can have several local optima, so the answer can depend on the starting point.
Can Excel Solver handle large problems?
Frontline Systems, the company behind the add-in, states that the standard Excel Solver limits a model to 200 decision variables. The utility example has three, but an hourly version needs three for each of 8,760 hours, which makes 26,280 decision variables. Models of that size need a dedicated solver engine, and Lumina’s comparison of optimization and solver software reviews the options. The Beyond the spreadsheet page covers models that outgrow a spreadsheet.
How do you optimize when inputs are uncertain?
Describe each uncertain input with a probability distribution, then choose the decisions that minimize the expected cost or maximize the expected value across the possible outcomes. That approach is stochastic optimization. Where a bad outcome would cost too much, robust optimization instead chooses the decision that performs acceptably in the worst of a defined set of scenarios. Sensitivity analysis first shows which uncertain inputs deserve the effort.