A wrapper around some of scipy's optimization functions to allow for a more convenient use of parameters and constants.
Project description
Wrapped-Optimizations
Description
wrapped_optimizations is a Python wrapper around some of SciPy's optimization functions. Instead of having one 1D array which contains all parameters to be optimized, the wrapped functions allow the parameters to be defined locally in the functions to be optimized.
Installation
To install this package, use pip:
pip install wrapped_optimizations
Usage
Here is a simple example of how to use Wrapped-Optimizations:
from wrapped_optimizations import differential_evolution, eval_function
def func(use_param, use_const, use_print=False):
# define a named parameter
x = use_param((2), 'x', bounds=(-5, 5))
# define an unnamed parameter
y = use_param((2,2), bounds=(-5, 5))
# define a (named) constant
# equals `N = 3`, but with the advantage that the value also gets saved to result.x
N = use_const(3, name='N')
V = use_param((N), bounds=(0, 20))
if use_print:
print(f'V: {V}')
return np.linalg.norm(x - 1)**2 + np.linalg.norm(y - 3)**2
result = differential_evolution(func)
# result.x now contains all the parameters and constants
# {
# 'x': array([1., 1.]),
# 'param_1': array([[3., 3.], [3., 3.]]),
# 'param_2': array([ 9.49532267, 16.89317493, 9.37888973]),
# 'N': 3
# }
# `func` can now be called, also with additional parameters being forwarded to `func`:
# eval_function(func, result.x, True)
Requirements
Wrapped-Optimizations requires the following Python libraries:
- NumPy
- SciPy
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wrapped_optimizations-0.1.0.tar.gz.
File metadata
- Download URL: wrapped_optimizations-0.1.0.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71d4c90fcce683a98e3e8c000a171c02109b561b808e030fa868967fd0919c25
|
|
| MD5 |
61ee40ba49c6effefd66b19263f30472
|
|
| BLAKE2b-256 |
2d82a288c827ab99215d7495dd2eebf934a05acd83ad681c5e6cd993435f15c5
|
File details
Details for the file wrapped_optimizations-0.1.0-py3-none-any.whl.
File metadata
- Download URL: wrapped_optimizations-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e0d1a9e8df6250424f8f609583f6172cb4256a699506ad36d1660170d22e7c1
|
|
| MD5 |
5b4f389a07f573be8be6762d7cc35069
|
|
| BLAKE2b-256 |
3cf396bfccd5fd02e74c23c8a630b11af04f4ce2a43e574651592eeb92f8f2c1
|