Introduction to Optimization#
Overview#
Power system operators face countless decisions every day. Which generators should run? How should power flow through the network? Where should we build new transmission lines? These questions share a common structure: we want to find the best solution among many possibilities while respecting physical and operational constraints.
Optimization provides the mathematical framework to answer these questions systematically. This lesson introduces fundamental optimization concepts through concrete power system examples. By the end, you’ll be able to recognize optimization problems in power systems and formulate them mathematically - the crucial first step toward finding solutions.
Learning Objectives#
By completing this lesson, you will be able to:
Recognize optimization problems in power system contexts
Identify decision variables, objectives, and constraints
Classify optimization problems by type (linear, nonlinear, integer)
Formulate optimization problems in standard mathematical form
Solve simple problems graphically to build intuition
Understand why problem structure affects solvability
# Import required libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from matplotlib.patches import Polygon
from matplotlib import cm
import warnings
warnings.filterwarnings('ignore')
# Set up plotting style
plt.style.use('seaborn-v0_8-whitegrid')
plt.rcParams['figure.figsize'] = (10, 6)
plt.rcParams['font.size'] = 12
print("Libraries loaded successfully")
Libraries loaded successfully
1. What is Optimization?#
Optimization is about making the best decision given constraints. In power systems, “best” usually means minimizing cost or maximizing reliability, while constraints represent physical laws and operational limits.
Consider three fundamental power system optimization problems:
Economic Dispatch: Given online generators, how much should each produce to minimize total cost while meeting demand?
Transmission Planning: Where should we build new lines to minimize investment while ensuring reliable power delivery?
Voltage Control: How should we adjust transformer taps and reactive power to maintain voltages within limits using minimal control actions?
Each problem involves:
Decisions to be made (generator outputs, line locations, tap settings)
An objective to optimize (minimize cost, maximize reliability)
Constraints that must be satisfied (power balance, line limits, voltage bounds)
Let’s explore a simple economic dispatch example to see these components in action.
Generator Characteristics:
Generator Min_MW Max_MW Cost_$/MWh
0 G1 20 100 25
1 G2 30 80 30
System demand: 150 MW
Optimization Components:
Decisions: How much power each generator produces (P1, P2)
Objective: Minimize total cost = 25*P1 + 30*P2
Constraints:
- Power balance: P1 + P2 = 150
- G1 limits: 20 ≤ P1 ≤ 100
- G2 limits: 30 ≤ P2 ≤ 80
Without optimization, we might dispatch generators equally (75 MW each) or proportionally to their capacity. But optimization tells us to use the cheaper generator (G1) as much as possible:
Optimal solution: P1 = 100 MW (at maximum), P2 = 50 MW
Total cost: \(25 × 100 + \)30 × 50 = $4,000/hour
This saves $125/hour compared to equal dispatch. Over a year, such optimization saves millions of dollars.
2. Components of Optimization Problems#
Every optimization problem has three essential components. Learning to identify these in problem descriptions is the key to successful formulation.
Decision Variables#
These are the quantities we control. In power systems:
Generator outputs (MW)
Transformer tap positions
Line flows (in some formulations)
Binary variables (on/off decisions)
Objective Function#
This quantifies what we want to optimize:
Minimize: generation cost, power losses, control actions
Maximize: social welfare, reliability, renewable integration
Constraints#
These are the requirements that must be satisfied:
Equality constraints: power balance (generation = demand + losses)
Inequality constraints: line flow limits, voltage bounds, generator limits
Some constraints come from physics (Kirchhoff’s laws), others from equipment ratings or operational policies
Exercise 1: Identify Optimization Components
A system operator must decide which generators to start up for tomorrow. The system has:
5 generators with different startup costs and minimum run times
Hourly demand that varies from 300 MW (night) to 500 MW (day)
A requirement to maintain 50 MW of spinning reserve at all times
Each generator has minimum and maximum output limits when running
Identify:
What are the decision variables?
What is the objective?
List at least 5 types of constraints
# Exercise 1: Your answer here
# Identify the optimization components for the unit commitment problem
# Your solution:
3. Types of Optimization Problems#
The mathematical structure of an optimization problem determines how difficult it is to solve and what solution methods apply. Understanding these classifications helps you choose appropriate solution techniques.
Linear vs. Nonlinear#
Linear programs (LP) have linear objectives and constraints:
DC optimal power flow
Economic dispatch with linear costs
Basic transmission planning
Nonlinear programs (NLP) include nonlinear relationships:
AC optimal power flow (power flow equations are nonlinear)
Loss minimization (losses are quadratic in current)
Voltage optimization
Continuous vs. Discrete#
Continuous variables can take any value in a range:
Generator output (e.g., 57.3 MW)
Voltage magnitude (e.g., 1.03 per unit)
Discrete variables have specific allowed values:
Binary: generator on/off, line built/not built
Integer: number of capacitor banks, transformer tap position
Convex vs. Non-convex#
Convex problems have a unique global optimum:
Linear programs are always convex
Some specially structured nonlinear problems
Non-convex problems may have multiple local optima:
AC optimal power flow
Most problems with discrete variables

* Linear in continuous variables, but has integer variables
4. Graphical Interpretation#
For problems with two variables, we can visualize the optimization process. This builds intuition for how constraints define feasible regions and how optimal solutions often lie at constraint boundaries.
Let’s solve our two-generator economic dispatch problem graphically.

Solution Analysis:
The optimal solution occurs where the cost contour is tangent to the feasible region.
Since G1 is cheaper ($25/MWh vs $30/MWh), we use it at maximum capacity.
Optimal dispatch: P1 = 100 MW, P2 = 50 MW
Total cost: $4000/hour
Note: The solution is at the intersection of two constraints:
- Power balance: P1 + P2 = 150
- G1 upper limit: P1 = 100
Exercise 2: Graphical Optimization
The system demand increases to 170 MW. Using the same two generators:
G1: 20-100 MW, $25/MWh
G2: 30-80 MW, $30/MWh
Is the problem still feasible?
What is the new optimal solution?
What is the marginal cost of this extra 20 MW?
# Exercise 2: Your solution here
# Analyze the system with 170 MW demand
# Your solution:
5. Mathematical Formulation#
To solve optimization problems computationally, we need to express them in standard mathematical form. This systematic approach ensures we capture all aspects of the problem and prepares it for solution algorithms.
Standard Form for Minimization#
Minimize: \(f(x)\) (objective function)
Subject to:
\(g_i(x) \leq 0\) for \(i = 1, ..., m\) (inequality constraints)
\(h_j(x) = 0\) for \(j = 1, ..., p\) (equality constraints)
\(x_l \leq x \leq x_u\) (variable bounds)
Where \(x\) is the vector of decision variables.
Converting to Standard Form#
Maximization to minimization: Maximize \(f(x)\) → Minimize \(-f(x)\)
Greater-than inequalities: \(g(x) \geq b\) → \(-g(x) \leq -b\)
Absolute values: \(|x| \leq b\) → \(x \leq b\) and \(-x \leq b\)
Ranges: \(a \leq x \leq b\) → \(x \geq a\) and \(x \leq b\)
Economic Dispatch - Mathematical Formulation
==================================================
Given data:
3 generators with quadratic cost functions
System demand: 400 MW
Reserve requirement: 50 MW
Generator parameters:
Generator Pmin (MW) Pmax (MW) a ($/h) b ($/MWh) c ($/MW²h)
0 G1 50 200 500 20 0.020
1 G2 40 150 300 25 0.030
2 G3 60 180 400 22 0.025
Cost function: C_i(P_i) = a_i + b_i*P_i + c_i*P_i²
==================================================
MATHEMATICAL FORMULATION
==================================================
Decision Variables:
P₁, P₂, P₃ = Power output of generators 1, 2, 3 (MW)
Objective Function:
Minimize: C_total = C₁(P₁) + C₂(P₂) + C₃(P₃)
= (500 + 20P₁ + 0.02P₁²) + (300 + 25P₂ + 0.03P₂²) + (400 + 22P₃ + 0.025P₃²)
= 1200 + 20P₁ + 25P₂ + 22P₃ + 0.02P₁² + 0.03P₂² + 0.025P₃²
Constraints:
1. Power Balance (equality):
P₁ + P₂ + P₃ = 400
2. Reserve Requirement (inequality):
(200 - P₁) + (150 - P₂) + (180 - P₃) ≥ 50
Simplifying: P₁ + P₂ + P₃ ≤ 480
3. Generator Limits (bounds):
50 ≤ P₁ ≤ 200
40 ≤ P₂ ≤ 150
60 ≤ P₃ ≤ 180
==================================================
PROBLEM CLASSIFICATION
==================================================
Type: Quadratic Programming (QP)
- Quadratic objective function
- Linear constraints
- Continuous variables
- Convex (positive semi-definite Hessian)
Solution approach: Can be solved efficiently to global optimum
Exercise 3: Problem Formulation
A utility must decide where to install capacitor banks to improve voltage profile. The system has:
5 candidate buses for capacitor installation
Each location can have 0, 1, or 2 capacitor banks
Each bank costs $10,000 and provides 5 MVAR
Goal: Minimize voltage deviations from 1.0 pu while limiting cost to $50,000
Formulate this as an optimization problem. Identify:
Decision variables and their type
Objective function
All constraints
Problem classification
# Exercise 3: Your solution here
# Formulate the capacitor placement problem
# Your solution:
6. Solution Concepts#
Understanding key solution concepts helps interpret optimization results and diagnose problems.
Feasibility vs. Optimality#
Feasible solution: Satisfies all constraints but may not be optimal Optimal solution: Feasible and achieves the best objective value Infeasible problem: No solution satisfies all constraints
Local vs. Global Optima#
Local optimum: Best solution in a neighborhood Global optimum: Best solution overall
Convex problems have only global optima
Non-convex problems may have multiple local optima
Sensitivity Analysis#
How does the solution change if we perturb:
Objective coefficients (e.g., fuel prices)
Constraint bounds (e.g., transmission limits)
Problem data (e.g., demand forecasts)
Shadow prices (dual variables) tell us the marginal value of relaxing constraints.

Key Insights:
1. Multiple feasible solutions exist, but only one (or a set) is optimal
2. Non-convex problems require global optimization techniques
3. Shadow prices indicate the value of relaxing constraints
4. Problem feasibility depends on the relationship between constraints
Exercise 4: Transmission Planning Formulation
A utility is planning transmission expansion. They have:
3 existing buses with generators
2 new load centers to connect
4 possible transmission corridors
Each line costs $1M per mile
Must ensure all loads can be served even with any single line outage (N-1)
Formulate this as an optimization problem:
What makes this problem particularly challenging?
What type of optimization problem is this?
Write the objective and key constraints
# Exercise 4: Your solution here
# Formulate the transmission planning problem
# Your solution:
Exercise 5: Complete Problem Formulation
An independent power producer wants to optimize the operation of their portfolio:
2 gas turbines: 50 MW each, $40/MWh operating cost, 5-minute start time
1 coal plant: 200 MW, $25/MWh, 4-hour start time, minimum 100 MW when on
1 battery: 20 MW / 80 MWh capacity, 90% round-trip efficiency
Must provide 150 MW firm capacity during peak hours (3-7 PM)
Energy prices vary hourly based on market forecast
Formulate a 24-hour optimization problem to maximize profit.
# Exercise 5: Your solution here
# Formulate the portfolio optimization problem
# Your solution:
Summary#
This lesson introduced the fundamental concepts of optimization through power system examples. You learned to:
Recognize optimization problems in power system contexts, from economic dispatch to transmission planning
Identify the three key components: decision variables (what we control), objective function (what we optimize), and constraints (what we must satisfy)
Classify problems by type: linear vs. nonlinear, continuous vs. discrete, convex vs. non-convex - understanding that problem structure determines solution difficulty
Formulate problems mathematically, converting verbal descriptions into precise mathematical statements ready for computational solution
Visualize simple problems graphically, seeing how constraints create feasible regions and optimal solutions lie at boundaries
Understand solution concepts like feasibility, optimality, and sensitivity that help interpret results
Key Takeaways#
Formulation is crucial: A well-formulated problem is halfway to solution. Poor formulation leads to wrong answers or computational intractability.
Problem structure matters: Linear problems are reliably solvable even at large scale. Integer variables and nonlinearity add significant complexity.
Constraints define feasibility: In power systems, constraints come from physics (power balance), equipment (ratings), and policy (reliability standards).
Optimal solutions often lie at boundaries: This explains why generators often run at minimum or maximum, and why transmission lines congest.
Multiple objectives require trade-offs: Cost, reliability, and environmental goals often conflict, requiring careful balancing.
Next Steps#
With these fundamentals established, you’re ready to implement optimization problems computationally. In the next lesson, we’ll explore Python tools for solving linear programs, starting with the economic dispatch and market clearing problems we formulated here.
Remember: every optimization problem in power systems started as a real operational challenge. By mastering these techniques, you’ll be able to tackle new challenges as the grid evolves.