Skip to content

Adds 3.12 support #69

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

Merged
merged 3 commits into from
Nov 9, 2024
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
2 changes: 1 addition & 1 deletion diffcp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.1.0"
__version__ = "1.1.1"

from diffcp.cone_program import solve_and_derivative, \
solve_and_derivative_batch, \
Expand Down
27 changes: 9 additions & 18 deletions diffcp/cone_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
import warnings
from multiprocessing.pool import ThreadPool

import ecos
import clarabel
import numpy as np
import scipy.sparse as sparse
import scs
from distutils.version import StrictVersion
from threadpoolctl import threadpool_limits

import _diffcp
Expand Down Expand Up @@ -319,25 +315,17 @@ def solve_internal(A, b, c, cone_dict, solve_method=None,
solve_method = "ECOS"

if solve_method == "SCS":
import scs

# SCS versions SCS 2.*
if StrictVersion(scs.__version__) < StrictVersion('3.0.0'):
if "eps_abs" in kwargs or "eps_rel" in kwargs:
# Take the min of eps_rel and eps_abs to be eps
kwargs["eps"] = min(kwargs.get("eps_abs", 1),
kwargs.get("eps_rel", 1))

# SCS version 3.*
else:
if "eps" in kwargs: # eps replaced by eps_abs, eps_rel
kwargs["eps_abs"] = kwargs["eps"]
kwargs["eps_rel"] = kwargs["eps"]
del kwargs["eps"]
if "eps" in kwargs: # eps replaced by eps_abs, eps_rel
kwargs["eps_abs"] = kwargs["eps"]
kwargs["eps_rel"] = kwargs["eps"]
del kwargs["eps"]

data = {
"A": A,
"b": b,
"c": c
"c": c,
}

if warm_start is not None:
Expand Down Expand Up @@ -367,6 +355,8 @@ def solve_internal(A, b, c, cone_dict, solve_method=None,
return result

elif solve_method == "ECOS":
import ecos

if warm_start is not None:
raise ValueError('ECOS does not support warmstart.')
if ('s' in cone_dict) and (cone_dict['s'] != []):
Expand Down Expand Up @@ -448,6 +438,7 @@ def solve_internal(A, b, c, cone_dict, solve_method=None,
'iter': solution['info']['iter'],
'pobj': solution['info']['pcost']}
elif solve_method == "Clarabel":
import clarabel
# for now set P to 0
P = sparse.csc_matrix((c.size, c.size))

Expand Down
11 changes: 2 additions & 9 deletions diffcp/cones.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import numpy as np
import scipy.sparse as sparse
from _diffcp import project_exp_cone, Cone, ConeType
from distutils.version import StrictVersion
import scs

if StrictVersion(scs.__version__) >= StrictVersion('3.0.0'):
EQ_DIM = "z"
else:
EQ_DIM = "f"

ZERO = EQ_DIM
ZERO = "z"
POS = "l"
SOC = "q"
PSD = "s"
Expand All @@ -21,7 +14,7 @@

# Map from Python cones to CPP format
CONE_MAP = {
EQ_DIM: ConeType.ZERO,
"z": ConeType.ZERO,
"l": ConeType.POS,
"q": ConeType.SOC,
"s": ConeType.PSD,
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@

[project]
name = "diffcp"
version = "1.1.0"
version = "1.1.1"
description = "A library to compute gradients for convex optimization problems"
requires-python = ">= 3.10"

readme = "README.md"

requires = [
"threadpoolctl >= 1.1"
dependencies = [
"threadpoolctl >= 1.1",
]
urls = {Homepage = "https://github.com/cvxgrp/diffcp/"}
license = {text = "Apache License, Version 2.0"}
Expand All @@ -30,7 +30,7 @@ build-backend = "scikit_build_core.build"
test = [
"clarabel >= 0.5.1",
"ecos >= 2.0.10",
"scs >= 2.0.2",
"scs >= 3.0.0",
]

[tool.scikit-build]
Expand Down