Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve cleanliness method print_infeasibilities() #354

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions linopy/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,12 +1162,24 @@ def compute_infeasibilities(self) -> list[int]:
labels.append(int(line_decoded.split(":")[0][2:]))
return labels

def print_infeasibilities(self, display_max_terms: None = None) -> None:
def print_infeasibilities(self, display_max_terms: int | None = None) -> None:
"""
Print a list of infeasible constraints.

This function requires that the model was solved with `gurobi` and the
termination condition was infeasible.
This function requires that the model was solved using `gurobi`
and the termination condition was infeasible.

Parameters
----------
display_max_terms : int, optional
The maximum number of infeasible terms to display. If `None`,
all infeasible terms will be displayed.

Returns
-------
None
This function does not return anything. It simply prints the
infeasible constraints.
"""
labels = self.compute_infeasibilities()
self.constraints.print_labels(labels, display_max_terms=display_max_terms)
Expand Down