Skip to content

PyPSA GlobalConstraints + Authorizing LB=UB#105

Merged
aoustry merged 37 commits intoAntaresSimulatorTeam:mainfrom
aoustry:main
Jun 12, 2025
Merged

PyPSA GlobalConstraints + Authorizing LB=UB#105
aoustry merged 37 commits intoAntaresSimulatorTeam:mainfrom
aoustry:main

Conversation

@aoustry
Copy link
Collaborator

@aoustry aoustry commented Jun 5, 2025

No description provided.

YassineAbdelouadoud and others added 30 commits May 9, 2025 16:54
Introduce a new test script to validate pypsa-eur data conversion logic. This ensures the system accurately handles PyPSA input files like those generated by PyPSA-EUR.
Commented out equality bound check in optimization logic while retaining the checks for invalid bounds. Introduced a comprehensive test script to convert and run PyPSA studies in Andromede, including utility functions for network adjustments and optimization problem building.
New test cases for the Generator model
Merge branch 'AntaresSimulatorTeam:main' into pypsa/global-constraint
aoustry and others added 3 commits June 4, 2025 10:53
Managing PyPSA GlobalConstraints related to CO2 emissions
@aoustry aoustry requested a review from tbittar June 5, 2025 07:34
f"Upper and lower bounds of variable {solver_var_name} have the same value: {lower_bound}"
)
elif lower_bound > upper_bound:
# if math.isclose(lower_bound, upper_bound):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comment

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

status = problem.solver.Solve()
assert status == problem.solver.INFEASIBLE # Infeasible

""" Test disabled: it is now authorized to have LB and UB with same value
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of disabling the test, you should keep it, and change the assert, i.e. check that the build runs without error / you manage to solve it with the correct output

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

self.pypsa_network.global_constraints.loc[pypsa_model_id, "type"]
== "primary_energy"
)
assert (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that you onlt handle global constraints representing co2 emissions for nnow ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now yes.

Comment on lines +171 to +175
self.pypsa_network.loads.index = (
self.pypsa_network.loads.index.astype(str) + "_load"
)
for key, val in self.pypsa_network.loads_t.items():
val.columns = val.columns + "_load"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate of lines 159-163 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes indeed

max_growth=any_to_float(inf),
)
self.pypsa_network.carriers[
"carrier"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intended to be "Carrier" or not ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No


def _convert_pypsa_components_of_given_model(
self, pysa_components_data: PyPSAComponentData
self, pypsa_components_data: PyPSAComponentData
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring of this function is not up to date

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not useful anymore ?


def extend_quota(network: Network) -> Network:
# Temporary function, used while the GlobalConstraint model is not implemented yet.
# Set the CO2 bound to very alrge value
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Set the CO2 bound to very alrge value
# Set the CO2 bound to very large value

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return network


def convert_pypsa_network(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this function is also used in test_pypsa_converter.py, you can put it in a file utils.py in this directory and import it from there

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return input_system_from_pypsa_converter


def build_problem_from_system(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@aoustry aoustry requested a review from tbittar June 10, 2025 13:29
@aoustry aoustry merged commit aaa61ff into AntaresSimulatorTeam:main Jun 12, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants