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.
Files changed (38) hide show
  1. {optimtool-2.7.1 → optimtool-2.7.2}/PKG-INFO +3 -1
  2. {optimtool-2.7.1 → optimtool-2.7.2}/README.md +2 -0
  3. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/__init__.py +1 -1
  4. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/_convert.py +6 -6
  5. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/_typing.py +5 -2
  6. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/_version.py +1 -1
  7. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/unconstrain/nonlinear_least_square.py +4 -4
  8. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/unconstrain/trust_region.py +4 -4
  9. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool.egg-info/PKG-INFO +3 -1
  10. {optimtool-2.7.1 → optimtool-2.7.2}/setup.py +1 -1
  11. {optimtool-2.7.1 → optimtool-2.7.2}/LICENSE +0 -0
  12. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/_drive.py +0 -0
  13. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/_kernel.py +0 -0
  14. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/_proxim.py +0 -0
  15. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/_search.py +0 -0
  16. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/_utils.py +0 -0
  17. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/base.py +0 -0
  18. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/constrain/__init__.py +0 -0
  19. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/constrain/equal.py +0 -0
  20. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/constrain/mixequal.py +0 -0
  21. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/constrain/unequal.py +0 -0
  22. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/example/Lasso.py +0 -0
  23. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/example/WanYuan.py +0 -0
  24. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/example/__init__.py +0 -0
  25. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/hybrid/__init__.py +0 -0
  26. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/hybrid/approt.py +0 -0
  27. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/hybrid/fista.py +0 -0
  28. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/hybrid/nesterov.py +0 -0
  29. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/unconstrain/__init__.py +0 -0
  30. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/unconstrain/gradient_descent.py +0 -0
  31. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/unconstrain/newton.py +0 -0
  32. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool/unconstrain/newton_quasi.py +0 -0
  33. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool.egg-info/SOURCES.txt +0 -0
  34. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool.egg-info/dependency_links.txt +0 -0
  35. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool.egg-info/not-zip-safe +0 -0
  36. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool.egg-info/requires.txt +0 -0
  37. {optimtool-2.7.1 → optimtool-2.7.2}/optimtool.egg-info/top_level.txt +0 -0
  38. {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.1
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
@@ -65,6 +65,8 @@ pip install optimtool>=2.5.0
65
65
  ```text
66
66
  pip install optimtool>=2.6.0
67
67
  ```
68
+ > 建议:如果对自定义输入函数的需求比高版本中允许的输入类型检查更为强烈,推荐下载v2.4.4;如果需要在_convert.py和_typing.py中做可扩展的输入函数类型(基于sympy.core中所实现的类型),那么高版本中所作出的优化可以得到保留与体现。
69
+
68
70
  ## 项目结构
69
71
 
70
72
  ```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.1 requires Python >=3.7, but yours is {sys.version}')
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, ArgType, ArgArray, PointType, PointArray, SympyMutableDenseMatrix, NDArray
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, (FuncType, SympyMutableDenseMatrix)):
33
- return sp.Matrix([funcs])
34
- elif isinstance(funcs, (list, tuple)) and all(list(map(lambda x: isinstance(x, FuncType), funcs))):
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, (ArgType, SympyMutableDenseMatrix)):
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]]
@@ -18,4 +18,4 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
19
  # SOFTWARE.
20
20
 
21
- __version__ = '2.7.1'
21
+ __version__ = '2.7.2'
@@ -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[0][0] < p1:
135
+ if pk < p1:
136
136
  lamk *= gamma2
137
137
  else:
138
- if pk[0][0] > p2:
138
+ if pk > p2:
139
139
  lamk *= gamma1
140
- if pk[0][0] > eta:
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[0][0] < p1:
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[0][0] > p2) or (np.linalg.norm(dk) == r0):
94
+ if (pk > p2) or (np.linalg.norm(dk) == r0):
95
95
  r0 = min(gamma2 * r0, rmax)
96
- if pk[0][0] > eta:
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.1
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.1 requires Python >=3.7, but yours is {sys.version}')
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