diff --git a/lowpass_oracle_ai.cpp b/lowpass_oracle_ai.cpp index f683da7..92e1b54 100644 --- a/lowpass_oracle_ai.cpp +++ b/lowpass_oracle_ai.cpp @@ -160,4 +160,3 @@ int main() { return 0; } - diff --git a/src/ellalgo/cutting_plane.py b/src/ellalgo/cutting_plane.py index 13caacf..21434d8 100644 --- a/src/ellalgo/cutting_plane.py +++ b/src/ellalgo/cutting_plane.py @@ -1,6 +1,5 @@ import copy -from typing import Any, MutableSequence, Optional, Tuple, Union -from typing import Generic +from typing import Any, Generic, MutableSequence, Optional, Tuple, Union from .ell_config import CutStatus, Options from .ell_typing import ( @@ -83,7 +82,10 @@ def cutting_plane_feas( def cutting_plane_optim( - omega: OracleOptim[ArrayType], space: SearchSpace[ArrayType], target, options=Options() + omega: OracleOptim[ArrayType], + space: SearchSpace[ArrayType], + target, + options=Options(), ) -> Tuple[Optional[ArrayType], float, int]: """Cutting-plane method for solving convex optimization problem @@ -146,7 +148,10 @@ def cutting_plane_feas_q( def cutting_plane_optim_q( - omega: OracleOptimQ[ArrayType], space_q: SearchSpaceQ[ArrayType], target, options=Options() + omega: OracleOptimQ[ArrayType], + space_q: SearchSpaceQ[ArrayType], + target, + options=Options(), ) -> Tuple[Optional[ArrayType], float, int]: """Cutting-plane method for solving convex discrete optimization problem diff --git a/src/ellalgo/ell_calc.py b/src/ellalgo/ell_calc.py index b438e46..6258595 100644 --- a/src/ellalgo/ell_calc.py +++ b/src/ellalgo/ell_calc.py @@ -1,8 +1,8 @@ from math import sqrt -from typing import Tuple, Optional +from typing import Optional, Tuple -from .ell_config import CutStatus from .ell_calc_core import EllCalcCore +from .ell_config import CutStatus class EllCalc: diff --git a/src/ellalgo/ell_stable.py b/src/ellalgo/ell_stable.py index 7d3601a..9da664a 100644 --- a/src/ellalgo/ell_stable.py +++ b/src/ellalgo/ell_stable.py @@ -4,7 +4,7 @@ from .ell_calc import EllCalc from .ell_config import CutStatus -from .ell_typing import SearchSpace, SearchSpaceQ, ArrayType +from .ell_typing import ArrayType, SearchSpace, SearchSpaceQ Matrix = np.ndarray CutChoice = Union[float, ArrayType] # single or parallel diff --git a/src/ellalgo/ell_typing.py b/src/ellalgo/ell_typing.py index e90896e..890bc83 100644 --- a/src/ellalgo/ell_typing.py +++ b/src/ellalgo/ell_typing.py @@ -1,7 +1,8 @@ from abc import ABC, abstractmethod -from typing import MutableSequence, Optional, Tuple, Union -from typing import Generic, TypeVar +from typing import Generic, MutableSequence, Optional, Tuple, TypeVar, Union + import numpy as np + from .ell_config import CutStatus ArrayType = TypeVar("ArrayType", bound=np.ndarray) diff --git a/src/ellalgo/oracles/lowpass_oracle.py b/src/ellalgo/oracles/lowpass_oracle.py index 85a0c98..e8e2cb7 100644 --- a/src/ellalgo/oracles/lowpass_oracle.py +++ b/src/ellalgo/oracles/lowpass_oracle.py @@ -1,7 +1,7 @@ +from math import floor from typing import Tuple import numpy as np -from math import floor Arr = np.ndarray Cut = Tuple[Arr, float] @@ -40,7 +40,9 @@ class LowpassOracle: more_alt: bool = True - def __init__(self, ndim: int, wpass: float, wstop: float, lp_sq: float, up_sq: float): + def __init__( + self, ndim: int, wpass: float, wstop: float, lp_sq: float, up_sq: float + ): # ********************************************************************* # optimization parameters # ********************************************************************* @@ -110,8 +112,8 @@ def assess_optim(self, x: Arr, sp_sq: float): # case 1 (unlikely) if x[0] < 0: - grade = np.zeros(ndim) - grade[0] = -1.0 + grad = np.zeros(ndim) + grad[0] = -1.0 return (grad, -x[0]), None # Begin objective function diff --git a/tests/test_lowpass.py b/tests/test_lowpass.py index c517df8..8d76944 100644 --- a/tests/test_lowpass.py +++ b/tests/test_lowpass.py @@ -1,6 +1,7 @@ import time import numpy as np + from ellalgo.cutting_plane import Options, cutting_plane_optim from ellalgo.ell import Ell from ellalgo.oracles.lowpass_oracle import create_lowpass_case @@ -33,7 +34,7 @@ def run_lowpass(use_parallel_cut: bool, duration=0.000001): def test_lowpass(): - """ Test the lowpass case with parallel cut """ + """Test the lowpass case with parallel cut""" result, feasible = run_lowpass(True) assert feasible assert result >= 1083 @@ -41,7 +42,7 @@ def test_lowpass(): def test_no_parallel_cut(): - """ Test the lowpass case with no parallel cut """ + """Test the lowpass case with no parallel cut""" result, feasible = run_lowpass(False) assert feasible assert result >= 16461