Skip to content
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/build_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ jobs:
cibw_archs: "auto"
- os: windows-2022
cibw_archs: "auto64"
# Include macos-13 to get Intel x86_64 macs and maos-latest to get the Aaarch64 macs
- os: macos-13
# Include macos-15-intel to get Intel x86_64 macs and macos-latest to get the Aaarch64 macs
- os: macos-15-intel
cibw_archs: "x86_64"
- os: macos-latest
cibw_archs: "arm64"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_mkl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
strategy:
fail-fast: false
matrix:
# macos-latest now uses arm64 runners, but MKL is x86_64 only, so restrict to the macos-13 runners
# macos-latest now uses arm64 runners, but MKL is x86_64 only, so restrict to the macos-15-intel runners
# to get x86_64 architecture.
os: [ubuntu-latest, macos-13]
os: [ubuntu-latest, macos-15-intel]

steps:
- uses: actions/checkout@master
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
cmake_minimum_required(VERSION 3.15...3.26)
project(ext)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(PYTHON "ON")
set(OSQP_BUILD_UNITTESTS "OFF")
set(OSQP_USE_LONG "OFF")
Expand Down
2 changes: 1 addition & 1 deletion cibuildwheel.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ before-build = "rm -rf {package}/osqp_sources/build"
# Install CPU-only version of torch beforehand since that allows cibuildwheel
# to satisfy the "test" dependency group install, but much faster. The runtime
# cost of torch-based osqp tests are considered negligible so torch-cpu is ok.
before-test = "pip install torch --index-url https://download.pytorch.org/whl/cpu"
before-test = 'pip install "scipy!=1.12.0,<1.17" && pip install torch --index-url https://download.pytorch.org/whl/cpu'
test-groups = ["test"]
test-command = "python -m pytest -s {project}/src/osqp/tests"
# 09/10/25 - Skip testing on cp313-manylinux_aarch64 because torch/numpy deps are unsatisfiable
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ cu12 = [
# support installation of torch at all, which is why it is useful to have this
# dependency group.
test-no-nn = ["pytest>=6"]
test = ["torch", "scipy!=1.12.0", { include-group = "test-no-nn" }]
test = ["torch", "scipy!=1.12.0,<1.17", { include-group = "test-no-nn" }]
dev = ["pre-commit", { include-group = "test" }]

[tool.scikit-build]
Expand Down
11 changes: 7 additions & 4 deletions src/bindings.cpp.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <iostream>
#include <memory>
#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>

Expand Down Expand Up @@ -132,6 +133,7 @@ class PyOSQPSolver {
const CSC& _A;
py::array_t<OSQPFloat> _u;
OSQPSolver *_solver;
std::unique_ptr<PyOSQPSolution> _solution_cache;
};

PyOSQPSolver::PyOSQPSolver(
Expand All @@ -143,8 +145,7 @@ PyOSQPSolver::PyOSQPSolver(
OSQPInt m,
OSQPInt n,
const OSQPSettings *settings
): m(m), n(n), _P(P), _A(A) {
this->_solver = new OSQPSolver();
): m(m), n(n), _P(P), _A(A), _solver(nullptr) {
this->_q = q;
this->_l = l;
this->_u = u;
Expand All @@ -164,8 +165,10 @@ OSQPSettings* PyOSQPSolver::get_settings() {
}

PyOSQPSolution& PyOSQPSolver::get_solution() {
PyOSQPSolution* solution = new PyOSQPSolution(*this->_solver->solution, this->m, this->n);
return *solution;
if (!_solution_cache) {
_solution_cache = std::make_unique<PyOSQPSolution>(*this->_solver->solution, this->m, this->n);
}
return *_solution_cache;
}

OSQPInfo* PyOSQPSolver::get_info() {
Expand Down
Loading