Open danielhuppmann opened 7 months ago
The single Python function, optimize_energy_allocation
, which is found in the optimization.py
file, uses linear programming to optimize the allocation of energy from different sources to minimize cost.
The function takes three inputs:
Pwind
: A list of available wind power for each hour of the day.Ppv
: A list of available photovoltaic (solar) power for each hour of the day.Load
: A list of the load or energy demand for each hour of the day.It defines three sets of variables, x_wind
, x_pv
, and x_fuel_cell
, representing the amount of energy allocated from wind, solar, and fuel cell sources respectively for each hour of the day.
The objective of the function is to minimize the total cost of energy, which is calculated as the sum of the cost of energy from each source for each hour. The costs per unit of energy from wind, solar, and fuel cell are assumed to be 0.4, 0.35, and 0.9 respectively.
The function imposes constraints to ensure that the total energy allocated meets the load demand for each hour (x_wind[i] + x_pv[i] + x_fuel_cell[i] >= Load[i]
) and that the energy allocated from wind and solar does not exceed the available power (x_wind[i] <= Pwind[i]
and x_pv[i] <= Ppv[i]
).
The function solves the linear programming problem and returns the optimal energy allocation from each source for each hour of the day.
This function could be used in a microgrid management system to optimally allocate energy from different sources in order to minimize cost while meeting the energy demand. It assumes that the available power from wind and solar and the load demand are known for each hour. The function uses the PuLP library for Python to define and solve the linear programming problem.
Run tests
(pytest.yml
) and Ruff
(ruff.yml
) Workflows fail in the upstream repository, I did not have to edit the code in order to bring the workflows to failure in both cases. The pull request was thereby declined as my fork didn't contain any changes.Ruff
(ruff.yml
) Workflow fails in the upstream repository.Run tests
(pytest.yml
) Workflow fails in the upstream repository.Submission of second homework assignment, @danielhuppmann. Thank you!
Please review, @404milan