optimtool 2.7.1__tar.gz → 2.7.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {optimtool-2.7.1 → optimtool-2.7.2}/PKG-INFO +3 -1
- {optimtool-2.7.1 → optimtool-2.7.2}/README.md +2 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/__init__.py +1 -1
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/_convert.py +6 -6
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/_typing.py +5 -2
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/_version.py +1 -1
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/unconstrain/nonlinear_least_square.py +4 -4
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/unconstrain/trust_region.py +4 -4
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool.egg-info/PKG-INFO +3 -1
- {optimtool-2.7.1 → optimtool-2.7.2}/setup.py +1 -1
- {optimtool-2.7.1 → optimtool-2.7.2}/LICENSE +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/_drive.py +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/_kernel.py +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/_proxim.py +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/_search.py +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/_utils.py +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/base.py +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/constrain/__init__.py +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/constrain/equal.py +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/constrain/mixequal.py +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/constrain/unequal.py +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/example/Lasso.py +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/example/WanYuan.py +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/example/__init__.py +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/hybrid/__init__.py +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/hybrid/approt.py +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/hybrid/fista.py +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/hybrid/nesterov.py +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/unconstrain/__init__.py +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/unconstrain/gradient_descent.py +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/unconstrain/newton.py +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/unconstrain/newton_quasi.py +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool.egg-info/SOURCES.txt +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool.egg-info/dependency_links.txt +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool.egg-info/not-zip-safe +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool.egg-info/requires.txt +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/optimtool.egg-info/top_level.txt +0 -0
- {optimtool-2.7.1 → optimtool-2.7.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: optimtool
|
|
3
|
-
Version: 2.7.
|
|
3
|
+
Version: 2.7.2
|
|
4
4
|
Summary: The fundamental package for scientific research in optimization.
|
|
5
5
|
Home-page: https://github.com/linjing-lab/optimtool
|
|
6
6
|
Download-URL: https://github.com/linjing-lab/optimtool/tags
|
|
@@ -94,6 +94,8 @@ pip install optimtool>=2.5.0
|
|
|
94
94
|
```text
|
|
95
95
|
pip install optimtool>=2.6.0
|
|
96
96
|
```
|
|
97
|
+
> 建议:如果对自定义输入函数的需求比高版本中允许的输入类型检查更为强烈,推荐下载v2.4.4;如果需要在_convert.py和_typing.py中做可扩展的输入函数类型(基于sympy.core中所实现的类型),那么高版本中所作出的优化可以得到保留与体现。
|
|
98
|
+
|
|
97
99
|
## 项目结构
|
|
98
100
|
|
|
99
101
|
```textile
|
|
@@ -32,4 +32,4 @@ from .base import MATPLOTLIB_VERSION
|
|
|
32
32
|
from ._version import __version__
|
|
33
33
|
|
|
34
34
|
if sys.version_info < (3, 7, 0):
|
|
35
|
-
raise OSError(f'optimtool-2.7.
|
|
35
|
+
raise OSError(f'optimtool-2.7.2 requires Python >=3.7, but yours is {sys.version}')
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
# SOFTWARE.
|
|
20
20
|
|
|
21
21
|
from .base import np, sp
|
|
22
|
-
from ._typing import FuncType, FuncArray,
|
|
22
|
+
from ._typing import ArgType, MulType, PowerType, AddType, FuncType, FuncArray, ArgArray, PointType, PointArray, SympyMutableDenseMatrix, NDArray
|
|
23
23
|
|
|
24
24
|
__all__ = ["f2m", "a2m", "p2t", "h2h"]
|
|
25
25
|
|
|
@@ -29,9 +29,9 @@ def f2m(funcs: FuncArray) -> SympyMutableDenseMatrix:
|
|
|
29
29
|
|
|
30
30
|
:return: objective function updated with `sp.Matrix()`.
|
|
31
31
|
'''
|
|
32
|
-
if isinstance(funcs, (
|
|
33
|
-
return sp.Matrix([funcs])
|
|
34
|
-
elif isinstance(funcs, (list, tuple)) and all(list(map(lambda x: isinstance(x,
|
|
32
|
+
if isinstance(funcs, (SympyMutableDenseMatrix, AddType, PowerType, MulType, ArgType)): # add type of FuncType to support need!
|
|
33
|
+
return sp.Matrix([funcs]) # prefer SympyMutableDenseMatrix to avoid enter into elif
|
|
34
|
+
elif isinstance(funcs, (list, tuple)) and all(list(map(lambda x: isinstance(x, (AddType, PowerType, MulType, ArgType)), funcs))):
|
|
35
35
|
return sp.Matrix(funcs)
|
|
36
36
|
else:
|
|
37
37
|
raise RuntimeError(f"f2m not support type of funcs: {type(funcs)}.")
|
|
@@ -42,8 +42,8 @@ def a2m(args: ArgArray) -> SympyMutableDenseMatrix:
|
|
|
42
42
|
|
|
43
43
|
:return: symbolic values updated with `sp.Matrix()`.
|
|
44
44
|
'''
|
|
45
|
-
if isinstance(args, (
|
|
46
|
-
return sp.Matrix([args])
|
|
45
|
+
if isinstance(args, (SympyMutableDenseMatrix, ArgType)):
|
|
46
|
+
return sp.Matrix([args]) # prefer SympyMutableDenseMatrix to avoid enter into elif
|
|
47
47
|
elif isinstance(args, (list, tuple)) and all(list(map(lambda x: isinstance(x, ArgType), args))):
|
|
48
48
|
return sp.Matrix(args)
|
|
49
49
|
else:
|
|
@@ -31,9 +31,12 @@ NDArray = np.ndarray # numpy.ndarray
|
|
|
31
31
|
SympyMutableDenseMatrix = sp.matrices.dense.MutableDenseMatrix # symbolic values
|
|
32
32
|
|
|
33
33
|
DataType = np.float64 # conver `object` to `float`
|
|
34
|
-
|
|
35
|
-
FuncType = sp.core.add.Add
|
|
34
|
+
# add type of FuncType to support need!
|
|
36
35
|
ArgType = sp.core.symbol.Symbol
|
|
36
|
+
MulType = sp.core.mul.Mul
|
|
37
|
+
PowerType = sp.core.power.Pow
|
|
38
|
+
AddType = sp.core.add.Add
|
|
39
|
+
FuncType = Union[AddType, PowerType, MulType, ArgType]
|
|
37
40
|
PointType = Union[float, int]
|
|
38
41
|
|
|
39
42
|
FuncArray = Union[SympyMutableDenseMatrix, FuncType, List[FuncType], Tuple[FuncType]]
|
|
@@ -130,14 +130,14 @@ def levenberg_marquardt(funcr: FuncArray,
|
|
|
130
130
|
hess_f = np.array(hess.subs(reps)).astype(DataType)
|
|
131
131
|
hess_f = h2h(hess_f)
|
|
132
132
|
pk_down = -(grad_f.dot(dk.T) + 0.5*((dk.dot(hess_f)).dot(dk.T)))
|
|
133
|
-
pk = pk_up / pk_down
|
|
133
|
+
pk = (pk_up / pk_down)[0][0]
|
|
134
134
|
if np.linalg.norm(dk) >= epsilon:
|
|
135
|
-
if pk
|
|
135
|
+
if pk < p1:
|
|
136
136
|
lamk *= gamma2
|
|
137
137
|
else:
|
|
138
|
-
if pk
|
|
138
|
+
if pk > p2:
|
|
139
139
|
lamk *= gamma1
|
|
140
|
-
if pk
|
|
140
|
+
if pk > eta:
|
|
141
141
|
x_0 += dk[0]
|
|
142
142
|
k += 1
|
|
143
143
|
else:
|
|
@@ -87,13 +87,13 @@ def steihaug_CG(funcs: FuncArray,
|
|
|
87
87
|
dk = steihaug(s0, grad, -grad, hessi, r0, epsk).astype(DataType)
|
|
88
88
|
if np.linalg.norm(dk) >= epsilon:
|
|
89
89
|
funvk = np.array(funcs.subs(dict(zip(args, x_0 + dk[0])))).astype(DataType)
|
|
90
|
-
pk = (funv - funvk) / -(grad.dot(dk.T) + 0.5*((dk.dot(hessi)).dot(dk.T)))
|
|
91
|
-
if pk
|
|
90
|
+
pk = ((funv - funvk) / -(grad.dot(dk.T) + 0.5*((dk.dot(hessi)).dot(dk.T))))[0][0]
|
|
91
|
+
if pk < p1:
|
|
92
92
|
r0 *= gamma1
|
|
93
93
|
else:
|
|
94
|
-
if (pk
|
|
94
|
+
if (pk > p2) or (np.linalg.norm(dk) == r0):
|
|
95
95
|
r0 = min(gamma2 * r0, rmax)
|
|
96
|
-
if pk
|
|
96
|
+
if pk > eta:
|
|
97
97
|
x_0 += dk[0]
|
|
98
98
|
k += 1
|
|
99
99
|
else:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: optimtool
|
|
3
|
-
Version: 2.7.
|
|
3
|
+
Version: 2.7.2
|
|
4
4
|
Summary: The fundamental package for scientific research in optimization.
|
|
5
5
|
Home-page: https://github.com/linjing-lab/optimtool
|
|
6
6
|
Download-URL: https://github.com/linjing-lab/optimtool/tags
|
|
@@ -94,6 +94,8 @@ pip install optimtool>=2.5.0
|
|
|
94
94
|
```text
|
|
95
95
|
pip install optimtool>=2.6.0
|
|
96
96
|
```
|
|
97
|
+
> 建议:如果对自定义输入函数的需求比高版本中允许的输入类型检查更为强烈,推荐下载v2.4.4;如果需要在_convert.py和_typing.py中做可扩展的输入函数类型(基于sympy.core中所实现的类型),那么高版本中所作出的优化可以得到保留与体现。
|
|
98
|
+
|
|
97
99
|
## 项目结构
|
|
98
100
|
|
|
99
101
|
```textile
|
|
@@ -4,7 +4,7 @@ import sys
|
|
|
4
4
|
from setuptools import setup
|
|
5
5
|
|
|
6
6
|
if sys.version_info < (3, 7, 0):
|
|
7
|
-
raise OSError(f'optimtool-2.7.
|
|
7
|
+
raise OSError(f'optimtool-2.7.2 requires Python >=3.7, but yours is {sys.version}')
|
|
8
8
|
|
|
9
9
|
if (3, 7, 0) <= sys.version_info < (3, 8, 0):
|
|
10
10
|
# https://github.com/pypa/setuptools/issues/926#issuecomment-294369342
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|