Start with feasible solution
Problem to optimize a linear function of several variables subject to linear constraints.
General Form: Maximize c_1 x_1 + c_2 x_2 + \dots + c_n x_n Subject to:
\begin{aligned} a_{11} x_1 + \dots + a_{1n} x_n &\le b_1 \\ &\dots \\ a_{m1} x_1 + \dots + a_{mn} x_n &\le b_m \\ x_1 \ge 0, \dots, x_n &\ge 0 \end{aligned}
Example:
Maximize 3x+5y
subject to:
\begin{aligned} x+y &\le 4 \\ x+3y &\le 6 \\ x \ge 0, y &\ge 0 \end{aligned}
We can draw a figure in 2D space and find the feasible region bounded by the intersection of these lines.
Any LP problem with a nonempty, bounded feasible region has an optimal solution.
Three outcomes:
Classic LP problem solver.
Works on maximization problems. All constraints (except the nonnegativity constraints) must be linear equations.
All variables must be nonnegative
A basic solution11. In geometric terms, these basic feasible solutions correspond directly to the extreme points (corners) of the feasible region. to a system of m linear equations in n unknowns is obtained by setting n-m variables to 0 and solving the resulting system to get the values of the other m variables.
\begin{aligned} x+y+u &= 4 \\ x+3y+v &= 6 \end{aligned}
(0,0,4,6) is a basic feasible solution.
The Simplex algorithm represents the system of equations as a tableau22. a matrix.. The bottom row represents the objective function. The algorithm repeatedly selects a pivot column (a variable to enter the basis) with a negative coefficient in the bottom row, and a pivot row (the variable to leave the basis) with the smallest positive ratio of the right-hand side to the pivot column element. It then performs row operations to make the pivot element 1 and all other elements in the pivot column 0. This repeats until no negative values remain in the bottom row.
Analysis — The Simplex algorithm has an exponential worst-case time complexity, but in practice, it is highly efficient and typically runs in polynomial time. Space complexity is O(mn).
Problem of maximizing the flow of a material through a transportation network.
Formally, this is represented with a connected, weighted digraph with n verticies numbered 1 to n.
Note — There can only be one source, and one sink.
Assignemnt of real number x_{ij} to edges (i,j) of a given network that satisfy the following:
\sum_j x_{ji} = \sum_k x_{ik} \quad \text{for all } i \ne 1, n
0 \le x_{ij} \le u_{ij} \quad \text{for every edge } (i,j)
No material can be lost or added by going through intermediate verticies, so total amount of material leaving the source must end up at the sink.
This means our objective function is \sum_j x_{1j}, which we want to maximize
Maximize \sum_j x_{1j}
subject to
Flow conservation and capacity constraints as defined above.
A solution to flow maximization.
Steps:
If an augmenting path goes through edges with remaining capacities 5, 2, and 8, the bottleneck capacity is 2. We can only push 2 additional units of flow through this entire path before the second edge maxes out.
ALGORITHM FordFulkerson(G, s, t)// Computes the maximum flow in a flow network// Input: Network G with capacities c, source s, sink t// Output: Maximum flowfor each edge (u, v) in E doflow[u, v] \leftarrow 0; flow[v, u] \leftarrow 0while there exists a path p from s to t in the residual network docf(p) \leftarrow min(capacity_f(u, v) for (u, v) in p)for each edge (u, v) in p doflow[u, v] \leftarrow flow[u, v] \text{$+$} cf(p)flow[v, u] \leftarrow -flow[u, v]return sum(flow[s, v] for v adjacent to s)
Analysis — Time complexity is O(|E| \times \text{max\_flow}). This can be inefficient if the max flow is large and capacities are irrational. Space complexity is O(|V| + |E|).
An improvement on Ford-Fulkerson (often called Edmonds-Karp). It simply chooses the augmenting path with the fewest number of edges using Breadth-First Search (BFS).
ALGORITHM ShortestAugmentingPath(G, s, t)// Computes max flow using shortest augmenting paths// Input: Network G with capacities c, source s, sink t// Output: Maximum flowInitialize flow to 0while BFS finds a path p from s to t in residual network doaugment flow along p by the bottleneck capacityreturn flow
Analysis — By using BFS, the time complexity is bounded by O(|V||E|^2), making it strongly polynomial and independent of edge capacities.
A solution to the Stable Marriage Problem. It ensures a stable matching between two equally sized sets of elements given their preferences.
Steps:
ALGORITHM GaleShapley(Preferences)// Finds stable matching for n men and n women// Input: Preference lists for all men and women// Output: Stable matchingInitialize all m in M and w in W to freewhile there is a free man m who has not proposed to every woman dow \leftarrow highest-ranked woman on m's list to whom m has not proposedif w is free(m, w) become engagedelse if w prefers m to her current fiancé m'(m, w) become engagedm' becomes freeelsew rejects mreturn set of engaged pairs
Analysis — The algorithm terminates after at most n^2 iterations. The time complexity is O(n^2) with efficient data structures. Space complexity is O(n^2) to store the preference lists.