# LODS GurobiAssignment 2023

```JBM035: Linear Optimization for Data Science 2023
Pieter Kleer
P. S . KLEER @ TILBURGUNIVERSITY. EDU
Gurobi Assignment
Deadline: Friday, July 7, 23:59 (CEST), 2023
General instructions
◦ This assignment is made individually. You can discuss it with other students, but you
have to write the code yourself1 , and you should be able to explain what was handed in
upon request. Plagiarism or fraude (of any kind) will result in a grade of 0, possible
exclusion from the course, and reported to the Examination Board.
◦ You are allowed to use all functionality that Gurobi and Python have to offer.
◦ Apart from correctly solving the problems, your submission is also assessed on coding
style &amp; documentation. This means that you should try to apply the materials from the
◦ If you have questions, send an e-mail to P. S . KLEER @ TILBURGUNIVERSITY. EDU.
What to hand in?
You have to hand in a Jupyter notebook (.ipynb) file containing your code and documentation.
◦ Clearly indicate where you answer which question!
◦ Clearly explain what you do in your code.
Late submissions automatically get grade 0 (no discussion possible).
1 Meaning
also no help of (AI-driven) chatbots or programs such as ChatGPT.
Decreasing CO2 emissions
Variation on Exercise 6 of Lectures 1-2
The Dutch government wants to decrease CO2 emissions in The Netherlands by an additional
15% in the period 2021–2030. Studies have revealed that there are five key areas where new
government policies will lead to emission reductions, namely: Industry Efficiency Standards,
Carbon Pricing, Industrial Emissions Policies, Power Sector Policies, and Land Use.
Each one of these policy areas could give some reduction in CO2 emissions (as shown in Table
1), and the government has estimates of what each policy will cost to achieve a 1% reduction in
emissions (also shown in Table 1). The government wants to fund the different areas in order
to achieve at least f % of reductions in emissions in total. In order to make sure the money is
spread somewhat evenly, every area can obtain at most g times the amount of funding that any
other area gets. The parameters f and g are general input parameters that will be chosen later.
Industry Efficiency
Standards
Carbon
Pricing
Industrial Emissions
Policies
Power Sector
Policies
Land
Use
16.3
25.8
10.3
11.2
14.7
5.3
7.2
3.8
2.7
6.1
maximum
reduction (%):
Cost of 1%
reduction
(Billion e):
Table 1: Details on the emission reduction policies.
To formulate this problem as an LOP, we introduce the indices
1. Industry Efficiency Standards,
2. Carbon Pricing,
3. Industrial Emissions Policies,
4. Power Sector Policies,
5. Land Use.
We have the following input data
◦ mi : maximum possible reduction from policy i (in %); see Table 1.
◦ ci : cost (billion e) of policy i to reduce a 1% reduction; see Table 1.
◦ f : CO2 emission reduction target (in %); can be chosen by user.
◦ g: Maximal (multiplicative) difference funding between two areas; can be chosen by user.
Decision variables are xi : amount of funding for policy i (in billion e).
The above problem can be modeled with the following LOP:
5
min
∑ xi
i=1
5
subject to
1
∑ ci xi ≥ f
i=1
xi ≤ ci mi
xi ≤ gx j
xi ≥ 0
(1)
i = 1, . . . , 5
i, j = 1, . . . , 5 with i 6= j
i = 1, . . . , 5.
1) [11 points, Tutorials 1 &amp; 2] Write a function POLICY that takes as input values for f and
g and outputs the optimized LOP above for the given values of f and g (together with the
input data as in Table 1). The output should be the optimized LO model.
Try to make efficient use of indices in your code. For example, try to make sure that: If
one of the input values (or policy names) is changed, then ideally you should only have to
change this at ONE point in your code. If you cannot achieve this, that is not a problem,
but this might cost you some points (this is the ”efficiency” part of your code that is also
being assessed).
2) [3 points] Run your function ten times on the input pairs ( f , g) with f = 15 and g ∈
{1, 2, . . . , 10} and give an overview of the objective values (not the variable values) for
every g.
Be efficient in your code, i.e., do not to copy-paste your function call ten times with a
different value of g (this is the ”efficiency” part that is being assessed).
The objective function should decrease as g increases. Explain why this is the case based
on the LOP formulation.
3) [2 points, Tutorial 3] Take f = 15 and g = 10. Argue, by looking at the (correct) shadow
price, how much extra funding would be needed if we raise the value of f to 16.
In order to simplify the funding policy the government is considering always funding an area a
multiple of five billion euros. That is
xi ∈ {0, 5, 10, 15, . . . , } for i = 1, . . . , 5.
(2)
4) [4 points, Tutorial 4] Create a new function POLICY SIMPLIFIED that takes as input
values f and g, and outputs the optimized LO model with the additional constraint (2).
You can copy your solution from 1) and adjust it accordingly. Hint: Introduce new integer
variables yi for i = 1, . . . , 5. Think of an appropriate constraint to link xi to yi so that (2)
is satisfied.
Optimize your function for f = 15 and g = 10. Which policy would you recommend to
the government, the original or the ”simplified” policy based on (2)?
◦ If you want to create a dictionary like
costs = {
’process-1’: 51,
’process-2’: 11,
’process-3’: 40,
}
as in Tutorial 2, you can create two lists
process = [’process-1’,’process-2’,’process-3’]
cost = [51,11,40]
and then use
dict(zip(process,cost))
to create the desired dictionary. This is useful whenever indices, like the processes in
this case, appear in multiple input data. By cleverly setting up indices like this, you
can write your input data very compactly as dictionaries.
```