LP Example: Optimizing Resource Allocation


Lecture 16

October 11, 2023

Review and Questions

A While Ago…

A linear program (LP), has the following characteristics:

  • Linearity: The objective function and constraints are all linear;
  • Divisibility: The decision variables are continuous (they can be fractional levels);
  • Certainty: The problem is deterministic.

Simplex Method

Solutions to LPs must occur at intersections of constraints, which is the key insight for the simplex method.

Questions?

Poll Everywhere QR Code

Text: VSRIKRISH to 22333

URL: https://pollev.com/vsrikrish

See Results

Resource Allocation Example

Resource Allocation Problems

Resource Allocation Problems are a broad category of prescriptive environmental modeling.

Resource Allocation Schematic

Example: Pesticide Application

A farmer has access to a pesticide which can be used on corn, soybeans, and wheat fields, and costs $70/ha-yr to apply.

Example: Pesticide Application

The following crop yields can be obtained:

Application Rate (kg/ha) Soybean (kg/ha) Wheat (kg/ha) Corn (kg/ha)
0 2900 3500 5900
1 3800 4100 6700
2 4400 4200 7900

Example: Pesticide Application

Production costs, excluding pesticide, and selling prices:

Crop Production Cost ($/ha-yr) Selling Price ($/kg)
Soybeans 350 0.36
Wheat 280 0.27
Corn 390 0.22

Example: Pesticide Application

Recently, environmental authorities have declared that farms cannot have an average application rate on soybeans, wheat, and corn which exceeds 0.8, 0.7, and 0.6 kg/ha, respectively.

Question: How should the farmer plant crops and apply pesticides to maximize profits over 130 total ha while remaining in regulatory compliance if demand for each crop this year is 250,000 kg?

Problem Formulation

Decision Variables

The first step is to establish notation for our decision variables.

What Are Our Decision Variables?

Poll Everywhere QR Code

Text: VSRIKRISH to 22333

URL: https://pollev.com/vsrikrish

See Results

Decision Variables

Variable Meaning
\(S_j\) ha planted with soybeans and treated with pesticide rate \(j=0,1,2\) kg
\(W_j\) ha planted with wheat and treated with pesticide rate \(j=0,1,2\) kg
\(C_j\) ha planted with corn and treated with pesticide rate \(j=0,1,2\) kg

Objective Function

Next, let’s formulate the objective function.

The farmer’s goal is to maximize profits.

Take some time to work on this.

Objective Function

Key: Compute profit for each ha by crop and pesticide rate.

\[Z = \sum_{\text{crop}, i} \left[ (\text{yield} \times \text{selling price}) - \text{total cost} \right]\]

After some algebra:

\[\begin{align*} Z &= 694 S_0 + 948 S_1 + 1164 S_2 \\[0.25em] & \qquad + 665 W_0 + 757 W_1 + 784 W_2 \\[0.25em] & \qquad + 908 C_0 + 1014 C_1 + 1278 C_2 \end{align*}\]

Objective Function (Vector Notation)

Original: \[\begin{align*} Z &= 694 S_0 + 948 S_1 + 1164 S_2 \\[0.25em] & + 665 W_0 + 757 W_1 + 784 W_2 \\[0.25em] & + 908 C_0 + 1014 C_1 + 1278 C_2 \end{align*}\]

Vectorized: \[\begin{align*} Z &= \mathbf{S} \begin{pmatrix}694 \\ 948 \\ 1164 \end{pmatrix} + \mathbf{W} \begin{pmatrix}665 \\ 757 \\ 784 \end{pmatrix} \\[0.25em] & + \mathbf{C} \begin{pmatrix}908 \\ 1014 \\ 1278 \end{pmatrix} \end{align*}\]

Constraints

Finally, we need to establish our constraints.

What Are Our Constraints?

Poll Everywhere QR Code

Text: VSRIKRISH to 22333

URL: https://pollev.com/vsrikrish

See Results

What Are Our Constraints?

  • Land Area: total farmland cannot exceed 130 ha
  • Demand: No reason to grow more than 250,000 kg of any crop.
  • Regulation: Limits on average pesticide application for each crop.
  • Non-negativity: No land allocation can be less than 0.

Land Area Constraint

\[\sum_j S_j + C_j + W_j \leq 130\]

Can write this out more fully, but as you will see, JuMP.jl can handle these compact formulations (which makes debugging easier).

Demand Constraints

\[\begin{alignat*}{3} \text{Soybeans}:& \qquad &\mathbf{S} \begin{pmatrix}2900 \\ 3800 \\ 4400 \end{pmatrix} \leq 250000 \\ \text{Wheat}:& \qquad &\mathbf{W} \begin{pmatrix}3500 \\ 4100 \\ 4200 \end{pmatrix} \leq 250000 \\ \text{Corn}:& \qquad &\mathbf{C} \begin{pmatrix}5900 \\ 6700 \\ 7200 \end{pmatrix} \leq 250000 \end{alignat*}\]

Regulatory Constraints

For soybeans:

\[\frac{S_1 + 2 S_2}{S_0 + S_1 + S_2} \leq 0.8\]

Is this an acceptable constraint?

Regulatory Constraints

These need to be linear for a linear program.

\[\begin{align*} & \frac{S_1 + 2 S_2}{S_0 + S_1 + S_2} \leq 0.8 \\\\ & \quad \Rightarrow S_1 + 2S_2 \leq 0.8 (S_0 + S_1 + S_2) \\\\ & \quad \Rightarrow -0.8 S_0 + 0.2 S_1 + 1.2 S_2 \leq 0 \end{align*}\]

Regulatory Constraints

Similarly for wheat and corn:

\[\begin{align*} -0.7 W_0 + 0.3 W_1 + 1.3 W_2 & \leq 0 \\\\ -0.6 C_0 + 0.4 C_1 + 1.4 C_2 & \leq 0 \end{align*}\]

Non-Negativity Constraints

These are straightforward, but neglecting them can lead to numerical issues:

\[S_j, W_j, C_j \geq 0.\]

Final Model (Standard Form)

\[\begin{align} \max_{S_j, W_j, C_j} \quad & 694 S_0 + 948 S_1 + 1164 S_2 + 665 W_0 + 757 W_1 + 784 W_2 \tag{1} \\[-1em] & \qquad + 908 C_0 + 1014 C_1 + 1278 C_2 \\[0.5em] \text{subject to:} \quad & S_0 + S_1 + S_2 + W_0 + W_1 + W_2 + C_0 + C_1 + C_2 \leq 130 \tag{2} \\ & 2900 S_0 + 3800 S_1 + 4400 S_2 \leq 250000 \tag{3a} \\ & 3500 W_0 + 4100 W_1 + 4200 W_2 \leq 250000 \tag{3b}\\ & 5900 C_0 + 6700 C_1 + 7200 C_2 \leq 250000 \tag{3c}\\ & -0.8 S_0 + 0.2 S_1 + 1.2 S_2 \leq 0 \tag{4a}\\ & -0.7 W_0 + 0.3 W_1 + 1.3 W_2 \leq 0 \tag{4b}\\ & -0.6 C_0 + 0.4 C_1 + 1.4 C_2 \leq 0 \tag{4c}\\ & S_j, W_j, C_j \geq 0 \tag{5} \end{align}\]

Model Solution

Solution

Pesticide Application (kg/ha-yr) Soybeans (ha) Wheat (ha) Corn (ha)
0 13.8 26.9 6.7
1 55.2 0 15.7
2 0 11.5 0

This solution has an objective value of $117,549.

Shadow Prices

The following constraints have non-zero shadow prices:

  • Area (\(729\))
  • Soy Demand (\(4.6 \times 10^{-2}\))
  • Wheat Demand (\(4.5 \times 10^{-2}\))
  • Soy Pesticide (\(212\))
  • Wheat Pesticide (\(92\))
  • Corn Pesticide (\(140\))

Key Takeaways

Key Takeaways

  • Resource allocation problems can be formulated as mathematical programs (in this case, linear)
  • Saw example of formulating objective and constraints
  • Can learn about which constraints matter the most from shadow prices.

Upcoming Schedule

Next Classes

Friday/Monday: Electric power system decision problems (generating capacity expansion, unit commitment)