From 2bb6176284a66cd090bf330ae0aaac2a8dc48a3e Mon Sep 17 00:00:00 2001
From: Robert Lanzafame <R.C.Lanzafame@tudelft.nl>
Date: Mon, 18 Nov 2024 07:12:01 +0100
Subject: [PATCH] Optimization updates to WS and PAs

---
 .../Week_2_4/PA/PA_2_4_A_gurobilicious.ipynb  |   4 +-
 content/Week_2_4/PA/PA_2_4_B_solution.ipynb   |   4 +-
 content/Week_2_4/PA/README.md                 |  13 +-
 content/Week_2_5/PA/README.md                 |  18 ++
 .../Week_2_5/WS_2_5_planet_vs_profit.ipynb    | 223 ------------------
 content/Week_2_5/WS_2_5_solution.ipynb        | 154 +++++++-----
 6 files changed, 132 insertions(+), 284 deletions(-)
 delete mode 100644 content/Week_2_5/WS_2_5_planet_vs_profit.ipynb

diff --git a/content/Week_2_4/PA/PA_2_4_A_gurobilicious.ipynb b/content/Week_2_4/PA/PA_2_4_A_gurobilicious.ipynb
index 2a5bf14f..cb33bcf6 100644
--- a/content/Week_2_4/PA/PA_2_4_A_gurobilicious.ipynb
+++ b/content/Week_2_4/PA/PA_2_4_A_gurobilicious.ipynb
@@ -5,7 +5,7 @@
    "id": "c96d6259-08d6-4289-aea2-589d67cdb5ee",
    "metadata": {},
    "source": [
-    "# Programming Assignment 12A: Gurobi Environment and License\n",
+    "# PA 2.4A: Gurobi Environment and License\n",
     "\n",
     "<h1 style=\"position: absolute; display: flex; flex-grow: 0; flex-shrink: 0; flex-direction: row-reverse; top: 60px;right: 30px; margin: 0; border: 0\">\n",
     "    <style>\n",
@@ -18,7 +18,7 @@
     "<h2 style=\"height: 10px\">\n",
     "</h2>\n",
     "\n",
-    "*[CEGM1000 MUDE](http://mude.citg.tudelft.nl/): Week 2.4. Due: complete this PA prior to class on Friday, Dec 8, 2023.*"
+    "*[CEGM1000 MUDE](http://mude.citg.tudelft.nl/): Week 2.4. Due: complete this PA prior to class on Friday, Dec 6, 2024.*"
    ]
   },
   {
diff --git a/content/Week_2_4/PA/PA_2_4_B_solution.ipynb b/content/Week_2_4/PA/PA_2_4_B_solution.ipynb
index 7ae9df26..9b597997 100644
--- a/content/Week_2_4/PA/PA_2_4_B_solution.ipynb
+++ b/content/Week_2_4/PA/PA_2_4_B_solution.ipynb
@@ -5,7 +5,7 @@
    "id": "c96d6259-08d6-4289-aea2-589d67cdb5ee",
    "metadata": {},
    "source": [
-    "# Programming Assignment 12B: [Axis of Awesome](https://youtu.be/5pidokakU4I?si=Y5ewcgPFFQ5cLmC6)\n",
+    "# PA 2.4B: [Axis of Awesome](https://youtu.be/5pidokakU4I?si=Y5ewcgPFFQ5cLmC6)\n",
     "\n",
     "<h1 style=\"position: absolute; display: flex; flex-grow: 0; flex-shrink: 0; flex-direction: row-reverse; top: 60px;right: 30px; margin: 0; border: 0\">\n",
     "    <style>\n",
@@ -18,7 +18,7 @@
     "<h2 style=\"height: 10px\">\n",
     "</h2>\n",
     "\n",
-    "*[CEGM1000 MUDE](http://mude.citg.tudelft.nl/): Week 2.4. Due: complete this PA prior to class on Friday, Dec 8, 2023.*"
+    "*[CEGM1000 MUDE](http://mude.citg.tudelft.nl/): Week 2.4. Due: complete this PA prior to class on Friday, Dec 6, 2024.*"
    ]
   },
   {
diff --git a/content/Week_2_4/PA/README.md b/content/Week_2_4/PA/README.md
index 72e02ac1..d8a6842f 100644
--- a/content/Week_2_4/PA/README.md
+++ b/content/Week_2_4/PA/README.md
@@ -1,7 +1,18 @@
-# PA12 Information, Week 2.4
+# PA 2.4
 
 _[CEGM1000 MUDE](http://mude.citg.tudelft.nl/), Time Series Analysis, Week 4 of Quarter 2._
 
+
+
+- This week we will install the software Gurobi, which is required for optimization topic next week. This is to give you enough time to solve any problems with the installation. Next week we will learn how to use it.
+
+
+
+
+
+
+
+
 This week the programming assignment is based on three files:
 - `README.md`: instructions for PA12 and environment creation (this document)
 - `PA12A_gurobilicious.ipynb`: set-up of Gurobi software for Week 2.5 (optimization) with a new conda environment
diff --git a/content/Week_2_5/PA/README.md b/content/Week_2_5/PA/README.md
index f8eda229..3a07a875 100644
--- a/content/Week_2_5/PA/README.md
+++ b/content/Week_2_5/PA/README.md
@@ -2,6 +2,24 @@
 
 _[CEGM1000 MUDE](http://mude.citg.tudelft.nl/), Optimization, Week 5 of Quarter 2._
 
+
+
+updates for 2024:
+- environment stuff may be reduced
+- need to address optimizing the model and adding constraints
+- should probably also address the "running notebook cells out of order" issue directly
+- can remove pandas part if the rest is too big
+
+
+
+
+
+
+
+
+
+
+
 This week the programming assignment will illustrate some good practics for managing data sets in a git repostiroy. It is based on two files:
 - `README.md`: environment deletion and combining datasets with Git (this document).
 - `PA13_data_process.ipynb`: a brief intro to pandas to help us process and manage our data.
diff --git a/content/Week_2_5/WS_2_5_planet_vs_profit.ipynb b/content/Week_2_5/WS_2_5_planet_vs_profit.ipynb
deleted file mode 100644
index b01528ab..00000000
--- a/content/Week_2_5/WS_2_5_planet_vs_profit.ipynb
+++ /dev/null
@@ -1,223 +0,0 @@
-{
- "cells": [
-  {
-   "cell_type": "markdown",
-   "id": "61e3a843",
-   "metadata": {},
-   "source": [
-    "# WS13: Profit vs Planet\n",
-    "\n",
-    "<h1 style=\"position: absolute; display: flex; flex-grow: 0; flex-shrink: 0; flex-direction: row-reverse; top: 60px;right: 30px; margin: 0; border: 0\">\n",
-    "    <style>\n",
-    "        .markdown {width:100%; position: relative}\n",
-    "        article { position: relative }\n",
-    "    </style>\n",
-    "    <img src=\"https://gitlab.tudelft.nl/mude/public/-/raw/main/tu-logo/TU_P1_full-color.png\" style=\"width:100px\" />\n",
-    "    <img src=\"https://gitlab.tudelft.nl/mude/public/-/raw/main/mude-logo/MUDE_Logo-small.png\" style=\"width:100px\" />\n",
-    "</h1>\n",
-    "<h2 style=\"height: 10px\">\n",
-    "</h2>\n",
-    "\n",
-    "*[CEGM1000 MUDE](http://mude.citg.tudelft.nl/): Week 2.5, Optimization. For: December 13, 2023*"
-   ]
-  },
-  {
-   "attachments": {},
-   "cell_type": "markdown",
-   "id": "1c4b1a7a",
-   "metadata": {},
-   "source": [
-    "## Overview\n",
-    "\n",
-    "A civil engineering company wants to decide on the projects that they should do. Their objective is to minimize the environmental impact of their projects while making enough profit to keep the company running.\n",
-    "\n",
-    "They have a portfolio of 6 possible projects to invest in, where A, B , and C are new infrastructure projects (so-called type 1), and D, E, F are refurbishment projects (so-called type 2).\n",
-    "\n",
-    "The environmental impact of each project is given by $I_i$ where $i \\in [1,(...),6]$ is the index of the project. $I_i=[140,45,78,123,40,60]$\n",
-    "\n",
-    "The profit of each project is given by $P_i$ where $i\\in [1,(...),6]$ is the index of the project: $P_i=[123,65,99,143,33,99]$ \n",
-    "\n",
-    "The company wants to do 3 out of the 6 projects, therefore please formulate the mathematical program that allows solving the problem, also knowing that the projects of type 2 must be at least as many as the ones of type 1 and that the profit of all projects together must be $\\beta \\ge 250$.\n",
-    "\n",
-    "<b>You are not allowed to use ChatGPT for this task otherwise you won’t learn ;)</b>"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "15d6b3f0",
-   "metadata": {},
-   "source": [
-    "<div style=\"background-color:#AABAB2; color: black; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px; width: 95%\">\n",
-    "<p>\n",
-    "<b>Task 1: Writting the mathematical formulation</b>   \n",
-    "\n",
-    "Write down every formulation and constrain that is relevant to solve this optimization problem.\n",
-    "</p>\n",
-    "</div>"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Enter formulation here in $\\text{LaTeX}$ or insert a figure."
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "a1b35e97",
-   "metadata": {},
-   "source": [
-    "<div style=\"background-color:#AABAB2; color: black; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px; width: 95%\">\n",
-    "<p>\n",
-    "<b>Task 2: Setting up the problem</b>   \n",
-    "\n",
-    "Define any variables you might need to setup your model.\n",
-    "</p>\n",
-    "</div>"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 1,
-   "id": "d5cba9fe",
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "YOUR CODE HERE"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "<div style=\"background-color:#AABAB2; color: black; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px; width: 95%\">\n",
-    "<p>\n",
-    "<b>Task 3: Setting up the problem</b>   \n",
-    "\n",
-    "We'll continue using `gurobi` this week, which you've set up in last week's `PA12`. We'll use some other special packages as well. Therefor, create a new environment using `environment_MUDE_opt.yml` to continue today and on friday.\n",
-    "\n",
-    "</p>\n",
-    "</div>"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "789ed5ae",
-   "metadata": {},
-   "source": [
-    "<div style=\"background-color:#AABAB2; color: black; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px; width: 95%\">\n",
-    "<p>\n",
-    "<b>Task 4: Create the Gurobi model</b>   \n",
-    "\n",
-    "Create the Gurobi model, set your decision variables, your function and your constrains. Take a look at the book for an example implementation in Python if you don't know where to start.\n",
-    "</p>\n",
-    "</div>"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 2,
-   "id": "5a9bf052",
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "YOUR CODE HERE"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "1380916b",
-   "metadata": {},
-   "source": [
-    "<div style=\"background-color:#AABAB2; color: black; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px; width: 95%\">\n",
-    "<p>\n",
-    "<b>Task 5: Display your results</b>   \n",
-    "\n",
-    "Display the model in a good way to interpret and print the solution of the optimization.\n",
-    "</p>\n",
-    "</div>"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "YOUR CODE HERE"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "<div style=\"background-color:#AABAB2; color: black; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px; width: 95%\">\n",
-    "<p>\n",
-    "<b>Task 6: Additional constraint</b>   \n",
-    "\n",
-    "Solve the model with an additional constraint: if project 1 is done then the impact of all projects together should be lower than 𝛾 with 𝛾=150.\n",
-    "</p>\n",
-    "</div>"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "YOUR CODE HERE"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "99f8c4c4",
-   "metadata": {},
-   "source": [
-    "**End of notebook.**\n",
-    "<h2 style=\"height: 60px\">\n",
-    "</h2>\n",
-    "<h3 style=\"position: absolute; display: flex; flex-grow: 0; flex-shrink: 0; flex-direction: row-reverse; bottom: 60px; right: 50px; margin: 0; border: 0\">\n",
-    "    <style>\n",
-    "        .markdown {width:100%; position: relative}\n",
-    "        article { position: relative }\n",
-    "    </style>\n",
-    "    <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc-sa/4.0/\">\n",
-    "      <img alt=\"Creative Commons License\" style=\"border-width:; width:88px; height:auto; padding-top:10px\" src=\"https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png\" />\n",
-    "    </a>\n",
-    "    <a rel=\"TU Delft\" href=\"https://www.tudelft.nl/en/ceg\">\n",
-    "      <img alt=\"TU Delft\" style=\"border-width:0; width:100px; height:auto; padding-bottom:0px\" src=\"https://gitlab.tudelft.nl/mude/public/-/raw/main/tu-logo/TU_P1_full-color.png\"/>\n",
-    "    </a>\n",
-    "    <a rel=\"MUDE\" href=\"http://mude.citg.tudelft.nl/\">\n",
-    "      <img alt=\"MUDE\" style=\"border-width:0; width:100px; height:auto; padding-bottom:0px\" src=\"https://gitlab.tudelft.nl/mude/public/-/raw/main/mude-logo/MUDE_Logo-small.png\"/>\n",
-    "    </a>\n",
-    "    \n",
-    "</h3>\n",
-    "<span style=\"font-size: 75%\">\n",
-    "&copy; Copyright 2023 <a rel=\"MUDE Team\" href=\"https://studiegids.tudelft.nl/a101_displayCourse.do?course_id=65595\">MUDE Teaching Team</a> TU Delft. This work is licensed under a <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc-sa/4.0/\">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>."
-   ]
-  }
- ],
- "metadata": {
-  "kernelspec": {
-   "display_name": "Python 3 (ipykernel)",
-   "language": "python",
-   "name": "python3"
-  },
-  "language_info": {
-   "codemirror_mode": {
-    "name": "ipython",
-    "version": 3
-   },
-   "file_extension": ".py",
-   "mimetype": "text/x-python",
-   "name": "python",
-   "nbconvert_exporter": "python",
-   "pygments_lexer": "ipython3",
-   "version": "3.11.5"
-  }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/content/Week_2_5/WS_2_5_solution.ipynb b/content/Week_2_5/WS_2_5_solution.ipynb
index f36f443c..22ec559a 100644
--- a/content/Week_2_5/WS_2_5_solution.ipynb
+++ b/content/Week_2_5/WS_2_5_solution.ipynb
@@ -2,10 +2,10 @@
  "cells": [
   {
    "cell_type": "markdown",
-   "id": "61e3a843",
+   "id": "b3210984",
    "metadata": {},
    "source": [
-    "# WS13: Profit vs Planet\n",
+    "# WS 2.5: Profit vs Planet\n",
     "\n",
     "<h1 style=\"position: absolute; display: flex; flex-grow: 0; flex-shrink: 0; flex-direction: row-reverse; top: 60px;right: 30px; margin: 0; border: 0\">\n",
     "    <style>\n",
@@ -18,7 +18,7 @@
     "<h2 style=\"height: 10px\">\n",
     "</h2>\n",
     "\n",
-    "*[CEGM1000 MUDE](http://mude.citg.tudelft.nl/): Week 2.5, Optimization. For: December 13, 2023*"
+    "*[CEGM1000 MUDE](http://mude.citg.tudelft.nl/): Week 2.5, Optimization. For: December 11, 2024*"
    ]
   },
   {
@@ -34,12 +34,8 @@
     "\n",
     "The environmental impact of each project is given by $I_i$ where $i \\in [1,(...),6]$ is the index of the project. $I_i=[90,45,78,123,48,60]$\n",
     "\n",
-    "<div style=\"background-color:#facb8e; color: black; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px; width: 95%\"> <p>Please note that the values above have been changed in comparison with the original workshop that was provided in class; these updated values makes the optimization result more interesting.</p></div>\n",
-    "\n",
     "The profit of each project is given by $P_i$ where $i\\in [1,(...),6]$ is the index of the project: $P_i=[120,65,99,110,33,99]$\n",
     "\n",
-    "<div style=\"background-color:#facb8e; color: black; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px; width: 95%\"> <p>The values above have also been changed.</p></div>\n",
-    "\n",
     "The company wants to do 3 out of the 6 projects, therefore please formulate the mathematical program that allows solving the problem, also knowing that the projects of type 2 must be at least as many as the ones of type 1 and that the profit of all projects together must be greater or equal than $250$ ($\\beta$)\n",
     "\n",
     "<b>You are not allowed to use ChatGPT for this task otherwise you won’t learn ;)</b>"
@@ -66,7 +62,7 @@
    "source": [
     "<div style=\"background-color:#FAE99E; color: black; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px; width: 95%\">\n",
     "<p>\n",
-    "<b>Start solution.</b>\n",
+    "<b>Solution</b>\n",
     "\n",
     "$$Min(Z) \\sum_{i=1}^{6} x_i I_i $$\n",
     "\n",
@@ -86,6 +82,31 @@
     "</div>"
    ]
   },
+  {
+   "cell_type": "markdown",
+   "id": "d1f9f576",
+   "metadata": {},
+   "source": [
+    "<div style=\"background-color:#AABAB2; color: black; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px; width: 95%\">\n",
+    "<p>\n",
+    "<b>Task 2: Setting up the software</b>   \n",
+    "\n",
+    "We'll continue using Gurobi this week, which you've set up in last week's PA. We'll use some other special packages as well. Therefore, be sure to use the special conda environment created for this week.\n",
+    "\n",
+    "</p>\n",
+    "</div>"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "ae96cbb5",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "import gurobipy as gp"
+   ]
+  },
   {
    "cell_type": "markdown",
    "id": "a1b35e97",
@@ -93,7 +114,7 @@
    "source": [
     "<div style=\"background-color:#AABAB2; color: black; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px; width: 95%\">\n",
     "<p>\n",
-    "<b>Task 2: Setting up the problem</b>   \n",
+    "<b>Task 3: Setting up the problem</b>   \n",
     "\n",
     "Define any variables you might need to setup your model.\n",
     "</p>\n",
@@ -102,11 +123,14 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 11,
+   "execution_count": null,
    "id": "d5cba9fe",
    "metadata": {},
    "outputs": [],
    "source": [
+    "# YOUR_CODE_HERE\n",
+    "\n",
+    "# SOLUTION\n",
     "# Project data\n",
     "I = [90, 45, 78, 123, 48, 60]  # Environmental impact\n",
     "P = [120, 65, 99, 110, 33, 99]  # Profit\n",
@@ -123,17 +147,23 @@
   },
   {
    "cell_type": "markdown",
-   "id": "a032f86b",
+   "id": "88d658e6",
    "metadata": {},
    "source": [
-    "<div style=\"background-color:#AABAB2; color: black; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px; width: 95%\">\n",
-    "<p>\n",
-    "<b>Task 3: Setting up the problem</b>   \n",
+    "## Create model with Gurobi\n",
     "\n",
-    "We'll continue using `gurobi` this week, which you've set up in last week's `PA12`. We'll use some other special packages as well. Therefor, create a new environment using `environment_MUDE_opt.yml` to continue today and on friday.\n",
+    "Remember that examples of using Gurobi to create and optimize a model are provided in the online textbook, and generally consist of the following steps (the first instantiates a class and the rest are executed as methods of the class):\n",
     "\n",
-    "</p>\n",
-    "</div>"
+    "1. Define the model (instantiate the class)\n",
+    "2. Define variables\n",
+    "3. Define objective function\n",
+    "4. Add constraints\n",
+    "5. Optimize the model\n",
+    "\n",
+    "Remember, you can always ask for help to understand a function of gurobi\n",
+    "```\n",
+    "help(gurobipy.model.addVars)\n",
+    "```\n"
    ]
   },
   {
@@ -151,18 +181,31 @@
    ]
   },
   {
-   "cell_type": "code",
-   "execution_count": 12,
-   "id": "5a9bf052",
+   "cell_type": "markdown",
+   "id": "58f70d74",
    "metadata": {},
-   "outputs": [],
    "source": [
-    "import gurobipy as gp"
+    "<div style=\"background-color:#FAE99E; color: black; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px; width: 95%\">\n",
+    "<p>\n",
+    "<b>Solution.</b>\n",
+    "\n",
+    "Each line of code does the following:\n",
+    "\n",
+    "1. Create a Gurobi model\n",
+    "2. Add binary variables\n",
+    "3. Objective function: Minimize environmental impact\n",
+    "4. Constraint: Select exactly 3 projects\n",
+    "5. Constraint: Number of type 2 projects must be at least as many as type 1 projects selected\n",
+    "6. Constraint: Minimum profit requirement\n",
+    "7. Optimize the model\n",
+    "    \n",
+    "</p>\n",
+    "</div>"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 13,
+   "execution_count": null,
    "id": "8d008ba9",
    "metadata": {},
    "outputs": [
@@ -204,28 +247,19 @@
     }
    ],
    "source": [
-    "# Create a Gurobi model\n",
-    "model = gp.Model(\"Project_Selection\")\n",
+    "# YOUR_CODE_HERE\n",
     "\n",
-    "#You can always ask for help to understand a function of gurobi\n",
-    "#help(gurobipy.model.addVars)\n",
-    "\n",
-    "# Decision variables\n",
+    "# SOLUTION\n",
+    "model = gp.Model(\"Project_Selection\")\n",
     "x = model.addVars(num_projects, vtype=gp.GRB.BINARY, name=\"x\")\n",
-    "\n",
-    "# Objective function: Minimize environmental impact\n",
-    "model.setObjective(sum(I[i] * x[i] for i in range(num_projects)), gp.GRB.MINIMIZE)\n",
-    "\n",
-    "# Constraint: Select exactly 3 projects\n",
+    "model.setObjective(sum(I[i] * x[i] for i in range(num_projects)),\n",
+    "                   gp.GRB.MINIMIZE)\n",
     "model.addConstr(x.sum() == 3, \"Select_Projects\")\n",
-    "\n",
-    "# Constraint: Number of type 2 projects must be at least as many as type 1 projects selected\n",
-    "model.addConstr(sum(x[i] for i in range(num_type2_projects, num_projects)) - sum(x[i] for i in range(num_type1_projects)) >= 0, \"Type_Constraint\")\n",
-    "\n",
-    "# Constraint: Minimum profit requirement\n",
-    "model.addConstr(sum(P[i] * x[i] for i in range(num_projects)) >= beta, \"Minimum_Profit\")\n",
-    "\n",
-    "# Optimize the model\n",
+    "model.addConstr((sum(x[i] for i in range(num_type2_projects, num_projects))\n",
+    "                 - sum(x[i] for i in range(num_type1_projects)) >= 0),\n",
+    "                 \"Type_Constraint\")\n",
+    "model.addConstr(sum(P[i] * x[i] for i in range(num_projects)) >= beta,\n",
+    "                \"Minimum_Profit\")\n",
     "model.optimize()"
    ]
   },
@@ -245,7 +279,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 14,
+   "execution_count": null,
    "id": "83ef8b18",
    "metadata": {},
    "outputs": [
@@ -273,11 +307,13 @@
     }
    ],
    "source": [
+    "# YOUR_CODE_HERE\n",
+    "\n",
+    "# SOLUTION\n",
     "print(\"Model structure:\")        \n",
     "# see the model that you have built in a nice why to interpret\n",
     "model.display()  \n",
     "\n",
-    "# Display the solution\n",
     "if model.status == gp.GRB.OPTIMAL:\n",
     "    print(\"Optimal Solution:\")\n",
     "    for i in range(num_projects):\n",
@@ -301,7 +337,7 @@
     "\n",
     "Solve the model with an additional constraint: if project 1 is done then the impact of all projects together should be lower than $\\gamma$ with $\\gamma=130$.\n",
     "\n",
-    "> The value of $\\gamma$ has been changed with respect to the original workshop to make the optimization more interesting\n",
+    "In the first cell you should add the constraint, then in a second cell optimize the model.\n",
     "\n",
     "</p>\n",
     "</div>"
@@ -309,7 +345,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 15,
+   "execution_count": null,
    "id": "9f2f9b6d",
    "metadata": {},
    "outputs": [
@@ -325,14 +361,18 @@
     }
    ],
    "source": [
-    "#Additional constraint\n",
+    "# YOUR_CODE_HERE\n",
+    "\n",
+    "# SOLUTION\n",
     "gamma = 130\n",
-    "model.addConstr(sum(I[i] * x[i] for i in range(num_projects)) <= gamma * x[0] + M * (1 - x[0]), \"Impact_Constraint\") "
+    "model.addConstr((sum(I[i] * x[i] for i in range(num_projects))\n",
+    "                 <= gamma * x[0]+ M * (1 - x[0])),\n",
+    "                 \"Impact_Constraint\") "
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 16,
+   "execution_count": null,
    "id": "19040bd6",
    "metadata": {},
    "outputs": [
@@ -387,7 +427,9 @@
     }
    ],
    "source": [
-    "# Optimize the model\n",
+    "# YOUR_CODE_HERE\n",
+    "\n",
+    "# SOLUTION\n",
     "model.optimize()\n",
     "\n",
     "print(\"Model structure:\")        \n",
@@ -409,7 +451,7 @@
   },
   {
    "cell_type": "markdown",
-   "id": "99f8c4c4",
+   "id": "603aea77",
    "metadata": {},
    "source": [
     "**End of notebook.**\n",
@@ -420,19 +462,19 @@
     "        .markdown {width:100%; position: relative}\n",
     "        article { position: relative }\n",
     "    </style>\n",
-    "    <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc-sa/4.0/\">\n",
-    "      <img alt=\"Creative Commons License\" style=\"border-width:; width:88px; height:auto; padding-top:10px\" src=\"https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png\" />\n",
+    "    <a rel=\"license\" href=\"http://creativecommons.org/licenses/by/4.0/\">\n",
+    "      <img alt=\"Creative Commons License\" style=\"border-width:; width:88px; height:auto; padding-top:10px\" src=\"https://i.creativecommons.org/l/by/4.0/88x31.png\" />\n",
     "    </a>\n",
     "    <a rel=\"TU Delft\" href=\"https://www.tudelft.nl/en/ceg\">\n",
-    "      <img alt=\"TU Delft\" style=\"border-width:0; width:100px; height:auto; padding-bottom:0px\" src=\"https://gitlab.tudelft.nl/mude/public/-/raw/main/tu-logo/TU_P1_full-color.png\"/>\n",
+    "      <img alt=\"TU Delft\" style=\"border-width:0; width:100px; height:auto; padding-bottom:0px\" src=\"https://gitlab.tudelft.nl/mude/public/-/raw/main/tu-logo/TU_P1_full-color.png\" />\n",
     "    </a>\n",
     "    <a rel=\"MUDE\" href=\"http://mude.citg.tudelft.nl/\">\n",
-    "      <img alt=\"MUDE\" style=\"border-width:0; width:100px; height:auto; padding-bottom:0px\" src=\"https://gitlab.tudelft.nl/mude/public/-/raw/main/mude-logo/MUDE_Logo-small.png\"/>\n",
+    "      <img alt=\"MUDE\" style=\"border-width:0; width:100px; height:auto; padding-bottom:0px\" src=\"https://gitlab.tudelft.nl/mude/public/-/raw/main/mude-logo/MUDE_Logo-small.png\" />\n",
     "    </a>\n",
     "    \n",
     "</h3>\n",
     "<span style=\"font-size: 75%\">\n",
-    "&copy; Copyright 2023 <a rel=\"MUDE Team\" href=\"https://studiegids.tudelft.nl/a101_displayCourse.do?course_id=65595\">MUDE Teaching Team</a> TU Delft. This work is licensed under a <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc-sa/4.0/\">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>."
+    "&copy; Copyright 2024 <a rel=\"MUDE\" href=\"http://mude.citg.tudelft.nl/\">MUDE</a> TU Delft. This work is licensed under a <a rel=\"license\" href=\"http://creativecommons.org/licenses/by/4.0/\">CC BY 4.0 License</a>."
    ]
   }
  ],
-- 
GitLab