From c29e9605f2cc815a0d212cbc496e601e450dc24c Mon Sep 17 00:00:00 2001 From: Jing Lin <82669431+linjing-lab@users.noreply.github.com> Date: Sun, 22 Oct 2023 20:03:04 +0800 Subject: [PATCH] upgrade optimtool --- optimtool/__init__.py | 2 +- optimtool/_version.py | 2 +- optimtool/example/Lasso.py | 3 +++ setup.py | 2 +- test_L_BFGS.py | 11 +++++++++++ 5 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 test_L_BFGS.py diff --git a/optimtool/__init__.py b/optimtool/__init__.py index 4c6c179..7babf9e 100644 --- a/optimtool/__init__.py +++ b/optimtool/__init__.py @@ -32,4 +32,4 @@ from ._version import __version__ if sys.version_info < (3, 7, 0): - raise OSError(f'optimtool-2.6.0 requires Python >=3.7, but yours is {sys.version}') \ No newline at end of file + raise OSError(f'optimtool-2.6.1 requires Python >=3.7, but yours is {sys.version}') \ No newline at end of file diff --git a/optimtool/_version.py b/optimtool/_version.py index de17b48..7b2e587 100644 --- a/optimtool/_version.py +++ b/optimtool/_version.py @@ -18,4 +18,4 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -__version__ = '2.6.0' \ No newline at end of file +__version__ = '2.6.1' \ No newline at end of file diff --git a/optimtool/example/Lasso.py b/optimtool/example/Lasso.py index 6ae38ce..ee40398 100644 --- a/optimtool/example/Lasso.py +++ b/optimtool/example/Lasso.py @@ -54,6 +54,8 @@ def gradient(A: NDArray, :return: final convergenced point and iterative times, (iterative values in a list). ''' + assert delta > 0 + assert alp > 0 from .._drive import get_f_delta_gradient args = a2m(args) funcs = sp.Matrix([0.5*((A*args - b).T)*(A*args - b)]) @@ -107,6 +109,7 @@ def subgradient(A: NDArray, :return: final convergenced point and iterative times, (iterative values in a list). ''' + assert alphak > 0 from .._drive import get_subgradient args = a2m(args) funcs = sp.Matrix([0.5*((A*args - b).T)*(A*args - b)]) diff --git a/setup.py b/setup.py index 2fc4802..a535c34 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup if sys.version_info < (3, 7, 0): - raise OSError(f'optimtool-2.6.0 requires Python >=3.7, but yours is {sys.version}') + raise OSError(f'optimtool-2.6.1 requires Python >=3.7, but yours is {sys.version}') if (3, 7, 0) <= sys.version_info < (3, 8, 0): # https://github.com/pypa/setuptools/issues/926#issuecomment-294369342 diff --git a/test_L_BFGS.py b/test_L_BFGS.py new file mode 100644 index 0000000..b8c1f0d --- /dev/null +++ b/test_L_BFGS.py @@ -0,0 +1,11 @@ +import optimtool.unconstrain as ou +from optimtool.base import sp +x = sp.symbols("x1:5") +f = 100 * (x[1] - x[0]**2)**2 + \ + (1 - x[0])**2 + \ + 100 * (x[3] - x[2]**2)**2 + \ + (1 - x[2])**2 +x_0 = (-1.2, 1, -1.2, 1) +lbfgs = ou.newton_quasi.L_BFGS +lbfgs(f, x, x_0, verbose=True, draw=False, m=2) +# lbfgs(f, x, x_0, verbose=True, draw=False, m=6) \ No newline at end of file