From d90a1417db200df498d2486ce53aebd5672edd8d Mon Sep 17 00:00:00 2001 From: Parth Nobel Date: Sat, 9 Nov 2024 12:12:36 -0800 Subject: [PATCH 1/3] Tries to add 3.12 support --- diffcp/cone_program.py | 26 +++++++++----------------- diffcp/cones.py | 11 ++--------- pyproject.toml | 6 +++--- 3 files changed, 14 insertions(+), 29 deletions(-) diff --git a/diffcp/cone_program.py b/diffcp/cone_program.py index 9919108..7fb12b7 100644 --- a/diffcp/cone_program.py +++ b/diffcp/cone_program.py @@ -2,11 +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 @@ -319,25 +316,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: @@ -367,6 +356,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'] != []): @@ -448,6 +439,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)) diff --git a/diffcp/cones.py b/diffcp/cones.py index eb7a32f..ec2bd95 100644 --- a/diffcp/cones.py +++ b/diffcp/cones.py @@ -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" @@ -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, diff --git a/pyproject.toml b/pyproject.toml index 7e7193d..f16fb6d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,8 +7,8 @@ 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"} @@ -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] From f9d23c37de1d0e293393ebf474c74fa3a9d4bcf4 Mon Sep 17 00:00:00 2001 From: Parth Nobel Date: Sat, 9 Nov 2024 12:16:54 -0800 Subject: [PATCH 2/3] Fixes some imports --- diffcp/cone_program.py | 1 - 1 file changed, 1 deletion(-) diff --git a/diffcp/cone_program.py b/diffcp/cone_program.py index 7fb12b7..fcd0c5f 100644 --- a/diffcp/cone_program.py +++ b/diffcp/cone_program.py @@ -4,7 +4,6 @@ import numpy as np import scipy.sparse as sparse -from distutils.version import StrictVersion from threadpoolctl import threadpool_limits import _diffcp From e12b844ce9e19050cbd3ed084b6092a081d592e1 Mon Sep 17 00:00:00 2001 From: Parth Nobel Date: Sat, 9 Nov 2024 12:28:27 -0800 Subject: [PATCH 3/3] Bumps version number --- diffcp/__init__.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/diffcp/__init__.py b/diffcp/__init__.py index 017eb6e..bc76412 100644 --- a/diffcp/__init__.py +++ b/diffcp/__init__.py @@ -1,4 +1,4 @@ -__version__ = "1.1.0" +__version__ = "1.1.1" from diffcp.cone_program import solve_and_derivative, \ solve_and_derivative_batch, \ diff --git a/pyproject.toml b/pyproject.toml index f16fb6d..6458ff2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [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"