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
lp(max 3x1 + 5x2; x1 <= 4; 2x2 <= 12; 3x1 + 2x2 <= 18)




max 3x + 2y; x + y <= 4; x + 3y <= 6; x, y >= 0


lp(min 2x + 3y; x + y >= 4; x + 3y >= 6)




lp(min 2x + 3y; x + y >= 4; x + 3y >= 6; method=bigm)




lp(max 5x + 4y; 6x + 4y <= 24; x + 2y <= 6; integer)


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(4 6 8; 5 7 3; supply=50 60; demand=30 40 20; method=northwest)


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=max)


game(4 2 5; 3 1 6; 6 0 2)
game(3 -1; -2 4)


game(3 -1 4; -2 4 5; 1 -2 3)


game(2 3 1 5; 4 1 6 0)


game(0 -1 1; 1 0 -1; -1 1 0)




game(2 0; 0 1 | 1 0; 0 2)


Known limitations
- At most 12 variables and 15 constraints; integer programs up to 6 variables. All variables must be non-negative – free variables aren't supported yet.
- Transportation and assignment problems up to 8 × 8.
- Matrix games up to 6 × 6; a bimatrix game's mixed Nash equilibrium only for 2 × 2 games.