Skip to content

Commit

Permalink
Finish Chp 3-1
Browse files Browse the repository at this point in the history
  • Loading branch information
FabsOliveira committed Jul 11, 2024
1 parent d9955ca commit a1fc5ab
Show file tree
Hide file tree
Showing 7 changed files with 312 additions and 149 deletions.
2 changes: 1 addition & 1 deletion course/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ parts:
- file: content/chapter_3/1-risk_modelling.md
# - caption: 'Robust optimisation'
# - caption: 'Decomposition methods'
- caption: 'Bibliography'
- caption: ' '
chapters:
- file: content/bibliography.md
68 changes: 35 additions & 33 deletions course/content/chapter_1/1-the_farmers_problem.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ We start with the classic example from {cite}`birge2011introduction`: the farmer

## The deterministic farmers problem

A farmer has 500 acres of land available for raising wheat, corn, and sugar beets. She needs at least 200 tons of wheat and 240 tons of corn for cattle feed. Cattle feed amounts can be raised on the farm or bought from a wholesale market. Sugar beet is raised for profit only. However, production above a 6000 ton quota has a lower sales price.
A farmer has 500 acres of land available for raising wheat, corn, and sugar beets. She needs at least 200 tons of wheat and 240 tons of corn for cattle feed. Cattle feed amounts can be raised on the farm or bought from a wholesale market. Sugar beet is raised for profit only. However, production above a 6000 ton quota has a lower sales price.

:::{table} Farmer's problem data
```{table} Farmer's problem data
:name: farmers_data
| | **Wheat** | **Corn** | **Sugar beets** |
|--------------------------|-----------------|----------------|--------------------------|
Expand All @@ -16,7 +16,7 @@ A farmer has 500 acres of land available for raising wheat, corn, and sugar beet
| **Selling price ($/ton)** | 170 | 150 | 36 (under 6000 ton) |
| | | | 10 (above 6000 ton) |
| **Purchase price ($/ton)** | 238 | 210 | - |
:::
```

The farmer's objective is to maximise its profit, whilst satisfying the cattle feed demand. For that, let $I=\braces{1:\text{wheat}, 2:\text{corn}, 3:\text{sugar beets}}$. Then, we can define the following decision variables:

Expand All @@ -28,19 +28,19 @@ With that, we can pose the farmer's problem as
```{math}
:label: farmers_deterministic
\begin{aligned}
\mini & 150x_1 + 230 x_2 + 260 x_3 + 238 y_1 + 210 y_2 \\ & - 170 w_1 - 150 w_2 - 36 w_3 - 10w_4 \\
\st & x_1 + x_2 + x_3 \le 500 \\
& 2.5x_1 + y_1 - w_1 \ge 200 \\
& 3 x_2 + y_2 - w_2 \ge 240 \\
& w_3 + w_4 \le 20x_3 \\
& w_3 \le 6000 \\
& x_i \ge 0, i \in I; y_i \ge 0, i \in I \setminus \braces{3}; w_i \ge 0, i \in I \cup \braces{4}.
\mini & 150x_1 + 230 x_2 + 260 x_3 + 238 y_1 + 210 y_2 \\ & - 170 w_1 - 150 w_2 - 36 w_3 - 10w_4 \\
\st & x_1 + x_2 + x_3 \le 500 \\
& 2.5x_1 + y_1 - w_1 \ge 200 \\
& 3 x_2 + y_2 - w_2 \ge 240 \\
& w_3 + w_4 \le 20x_3 \\
& w_3 \le 6000 \\
& x_i \ge 0, i \in I; y_i \ge 0, i \in I \setminus \braces{3}; w_i \ge 0, i \in I \cup \braces{4}.
\end{aligned}
```

The optimal strategy for the farmer's problem [](farmers_deterministic) is given by

:::{table} Optimal solution considering average yields
```{table} Optimal solution considering average yields
:name: farmers_optimal_avg
| | **Wheat** | **Corn** | **Sugar beets** |
|--------------------|-----------|----------|-----------------|
Expand All @@ -49,52 +49,52 @@ The optimal strategy for the farmer's problem [](farmers_deterministic) is given
| **Sales** | 100 | - | 6000 |
| **Purchase** | - | - | - |
| **Overall profit:**| | | **$118,600** |
:::
```

You can notice that there is a straightforward strategy for the farmer to follow:

1. Plant the "just-right" amount of sugar beets to reach the quota;
2. Satisfy the minimum requirements for cattle feed;
3. Plant the remaining land with wheat.

Notice how ths optimal strategy is sensitive to the crop yields per acre planted. As one may suspect, small variations in these numbers can render this strategy not optimal anymore.
Notice how ths optimal strategy is sensitive to the crop yields per acre planted. As one may suspect, small variations in these numbers can render this strategy not optimal anymore.

:::{admonition} Strategy vs. policy
```{admonition} Strategy vs. policy
:class: note
In our context, the terms strategy and policy have the same meaning: a set of instructions that define a certain course of action.
:::
```

## Considering multiple scenarios individually

To illustrate what this means, let us consider that crop yields can fluctuate $\pm$ 20% due to climate related factors such as solar incidence and rainfall. The most natural way to take into consideration such variation is to rely on the notion of *scenarios*, which essentially means solving the problem for different inputs (in this case different crop yields) and seeing how the optimal strategy changes.

Let us first consider that our yields are 20% higher than the average values listed in {numref}`farmers_data`. Then our optimal decisions become

:::{table} Optimal solution considering 20% higher yields
```{table} Optimal solution considering 20% higher yields
:name: farmers_optimal_20+
| | **Wheat** | **Corn** | **Sugar beets** |
|--------------------|-----------|----------|-----------------|
| **Surface** | 183.33 | 66.67 | 250 |
| **Yield** | 550 | 240 | 6000 |
| **Sales** | 350 | - | 6000 |
| **Purchase** | - | - | - |
| **Overall profit:**| | | **$167,667** |
:::
| **Overall profit:** | | | **$167,667** |
```

Notice how in this case, the original strategy still yields the optimal solution. Trivially what changes is that we allocate less land to steps 1 and 2 due to the higher yields, and are left with more land to plant wheat and sell.

Let us now consider the other scenario, in which the yields are instead 20% lower. In this case, we obtain the following optimal solution:

:::{table} Optimal solution considering 20% lower yields
```{table} Optimal solution considering 20% lower yields
:name: farmers_optimal_20-
| | **Wheat** | **Corn** | **Sugar beets** |
|--------------------|-----------|----------|-----------------|
| **Surface** | 100 | 25 | 375 |
| **Yield** | 200 | 60 | 6000 |
| **Sales** | - | - | 6000 |
| **Purchase** | - | 180 | - |
| **Overall profit:**| | | **$59,950** |
:::
| **Overall profit:** | | | **$59,950** |
```

The results in {numref}`farmers_optimal_20-` show that in this case, our optimal strategy changes in some way. Essentially, we are still following steps 1-3, but we never really reach step 3, as we are left with not enough land to satisfy our cattle feed constraints. As corn is cheaper to buy than wheat, we focus on fulfilling the need for wheat and plant the reminder of the land with corn, complementing it with an amount of 180 tons from the market.

Expand All @@ -116,7 +116,7 @@ To formulate the farmer's problem as such, we must first define a set of yield s

Finally, our reformulated model becomes

:::{math}
```{math}
:label: farmers_stochastic
\begin{aligned}
\mini & 150x_1 + 230 x_2 + 260 x_3 +~ \\
Expand All @@ -130,42 +130,44 @@ Finally, our reformulated model becomes
& w_{31} \le 6000, w_{32} \le 6000, w_{33} \le 6000 \\
& x_i \ge 0, i \in I; y_{is} \ge 0, i \in I \setminus \braces{3}, s \in S; w_{is} \ge 0, i \in I \cup \braces{4}, s \in S.
\end{aligned}
:::
```

The optimal solution to {eq}`farmers_stochastic` is given by

:::{table} Optimal solution considering the three scenarios simultaneously
```{table} Optimal solution considering the three scenarios simultaneously
:name: farmers_optimal_2ssp
| | | **Wheat** | **Corn** | **Sugar beets** |
|------|---------------|-----------|----------|-----------------|
| | **Surface** | 170 | 80 | 250 |
|------|---------------|-----------|----------|-----------------|
| $s=1$| **Yield** | 340 | 192 | 4000 |
| | **Sales** | 140 | - | 4000 |
| | **Purchase** | - | 48 | - |
|------|---------------|-----------|----------|-----------------|
| $s=2$| **Yield** | 422 | 240 | 5000 |
| | **Sales** | 225 | - | 5000 |
| | **Purchase** | - | - | - |
|------|---------------|-----------|----------|-----------------|
| $s=3$| **Yield** | 510 | 288 | 6000 |
| | **Sales** | 310 | 48 | 6000 |
| | **Purchase** | - | - | - |
|------|---------------|-----------|----------|-----------------|
| | **Overall profit:** | | | **$108,390** |
:::
| | **Overall profit:** | | | **$108,390** |
```

Notice that this model has a few remarkable features. First of all, notice that by considering all scenarios *simultaneously* and marking some decisions to be scenario-dependent while others are not, the farmer is effectively exploiting the *timing* making decisions and observing the realisation of the uncertainties.

:::{admonition} Non-anticipativity and temporal causality
```{admonition} Non-anticipativity and temporal causality
:class: note
In this simple example, having variables that depend on the scenarios imply that they are decided with the knowledge from observing the uncertainty revelation.
In contrast, variables that do not depend on the scenarios are implicitly decided without knowing which realisation occured. In other words, they cannot anticipate the uncertainty, thus satisfying temporal causality.
:::
```

Moreover, the farmer's land allocation decisions are such that they are *hedging* against the fact that, ultimately, the farmer cannot know which scenario will indeed occur. Naturally, this hedging comes with a "price" that is paid in comparison to the setting where th farmer can perfectly match the land allocation to the crop yields.

Effectively, this encoding of the dynamics between decision-making and uncertainty observations is the one of the main focus of *stochastic programming*, i.e., how to incorporate within the model the notion of sequential decisions which are made prior or after information about the uncertainty becomes available.

%TODO: Include diagram with the farmers's first and second stge decisions.
%TODO: Include diagram with the farmers's first and second stge decisions.
```{figure} ../figures/2-stage.svg
:align: center
:scale: 100%

Schematic representation of the farmer's two-stage decision process
```
2 changes: 1 addition & 1 deletion course/content/chapter_2/4-sample_average_approximation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The method was first analysed in the context of stochastic programming models in

When employing SAA, we are taking an alternative approach in which, instead of solving one single problem considering $|\xi|$ scenarios (or $\eta$, assuming $\eta$ discrete and finite), we solve multiple $M$ problems, each with scenario trees of size $N << |\xi|$.

```{figure} ../figures/SAA-scheme.drawio.svg
```{figure} ../figures/SAA-scheme.svg
:align: center
:scale: 100%

Expand Down
57 changes: 0 additions & 57 deletions course/content/figures/.$spro_diagrams.drawio.bkp

This file was deleted.

92 changes: 92 additions & 0 deletions course/content/figures/2-stage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 99 additions & 0 deletions course/content/figures/SAA-scheme.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a1fc5ab

Please sign in to comment.