"*[CEGM1000 MUDE](http://mude.citg.tudelft.nl/): Week 2.5, Optimization. For: December 11, 2024*"
]
},
{
"cell_type": "markdown",
"id": "1c4b1a7a",
"metadata": {},
"source": [
"## Part 1: Overview and Mathematical Formulation\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=[90,45,78,123,48,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=[120,65,99,110,33,99]$\n",
"\n",
"The company is operating with the following constraints, please formulate the mathematical program that allows solving the problem:\n",
"\n",
"- The company wants to do 3 out of the 6 projects\n",
"- the projects of type 2 must be at least as many as the ones of type 1 \n",
"- the profit of all projects together must be greater or equal than $250$ ($\\beta$)"
"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",
"Define any variables you might need to setup your model.\n",
"</p>\n",
"</div>"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d5cba9fe",
"metadata": {},
"outputs": [],
"source": [
"# Project data\n",
"YOUR_CODE_HERE\n",
"\n",
"# Minimum required profit\n",
"YOUR_CODE_HERE\n",
"\n",
"# Number of projects and types\n",
"YOUR_CODE_HERE"
]
},
{
"cell_type": "markdown",
"id": "88d658e6",
"metadata": {},
"source": [
"## Part 2: Create model with Gurobi\n",
"\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",
"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",
"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",
"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",
"In the first cell you should add the constraint, then in a second cell optimize the model.\n",
*[CEGM1000 MUDE](http://mude.citg.tudelft.nl/): Week 2.5, Optimization. For: December 11, 2024*
%% Cell type:markdown id:1c4b1a7a tags:
## Part 1: Overview and Mathematical Formulation
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.
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).
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]$
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]$
The company is operating with the following constraints, please formulate the mathematical program that allows solving the problem:
- The company wants to do 3 out of the 6 projects
- the projects of type 2 must be at least as many as the ones of type 1
- the profit of all projects together must be greater or equal than $250$ ($\beta$)
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.**
Define any variables you might need to setup your model.
</p>
</div>
%% Cell type:code id:d5cba9fe tags:
``` python
# Project data
YOUR_CODE_HERE
# Minimum required profit
YOUR_CODE_HERE
# Number of projects and types
YOUR_CODE_HERE
```
%% Cell type:markdown id:88d658e6 tags:
## Part 2: Create model with Gurobi
**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):
1. Define the model (instantiate the class)
2. Define variables
3. Define objective function
4. Add constraints
5. Optimize the model
Remember, you can always ask for help to understand a function of gurobi
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.
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$.
In the first cell you should add the constraint, then in a second cell optimize the model.
"<b>Task 1: Writing the mathematical formulation</b> \n",
"\n",
"Write down every formulation and constrain that is relevant to solve this optimization problem.\n",
"Write down every formulation and constraint that is relevant to solve this optimization problem.\n",
"</p>\n",
"</div>"
]
...
...
@@ -95,7 +95,7 @@
"<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",
"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>"
...
...
@@ -103,7 +103,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 7,
"id": "ae96cbb5",
"metadata": {},
"outputs": [],
...
...
@@ -246,7 +246,7 @@
"\n",
" 0 0 cutoff 0 198.00000 198.00000 0.00% - 0s\n",
"\n",
"Explored 1 nodes (3 simplex iterations) in 0.05 seconds (0.00 work units)\n",
"Explored 1 nodes (3 simplex iterations) in 0.04 seconds (0.00 work units)\n",
"Thread count was 12 (of 12 available processors)\n",
"\n",
"Solution count 2: 198 228 \n",
...
...
@@ -289,7 +289,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"id": "83ef8b18",
"metadata": {},
"outputs": [
...
...
@@ -318,7 +318,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\jdding\\AppData\\Local\\Temp\\ipykernel_12768\\2324086517.py:6: DeprecationWarning: Model.display() is deprecated\n",
"C:\\Users\\jdding\\AppData\\Local\\Temp\\ipykernel_6080\\2324086517.py:6: DeprecationWarning: Model.display() is deprecated\n",
" model.display()\n"
]
}
...
...
@@ -418,7 +418,7 @@
"Presolve time: 0.00s\n",
"Presolve: All rows and columns removed\n",
"\n",
"Explored 0 nodes (0 simplex iterations) in 0.01 seconds (0.00 work units)\n",
"Explored 0 nodes (0 simplex iterations) in 0.02 seconds (0.00 work units)\n",
"Thread count was 1 (of 12 available processors)\n",
"\n",
"Solution count 1: 228 \n",
...
...
@@ -448,7 +448,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\jdding\\AppData\\Local\\Temp\\ipykernel_12768\\1357951651.py:8: DeprecationWarning: Model.display() is deprecated\n",
"C:\\Users\\jdding\\AppData\\Local\\Temp\\ipykernel_6080\\1357951651.py:8: DeprecationWarning: Model.display() is deprecated\n",
*[CEGM1000 MUDE](http://mude.citg.tudelft.nl/): Week 2.5, Optimization. For: December 11, 2024*
%% Cell type:markdown id:1c4b1a7a tags:
## Part 1: Overview and Mathematical Formulation
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.
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).
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]$
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]$
The company is operating with the following constraints, please formulate the mathematical program that allows solving the problem:
- The company wants to do 3 out of the 6 projects
- the projects of type 2 must be at least as many as the ones of type 1
- the profit of all projects together must be greater or equal than $250$ ($\beta$)
<b>You are not allowed to use ChatGPT for this task otherwise you won’t learn ;)</b>
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.
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.**
**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):
1. Define the model (instantiate the class)
2. Define variables
3. Define objective function
4. Add constraints
5. Optimize the model
Remember, you can always ask for help to understand a function of gurobi
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.
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$.
In the first cell you should add the constraint, then in a second cell optimize the model.