-
-
Notifications
You must be signed in to change notification settings - Fork 46.7k
Add Primal-Dual Interior-Point Method for linear programming #11497
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
max_iter (int): Maximum number of iterations. | ||
""" | ||
|
||
def __init__(self, c: np.ndarray, a: np.ndarray, b: np.ndarray, tol: float = 1e-8, max_iter: int = 100) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide descriptive name for the parameter: c
Please provide descriptive name for the parameter: a
Please provide descriptive name for the parameter: b
if not self._is_valid_input(): | ||
raise ValueError("Invalid input for the linear programming problem.") | ||
|
||
def _is_valid_input(self) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file linear_programming/interior_point_method.py
, please provide doctest for the function _is_valid_input
"""Validate the input for the linear programming problem.""" | ||
return (self.a.shape[0] == self.b.shape[0]) and (self.a.shape[1] == self.c.shape[0]) | ||
|
||
def _convert_to_standard_form(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide return type hint for the function: _convert_to_standard_form
. If the function does not return a value, please provide the type hint as: def function() -> None:
As there is no test file in this pull request nor any test function or class in the file linear_programming/interior_point_method.py
, please provide doctest for the function _convert_to_standard_form
c_standard = np.hstack([self.c, np.zeros(m)]) | ||
return a_standard, c_standard | ||
|
||
def solve(self) -> tuple[np.ndarray, float]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file linear_programming/interior_point_method.py
, please provide doctest for the function solve
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
if not self._is_valid_input(): | ||
raise ValueError("Invalid input for the linear programming problem.") | ||
|
||
def _is_valid_input(self) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file linear_programming/interior_point_method.py
, please provide doctest for the function _is_valid_input
self.constraint_matrix.shape[1] == self.objective_coefficients.shape[0] | ||
) | ||
|
||
def _convert_to_standard_form(self) -> tuple[np.ndarray, np.ndarray]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file linear_programming/interior_point_method.py
, please provide doctest for the function _convert_to_standard_form
c_standard = np.hstack([self.objective_coefficients, np.zeros(m)]) | ||
return a_standard, c_standard | ||
|
||
def solve(self) -> tuple[np.ndarray, float]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file linear_programming/interior_point_method.py
, please provide doctest for the function solve
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
if not self._is_valid_input(): | ||
raise ValueError("Invalid input for the linear programming problem.") | ||
|
||
def _is_valid_input(self) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file linear_programming/interior_point_method.py
, please provide doctest for the function _is_valid_input
and self.constraint_matrix.shape[1] == self.objective_coefficients.shape[0] | ||
) | ||
|
||
def _convert_to_standard_form(self) -> tuple[np.ndarray, np.ndarray]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file linear_programming/interior_point_method.py
, please provide doctest for the function _convert_to_standard_form
c_standard = np.hstack([self.objective_coefficients, np.zeros(m)]) | ||
return a_standard, c_standard | ||
|
||
def solve(self) -> tuple[np.ndarray, float]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file linear_programming/interior_point_method.py
, please provide doctest for the function solve
b2e80cf
to
12c29ce
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
if not self._is_valid_input(): | ||
raise ValueError("Invalid input for the linear programming problem.") | ||
|
||
def _is_valid_input(self) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file linear_programming/interior_point_method.py
, please provide doctest for the function _is_valid_input
and self.constraint_matrix.shape[1] == self.objective_coefficients.shape[0] | ||
) | ||
|
||
def _convert_to_standard_form(self) -> tuple[np.ndarray, np.ndarray]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file linear_programming/interior_point_method.py
, please provide doctest for the function _convert_to_standard_form
c_standard = np.hstack([self.objective_coefficients, np.zeros(m)]) | ||
return a_standard, c_standard | ||
|
||
def solve(self) -> tuple[np.ndarray, float]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file linear_programming/interior_point_method.py
, please provide doctest for the function solve
a9093fc
to
e486852
Compare
for more information, see https://pre-commit.ci
Closing tests_are_failing PRs to prepare for Hacktoberfest 2024 |
Describe your change:
Checklist:
Description of the change:
This pull request adds an implementation of the Primal-Dual Interior-Point Method for solving linear programming problems. The method handles
>=
,<=
, and=
constraints and ensures each variablex1, x2, ... >= 0
.Changes:
InteriorPointMethod
class to solve linear programming problems using the Primal-Dual Interior-Point Method.Testing:
References: