What Should a Crate Cost?

Hawkins-Simon condition · determinant · exact arithmetic · dual prices · input-output model

A valley's workshops make goods measured in crates. Making one crate of good j uses up A[i][j] hundredths of a crate of good i (so A[i][j] = 25 means a quarter of a crate). Column j is good j's recipe; amounts are physical, so a column may well add up to more than 100.

Is the valley productive? It is if it can deliver every non-negative final demand with non-negative outputs. With a_{ij} = A[i][j] / 100 and I the identity matrix, the Hawkins-Simon condition decides it: the valley is productive exactly when every leading principal minor of I - a is positive. The k-th leading principal minor is the determinant of the top-left k x k block, for k = 1, ..., n.

What do crates cost? In a competitive valley every price just covers the cost of a crate: the inputs it uses, bought at the going prices, plus the value added v_j (wages and rent per crate, in coins). So the prices solve

p_j = \sum_i p_i\, a_{ij} + v_j \quad \text{for every } j, \qquad \text{that is} \qquad p = p\,a + v

with p a row vector. In a productive valley this has exactly one solution, and it has no negative prices.

Write cost_prices(A, value_added) that returns a tuple (minors, prices): the list of the n leading principal minors of I - a (as floats), and the list of prices, or None if the valley is not productive. A minor that is exactly 0 means not productive, so compute the minors exactly, with fractions.Fraction (in floating point 0.25 * 0.9 - 0.75 * 0.3 is not 0).

Examples

Input:  A = [[20, 10], [40, 30]], value_added = [1, 2]
Output: ([0.8, 0.52], [2.88461538, 3.26923077])
Explanation: a crate of good 1 costs 0.2 * 2.8846 + 0.4 * 3.2692 + 1 = 2.8846 coins.

Input:  A = [[10, 120], [20, 10]], value_added = [3, 1]
Output: ([0.9, 0.57], [5.0877193, 7.89473684])
Explanation: good 2 uses 1.2 crates of good 1 per crate, yet the valley is productive.

Input:  A = [[75, 75], [30, 10]], value_added = [1, 1]
Output: ([0.25, 0.0], None)
Explanation: 0.25 * 0.9 - 0.75 * 0.3 = 0 exactly: the second minor is not positive.

Constraints

  • answers are compared with an absolute and relative tolerance of 1e-6; do not round

Goals

  • Test whether an input-output economy is productive from the leading principal minors of $I - A$
  • Compute determinants exactly with `fractions.Fraction`, so a minor of exactly 0 is recognised
  • Solve the price equation $p = pA + v$, the dual of the quantity model, by elimination
Starting Python…