diff --git a/diffcp/cone_program.py b/diffcp/cone_program.py index 9919108..fcd0c5f 100644 --- a/diffcp/cone_program.py +++ b/diffcp/cone_program.py @@ -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 @@ -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: @@ -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'] != []): @@ -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)) 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]