NumOpt 0.0.1__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.
- numopt-0.0.1/LICENSE.txt +21 -0
- numopt-0.0.1/NumOpt/__init__.py +3 -0
- numopt-0.0.1/NumOpt/opti.py +95 -0
- numopt-0.0.1/NumOpt.egg-info/PKG-INFO +31 -0
- numopt-0.0.1/NumOpt.egg-info/SOURCES.txt +10 -0
- numopt-0.0.1/NumOpt.egg-info/dependency_links.txt +1 -0
- numopt-0.0.1/NumOpt.egg-info/requires.txt +2 -0
- numopt-0.0.1/NumOpt.egg-info/top_level.txt +1 -0
- numopt-0.0.1/PKG-INFO +31 -0
- numopt-0.0.1/README.md +5 -0
- numopt-0.0.1/setup.cfg +4 -0
- numopt-0.0.1/setup.py +50 -0
numopt-0.0.1/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019-2023 Peter Sharpe
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import aerosandbox.numpy as anp
|
|
2
|
+
import aerosandbox as asb
|
|
3
|
+
import casadi as cas
|
|
4
|
+
from termcolor import cprint
|
|
5
|
+
from functools import partial
|
|
6
|
+
from typing import Callable, Any, Dict
|
|
7
|
+
|
|
8
|
+
cprint_green = partial(cprint, color="green", attrs=["bold"])
|
|
9
|
+
cprint_magenta = partial(cprint, color="magenta", attrs=["bold"])
|
|
10
|
+
cprint_blue = partial(cprint, color="blue", attrs=["bold"])
|
|
11
|
+
cprint_red = partial(cprint, color="red", attrs=["bold"])
|
|
12
|
+
cprint_yellow = partial(cprint, color="yellow", attrs=["bold"])
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
# def trape(y, x):
|
|
16
|
+
# y = anp.array(y)
|
|
17
|
+
# x = anp.array(x)
|
|
18
|
+
# mid_y = (y[:-1] + y[1:]) / 2.0
|
|
19
|
+
# dx = anp.diff(x)
|
|
20
|
+
|
|
21
|
+
# I = anp.sum(mid_y * dx)
|
|
22
|
+
# return I
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class Opti(asb.Opti):
|
|
26
|
+
def solver(
|
|
27
|
+
self,
|
|
28
|
+
max_iter: int = 1000,
|
|
29
|
+
max_runtime: float = 1e20,
|
|
30
|
+
callback: Callable[[int], Any] = None,
|
|
31
|
+
verbose: bool = True,
|
|
32
|
+
jit: bool = False,
|
|
33
|
+
detect_simple_bounds: bool = False,
|
|
34
|
+
expand: bool = True,
|
|
35
|
+
options: Dict = None,
|
|
36
|
+
):
|
|
37
|
+
if options is None:
|
|
38
|
+
options = {}
|
|
39
|
+
default_options = {
|
|
40
|
+
"ipopt.sb": "yes", # Hide the IPOPT banner.
|
|
41
|
+
"ipopt.max_iter": max_iter,
|
|
42
|
+
"ipopt.max_cpu_time": max_runtime,
|
|
43
|
+
"ipopt.mu_strategy": "adaptive",
|
|
44
|
+
"ipopt.fast_step_computation": "yes",
|
|
45
|
+
"detect_simple_bounds": detect_simple_bounds,
|
|
46
|
+
"expand": expand,
|
|
47
|
+
}
|
|
48
|
+
if jit:
|
|
49
|
+
default_options["jit"] = True
|
|
50
|
+
# options["compiler"] = "shell" # Recommended by CasADi devs, but doesn't work on my machine
|
|
51
|
+
default_options["jit_options"] = {
|
|
52
|
+
"flags": ["-O3"],
|
|
53
|
+
# "verbose": True
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if verbose:
|
|
57
|
+
default_options["ipopt.print_level"] = 5 # Verbose, per-iteration printing.
|
|
58
|
+
else:
|
|
59
|
+
default_options["print_time"] = False # No time printing
|
|
60
|
+
default_options["ipopt.print_level"] = 0 # No printing from IPOPT
|
|
61
|
+
|
|
62
|
+
super().solver(
|
|
63
|
+
"ipopt",
|
|
64
|
+
{
|
|
65
|
+
**default_options,
|
|
66
|
+
**options,
|
|
67
|
+
},
|
|
68
|
+
)
|
|
69
|
+
if callback is not None:
|
|
70
|
+
self.callback(callback)
|
|
71
|
+
|
|
72
|
+
def solve(
|
|
73
|
+
self,
|
|
74
|
+
behavior_on_failure: str = "raise",
|
|
75
|
+
):
|
|
76
|
+
if behavior_on_failure == "raise":
|
|
77
|
+
sol = asb.OptiSol(opti=self, cas_optisol=cas.Opti.solve(self))
|
|
78
|
+
elif behavior_on_failure == "return_last":
|
|
79
|
+
try:
|
|
80
|
+
sol = asb.OptiSol(opti=self, cas_optisol=cas.Opti.solve(self))
|
|
81
|
+
except RuntimeError:
|
|
82
|
+
import warnings
|
|
83
|
+
|
|
84
|
+
warnings.warn("Optimization failed. Returning last solution.")
|
|
85
|
+
|
|
86
|
+
sol = asb.OptiSol(opti=self, cas_optisol=self.debug)
|
|
87
|
+
|
|
88
|
+
if self.save_to_cache_on_solve:
|
|
89
|
+
self.save_solution()
|
|
90
|
+
|
|
91
|
+
return sol
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
if __name__=="__main__":
|
|
95
|
+
cprint_yellow("it is ok")
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: NumOpt
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Opti is a Python package that helps you design and optimize engineered systems.
|
|
5
|
+
Home-page: https://github.com/Zcaic/NumOpt.git
|
|
6
|
+
Author: Zcaic
|
|
7
|
+
Keywords: optimization automatic differentiation
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: Intended Audience :: Science/Research
|
|
10
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Requires-Python: >=3.9
|
|
14
|
+
License-File: LICENSE.txt
|
|
15
|
+
Requires-Dist: aerosandbox>=4.2.8
|
|
16
|
+
Requires-Dist: termcolor>=3.1.0
|
|
17
|
+
Dynamic: author
|
|
18
|
+
Dynamic: classifier
|
|
19
|
+
Dynamic: description
|
|
20
|
+
Dynamic: home-page
|
|
21
|
+
Dynamic: keywords
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
Dynamic: requires-dist
|
|
24
|
+
Dynamic: requires-python
|
|
25
|
+
Dynamic: summary
|
|
26
|
+
|
|
27
|
+
**NumOpt is a Numerical Optimization Tool Python package that helps you design and optimize engineered systems.**
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
pip install NumOpt
|
|
31
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
NumOpt
|
numopt-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: NumOpt
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Opti is a Python package that helps you design and optimize engineered systems.
|
|
5
|
+
Home-page: https://github.com/Zcaic/NumOpt.git
|
|
6
|
+
Author: Zcaic
|
|
7
|
+
Keywords: optimization automatic differentiation
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: Intended Audience :: Science/Research
|
|
10
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Requires-Python: >=3.9
|
|
14
|
+
License-File: LICENSE.txt
|
|
15
|
+
Requires-Dist: aerosandbox>=4.2.8
|
|
16
|
+
Requires-Dist: termcolor>=3.1.0
|
|
17
|
+
Dynamic: author
|
|
18
|
+
Dynamic: classifier
|
|
19
|
+
Dynamic: description
|
|
20
|
+
Dynamic: home-page
|
|
21
|
+
Dynamic: keywords
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
Dynamic: requires-dist
|
|
24
|
+
Dynamic: requires-python
|
|
25
|
+
Dynamic: summary
|
|
26
|
+
|
|
27
|
+
**NumOpt is a Numerical Optimization Tool Python package that helps you design and optimize engineered systems.**
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
pip install NumOpt
|
|
31
|
+
```
|
numopt-0.0.1/README.md
ADDED
numopt-0.0.1/setup.cfg
ADDED
numopt-0.0.1/setup.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""A setuptools based setup module.
|
|
2
|
+
|
|
3
|
+
See:
|
|
4
|
+
https://packaging.python.org/guides/distributing-packages-using-setuptools/
|
|
5
|
+
https://github.com/pypa/sampleproject
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
# Always prefer setuptools over distutils
|
|
9
|
+
from setuptools import setup, find_packages
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
# Get the long description from the README file
|
|
13
|
+
README_path = Path(__file__).parent / "README.md"
|
|
14
|
+
with open(README_path, encoding='utf-8') as f:
|
|
15
|
+
long_description = f.read()
|
|
16
|
+
|
|
17
|
+
### Get the version number dynamically
|
|
18
|
+
init_path = Path(__file__).parent / "NumOpt" / "__init__.py"
|
|
19
|
+
|
|
20
|
+
with open(init_path) as f:
|
|
21
|
+
for line in f:
|
|
22
|
+
if line.startswith("__version__"):
|
|
23
|
+
version = line.split("=")[1].strip().strip('"').strip("'")
|
|
24
|
+
break
|
|
25
|
+
else:
|
|
26
|
+
raise RuntimeError("Unable to find version string.")
|
|
27
|
+
|
|
28
|
+
### Do the setup
|
|
29
|
+
setup(
|
|
30
|
+
name='NumOpt',
|
|
31
|
+
author='Zcaic',
|
|
32
|
+
version=version,
|
|
33
|
+
description='Opti is a Python package that helps you design and optimize engineered systems.',
|
|
34
|
+
long_description=long_description,
|
|
35
|
+
url='https://github.com/Zcaic/NumOpt.git',
|
|
36
|
+
classifiers=[
|
|
37
|
+
'Development Status :: 5 - Production/Stable',
|
|
38
|
+
'Intended Audience :: Science/Research',
|
|
39
|
+
'Topic :: Scientific/Engineering :: Physics',
|
|
40
|
+
'License :: OSI Approved :: MIT License',
|
|
41
|
+
'Programming Language :: Python :: 3',
|
|
42
|
+
],
|
|
43
|
+
keywords='optimization automatic differentiation',
|
|
44
|
+
packages=find_packages(),
|
|
45
|
+
python_requires='>=3.9',
|
|
46
|
+
install_requires=[
|
|
47
|
+
'aerosandbox >= 4.2.8',
|
|
48
|
+
"termcolor >= 3.1.0"
|
|
49
|
+
]
|
|
50
|
+
)
|