From a1fc5ab214492d74e97cef4791034407d82f177a Mon Sep 17 00:00:00 2001 From: Fabricio Oliveira Date: Thu, 11 Jul 2024 18:03:10 +0300 Subject: [PATCH] Finish Chp 3-1 --- course/_toc.yml | 2 +- .../chapter_1/1-the_farmers_problem.md | 68 +++++---- .../4-sample_average_approximation.md | 2 +- .../figures/.$spro_diagrams.drawio.bkp | 57 ------- course/content/figures/2-stage.svg | 92 ++++++++++++ course/content/figures/SAA-scheme.svg | 99 ++++++++++++ course/content/figures/spro_diagrams.drawio | 141 +++++++++++------- 7 files changed, 312 insertions(+), 149 deletions(-) delete mode 100644 course/content/figures/.$spro_diagrams.drawio.bkp create mode 100644 course/content/figures/2-stage.svg create mode 100644 course/content/figures/SAA-scheme.svg diff --git a/course/_toc.yml b/course/_toc.yml index 068e33b..6c4c869 100644 --- a/course/_toc.yml +++ b/course/_toc.yml @@ -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 \ No newline at end of file diff --git a/course/content/chapter_1/1-the_farmers_problem.md b/course/content/chapter_1/1-the_farmers_problem.md index 1365b6d..0b230ac 100644 --- a/course/content/chapter_1/1-the_farmers_problem.md +++ b/course/content/chapter_1/1-the_farmers_problem.md @@ -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** | |--------------------------|-----------------|----------------|--------------------------| @@ -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: @@ -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** | |--------------------|-----------|----------|-----------------| @@ -49,7 +49,7 @@ 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: @@ -57,12 +57,12 @@ You can notice that there is a straightforward strategy for the farmer to follow 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 @@ -70,7 +70,7 @@ To illustrate what this means, let us consider that crop yields can fluctuate $\ 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** | |--------------------|-----------|----------|-----------------| @@ -78,14 +78,14 @@ Let us first consider that our yields are 20% higher than the average values lis | **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** | |--------------------|-----------|----------|-----------------| @@ -93,8 +93,8 @@ Let us now consider the other scenario, in which the yields are instead 20% lowe | **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. @@ -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 +~ \\ @@ -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. \ No newline at end of file +%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 +``` \ No newline at end of file diff --git a/course/content/chapter_2/4-sample_average_approximation.md b/course/content/chapter_2/4-sample_average_approximation.md index 4bee331..3b8594a 100644 --- a/course/content/chapter_2/4-sample_average_approximation.md +++ b/course/content/chapter_2/4-sample_average_approximation.md @@ -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% diff --git a/course/content/figures/.$spro_diagrams.drawio.bkp b/course/content/figures/.$spro_diagrams.drawio.bkp deleted file mode 100644 index 2bf6fd5..0000000 --- a/course/content/figures/.$spro_diagrams.drawio.bkp +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/course/content/figures/2-stage.svg b/course/content/figures/2-stage.svg new file mode 100644 index 0000000..2ce7f25 --- /dev/null +++ b/course/content/figures/2-stage.svg @@ -0,0 +1,92 @@ +
Decide land
allocation
Decide land...
Decide purchase
and sale
Decide purchase...
Decide purchase
and sale
Decide purchase...
Decide purchase
and sale
Decide purchase...
$$s=1$$
$$s=2$$
$$s=3$$
Text is not SVG - cannot display
\ No newline at end of file diff --git a/course/content/figures/SAA-scheme.svg b/course/content/figures/SAA-scheme.svg new file mode 100644 index 0000000..8a7d1cf --- /dev/null +++ b/course/content/figures/SAA-scheme.svg @@ -0,0 +1,99 @@ + + + + + + + + \ No newline at end of file diff --git a/course/content/figures/spro_diagrams.drawio b/course/content/figures/spro_diagrams.drawio index b35e73e..c47f21b 100644 --- a/course/content/figures/spro_diagrams.drawio +++ b/course/content/figures/spro_diagrams.drawio @@ -1,57 +1,84 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file