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

Add Problem.load and expose Problem #103

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Added

* Expose `Problem` from top-level module
* `Problem.load` utility function

## [2.0.0] - 2023-12-11

### Added
Expand Down
2 changes: 2 additions & 0 deletions qpbenchmark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

"""Benchmark for quadratic programming solvers available in Python."""

from .problem import Problem
from .report import Report
from .results import Results
from .run import run
Expand All @@ -27,6 +28,7 @@
__version__ = get_version()

__all__ = [
"Problem",
"Report",
"Results",
"TestSet",
Expand Down
21 changes: 21 additions & 0 deletions qpbenchmark/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,24 @@ def to_sparse(self):
self.ub,
name=self.name,
)

@staticmethod
def load(file: str, name: str):
"""Load problem from file.

Args:
file: Path to the file to read.
name: Problem name.
"""
loaded = qpsolvers.Problem.load(file)
return Problem(
loaded.P,
loaded.q,
loaded.G,
loaded.h,
loaded.A,
loaded.b,
loaded.lb,
loaded.ub,
name,
)