VII. Applications: sciences, economics and optimization

51. Linear programming, transportation, assignment and matrix games

Optimization problems are on the home screen in the "Applications" section, field Logistics and networks (linear programming also in Economics): linear and integer programming, the transportation problem and the assignment problem. A linear program can also be typed or photographed, e.g. max 3x + 2y; x + y <= 4; x + 3y <= 6; x, y >= 0 – the constraints on separate lines or after a semicolon, min instead of max, and the word integer makes it an integer program.

The steps show the standard form with slack and artificial variables and the simplex tableaux in exact fractions with the pivot marked. Constraints ≥ and = are handled by the two-phase method by default; a chip selects the big M method. The optimum comes with the dual program, the constraints' shadow prices and a sensitivity analysis (the ranges of the objective's coefficients and of the right sides). With two variables the app draws the feasible region, the vertices with the objective's values and the level line through the optimum. An integer program is solved by branch and bound, and you go through the branching tree with the arrows as a graph.

The transportation problem is given by the matrix of unit costs, the suppliers' supplies and the customers' demands; an unbalanced problem gets a dummy supplier or customer. The starting solution comes from the north-west corner, the least cost or Vogel's approximation method, the optimum from the MODI method with potentials and closed loops; the transportation plan is also shown as a graph. The assignment problem is solved by the Hungarian method – row and column reduction, covering the zeros with lines and choosing independent zeros; it handles a maximum and a rectangular matrix too.

Two-player matrix games (the Logistics and networks field, or the notation game(3 -1 2; -2 4 1) – the rows are player A's strategies, the columns player B's): a zero-sum game first looks for a saddle point (maximin = minimax), then crosses out dominated strategies and computes the mixed strategies by a formula for a 2 × 2 game, graphically for 2 × n and m × 2 (the lines' lower and upper envelope) and by linear programming with simplex tableaux for a larger one – the dual problem gives the other player's strategy. The result is both players' optimal strategies and the value of the game in exact fractions. A bimatrix game (game(2 0; 0 1 | 1 0; 0 2), A's payoffs | B's payoffs) shows the best responses and the Nash equilibria in pure strategies, for a 2 × 2 game the mixed equilibrium too.

Examples

A production plan by the simplex method with shadow prices and sensitivity.
Input: lp(max 3x1 + 5x2; x1 <= 4; 2x2 <= 12; 3x1 + 2x2 <= 18)
lp(max 3x1 + 5x2; x1 <= 4; 2x2 <= 12; 3x1 + 2x2 <= 18)
lp(max 3x1 + 5x2; x1 <= 4; 2x2 <= 12; 3x1 + 2x2 <= 18)lp(max 3x1 + 5x2; x1 <= 4; 2x2 <= 12; 3x1 + 2x2 <= 18)lp(max 3x1 + 5x2; x1 <= 4; 2x2 <= 12; 3x1 + 2x2 <= 18)lp(max 3x1 + 5x2; x1 <= 4; 2x2 <= 12; 3x1 + 2x2 <= 18)
A typed program – the graphical solution for two variables.
Input: max 3x + 2y; x + y <= 4; x + 3y <= 6; x, y >= 0
max 3x + 2y; x + y <= 4; x + 3y <= 6; x, y >= 0
max 3x + 2y; x + y <= 4; x + 3y <= 6; x, y >= 0max 3x + 2y; x + y <= 4; x + 3y <= 6; x, y >= 0
A minimum with ≥ constraints by the two-phase method.
Input: lp(min 2x + 3y; x + y >= 4; x + 3y >= 6)
lp(min 2x + 3y; x + y >= 4; x + 3y >= 6)
lp(min 2x + 3y; x + y >= 4; x + 3y >= 6)lp(min 2x + 3y; x + y >= 4; x + 3y >= 6)lp(min 2x + 3y; x + y >= 4; x + 3y >= 6)lp(min 2x + 3y; x + y >= 4; x + 3y >= 6)
The same program by the big M method.
Input: lp(min 2x + 3y; x + y >= 4; x + 3y >= 6; method=bigm)
lp(min 2x + 3y; x + y >= 4; x + 3y >= 6; method=bigm)
lp(min 2x + 3y; x + y >= 4; x + 3y >= 6; method=bigm)lp(min 2x + 3y; x + y >= 4; x + 3y >= 6; method=bigm)lp(min 2x + 3y; x + y >= 4; x + 3y >= 6; method=bigm)lp(min 2x + 3y; x + y >= 4; x + 3y >= 6; method=bigm)
An integer solution by branch and bound.
Input: lp(max 5x + 4y; 6x + 4y <= 24; x + 2y <= 6; integer)
lp(max 5x + 4y; 6x + 4y <= 24; x + 2y <= 6; integer)
lp(max 5x + 4y; 6x + 4y <= 24; x + 2y <= 6; integer)lp(max 5x + 4y; 6x + 4y <= 24; x + 2y <= 6; integer)
A transportation problem – Vogel's method and MODI.
Input: transport(19 30 50 10; 70 30 40 60; 40 8 70 20; supply=7 9 18; demand=5 8 7 14; method=vogel)
transport(19 30 50 10; 70 30 40 60; 40 8 70 20; supply=7 9 18; demand=5 8 7 14; method=vogel)
transport(19 30 50 10; 70 30 40 60; 40 8 70 20; supply=7 9 18; demand=5 8 7 14; method=vogel)transport(19 30 50 10; 70 30 40 60; 40 8 70 20; supply=7 9 18; demand=5 8 7 14; method=vogel)
An unbalanced transportation problem with a dummy customer.
Input: transport(4 6 8; 5 7 3; supply=50 60; demand=30 40 20; method=northwest)
transport(4 6 8; 5 7 3; supply=50 60; demand=30 40 20; method=northwest)
transport(4 6 8; 5 7 3; supply=50 60; demand=30 40 20; method=northwest)transport(4 6 8; 5 7 3; supply=50 60; demand=30 40 20; method=northwest)
Assigning workers to tasks at the least cost.
Input: assignment(9 2 7 8; 6 4 3 7; 5 8 1 8; 7 6 9 4; goal=min)
assignment(9 2 7 8; 6 4 3 7; 5 8 1 8; 7 6 9 4; goal=min)
assignment(9 2 7 8; 6 4 3 7; 5 8 1 8; 7 6 9 4; goal=min)assignment(9 2 7 8; 6 4 3 7; 5 8 1 8; 7 6 9 4; goal=min)
An assignment with the largest profit.
Input: assignment(9 2 7 8; 6 4 3 7; 5 8 1 8; 7 6 9 4; goal=max)
assignment(9 2 7 8; 6 4 3 7; 5 8 1 8; 7 6 9 4; goal=max)
assignment(9 2 7 8; 6 4 3 7; 5 8 1 8; 7 6 9 4; goal=max)assignment(9 2 7 8; 6 4 3 7; 5 8 1 8; 7 6 9 4; goal=max)
A game with a saddle point – maximin equals minimax.
Input: game(4 2 5; 3 1 6; 6 0 2)
game(4 2 5; 3 1 6; 6 0 2)
A 2 × 2 game without a saddle point – mixed strategies by the formula.
Input: game(3 -1; -2 4)
game(3 -1; -2 4)
game(3 -1; -2 4)game(3 -1; -2 4)
Dominated strategies crossed out one by one.
Input: game(3 -1 4; -2 4 5; 1 -2 3)
game(3 -1 4; -2 4 5; 1 -2 3)
game(3 -1 4; -2 4 5; 1 -2 3)game(3 -1 4; -2 4 5; 1 -2 3)
A 2 × 4 game graphically – the lower envelope's maximum.
Input: game(2 3 1 5; 4 1 6 0)
game(2 3 1 5; 4 1 6 0)
game(2 3 1 5; 4 1 6 0)game(2 3 1 5; 4 1 6 0)
Rock, paper, scissors by linear programming – each strategy with probability 1/3.
Input: game(0 -1 1; 1 0 -1; -1 1 0)
game(0 -1 1; 1 0 -1; -1 1 0)
game(0 -1 1; 1 0 -1; -1 1 0)game(0 -1 1; 1 0 -1; -1 1 0)game(0 -1 1; 1 0 -1; -1 1 0)game(0 -1 1; 1 0 -1; -1 1 0)
A bimatrix game (the battle of the sexes) – two pure and one mixed Nash equilibrium.
Input: game(2 0; 0 1 | 1 0; 0 2)
game(2 0; 0 1 | 1 0; 0 2)
game(2 0; 0 1 | 1 0; 0 2)game(2 0; 0 1 | 1 0; 0 2)

Known limitations