mango 0.2.1__tar.gz → 0.2.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.
- {mango-0.2.1/mango.egg-info → mango-0.2.2}/PKG-INFO +14 -1
- mango-0.2.2/README.rst +19 -0
- mango-0.2.2/mango/__init__.py +4 -0
- {mango-0.2.1 → mango-0.2.2}/mango/benchmark/optimization/gramacy_lee.py +11 -4
- {mango-0.2.1 → mango-0.2.2}/mango/benchmark/optimization/griewank.py +2 -2
- {mango-0.2.1 → mango-0.2.2}/mango/benchmark/optimization/holder_table.py +9 -4
- {mango-0.2.1 → mango-0.2.2}/mango/benchmark/optimization/langermann.py +12 -4
- {mango-0.2.1 → mango-0.2.2}/mango/benchmark/optimization/levy.py +11 -6
- {mango-0.2.1 → mango-0.2.2}/mango/benchmark/optimization/rastrigin.py +11 -5
- {mango-0.2.1 → mango-0.2.2}/mango/benchmark/optimization/rosenbrock.py +13 -7
- {mango-0.2.1 → mango-0.2.2}/mango/benchmark/optimization/schaffer.py +15 -8
- {mango-0.2.1 → mango-0.2.2}/mango/benchmark/optimization/schwefel.py +4 -4
- {mango-0.2.1 → mango-0.2.2}/mango/clients/arcgis.py +9 -4
- {mango-0.2.1 → mango-0.2.2}/mango/clients/google_cloud_storage.py +28 -0
- {mango-0.2.1 → mango-0.2.2}/mango/config/base_config.py +22 -0
- {mango-0.2.1 → mango-0.2.2}/mango/dashboards/file_explorer_app.py +5 -4
- {mango-0.2.1 → mango-0.2.2}/mango/models/pyomo.py +15 -1
- {mango-0.2.1 → mango-0.2.2}/mango/processing/date_functions.py +13 -9
- {mango-0.2.1 → mango-0.2.2}/mango/processing/file_functions.py +84 -14
- {mango-0.2.1 → mango-0.2.2}/mango/processing/object_functions.py +26 -0
- {mango-0.2.1 → mango-0.2.2}/mango/table/pytups_table.py +45 -17
- {mango-0.2.1 → mango-0.2.2}/mango/table/pytups_tools.py +45 -29
- {mango-0.2.1 → mango-0.2.2}/mango/table/table_tools.py +1 -1
- {mango-0.2.1 → mango-0.2.2}/mango/tests/config_module/test_config.py +24 -0
- mango-0.2.2/mango/tests/models_module/test_optimization_benchmarks.py +295 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/processing_module/test_date_functions.py +5 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/processing_module/test_file_functions.py +18 -1
- {mango-0.2.1 → mango-0.2.2}/mango/tests/table_module/test_table.py +126 -11
- {mango-0.2.1 → mango-0.2.2/mango.egg-info}/PKG-INFO +14 -1
- {mango-0.2.1 → mango-0.2.2}/pyproject.toml +1 -1
- mango-0.2.1/README.rst +0 -6
- mango-0.2.1/mango/__init__.py +0 -4
- mango-0.2.1/mango/tests/models_module/test_optimization_benchmarks.py +0 -116
- {mango-0.2.1 → mango-0.2.2}/LICENSE +0 -0
- {mango-0.2.1 → mango-0.2.2}/MANIFEST.in +0 -0
- {mango-0.2.1 → mango-0.2.2}/docs/source/conf.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/benchmark/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/benchmark/machine_learning/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/benchmark/optimization/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/benchmark/optimization/ackley.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/benchmark/optimization/bukin.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/benchmark/optimization/cross_in_tray.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/benchmark/optimization/dolan.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/benchmark/optimization/drop_wave.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/benchmark/optimization/egg_holder.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/cli/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/cli/dashboard.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/clients/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/clients/aemet.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/clients/cloud_storage.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/clients/email_downloader.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/clients/email_sender.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/clients/rest_client.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/config/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/dashboards/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/dashboards/assets/logo.png +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/data/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/data/calendar_data.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/data/ts_dataset.pkl +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/logging/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/logging/chrono.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/logging/decorators.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/logging/logger.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/models/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/models/activations.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/models/genetic/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/models/genetic/config/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/models/genetic/config/config.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/models/genetic/const.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/models/genetic/individual/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/models/genetic/individual/base_individual.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/models/genetic/population/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/models/genetic/population/base_population.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/models/genetic/problem/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/models/genetic/problem/base_problem.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/models/genetic/shared/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/models/genetic/shared/exceptions.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/models/neural_networks.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/plots/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/plots/plots.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/processing/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/processing/processing_time_series.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/schemas/location.json +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/shap_analysis/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/shap_analysis/const.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/shap_analysis/shap_analysis.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/shared/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/shared/const.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/shared/decorators.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/shared/exceptions.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/shared/requirement_check.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/shared/spatial.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/table/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/clients_module/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/clients_module/test_aemet_client.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/clients_module/test_arcgis_client.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/clients_module/test_rest_client.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/config_module/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/const.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/data/json_dataset.json +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/data/result.json +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/data/test.csv +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/data/test.json +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/data/test.xlsx +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/data/test2.csv +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/data/test_ackley.cfg +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/data/test_bad_type.cfg +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/data/test_bad_value.cfg +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/data/test_bukin.cfg +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/data/test_cross_in_tray.cfg +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/data/test_custom_problem.cfg +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/data/test_good.cfg +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/data/test_inverted_griewank_10d.cfg +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/data/test_levy.cfg +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/data/test_rastrigin.cfg +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/data/test_schwefel.cfg +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/data/variables.json +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/data/variables.xlsx +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/data_module/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/data_module/test_calendar_data.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/initialization_library/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/initialization_library/test_init.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/logging_module/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/logging_module/test_logging.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/models_module/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/models_module/test_genetic.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/models_module/test_models.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/models_module/test_pyomo.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/plots_module/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/processing_module/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/processing_module/test_correlation_ts.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/processing_module/test_object_functions.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/processing_module/test_processing_time_series.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/processing_module/test_tools.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/shap_module/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/shap_module/test_shap_analysis.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/shared_module/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/shared_module/test_requirement_check.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/shared_module/test_spatial.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/shared_module/test_validation.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/table_module/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/tests/table_module/test_tools.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/validators/__init__.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/validators/aemet.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango/validators/arcgis.py +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango.egg-info/SOURCES.txt +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango.egg-info/dependency_links.txt +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango.egg-info/entry_points.txt +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango.egg-info/requires.txt +0 -0
- {mango-0.2.1 → mango-0.2.2}/mango.egg-info/top_level.txt +0 -0
- {mango-0.2.1 → mango-0.2.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mango
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Library with a collection of usefull classes and methods to DRY
|
|
5
5
|
Author-email: baobab soluciones <mango@baobabsoluciones.es>
|
|
6
6
|
License: Apache Software License
|
|
@@ -54,6 +54,19 @@ Requires-Dist: shap[plots]==0.43.0; extra == "shap"
|
|
|
54
54
|
Mango
|
|
55
55
|
------
|
|
56
56
|
|
|
57
|
+
.. image:: https://img.shields.io/pypi/v/mango?label=version&logo=python&logoColor=white&style=for-the-badge&color=E58164
|
|
58
|
+
:alt: PyPI
|
|
59
|
+
:target: https://pypi.python.org/pypi/cornflow-client
|
|
60
|
+
.. image:: https://img.shields.io/pypi/l/mango?color=blue&style=for-the-badge
|
|
61
|
+
:alt: PyPI - License
|
|
62
|
+
:target: https://github.com/baobabsoluciones/cornflow/blob/master/LICENSE
|
|
63
|
+
.. image:: https://img.shields.io/github/actions/workflow/status/baobabsoluciones/mango/build_docs.yml?label=docs&logo=github&style=for-the-badge
|
|
64
|
+
:alt: GitHub Workflow Status
|
|
65
|
+
:target: https://github.com/baobabsoluciones/cornflow/actions
|
|
66
|
+
.. image:: https://img.shields.io/codecov/c/gh/baobabsoluciones/mango?flag=unit-tests&label=coverage&logo=codecov&logoColor=white&style=for-the-badge&token=0KKRF3J95L
|
|
67
|
+
:alt: Codecov
|
|
68
|
+
:target: https://app.codecov.io/gh/baobabsoluciones/mango
|
|
69
|
+
|
|
57
70
|
This a library containing several modules developed by the team at baobab soluciones. These functions, classes and methods are based on their experience, understanding and knowledge of the Python language and its ecosystem.
|
|
58
71
|
|
|
59
72
|
The functions are divided in different modules so even though everything is imported the dependencies can be installed only for the modules that are needed.
|
mango-0.2.2/README.rst
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Mango
|
|
2
|
+
------
|
|
3
|
+
|
|
4
|
+
.. image:: https://img.shields.io/pypi/v/mango?label=version&logo=python&logoColor=white&style=for-the-badge&color=E58164
|
|
5
|
+
:alt: PyPI
|
|
6
|
+
:target: https://pypi.python.org/pypi/cornflow-client
|
|
7
|
+
.. image:: https://img.shields.io/pypi/l/mango?color=blue&style=for-the-badge
|
|
8
|
+
:alt: PyPI - License
|
|
9
|
+
:target: https://github.com/baobabsoluciones/cornflow/blob/master/LICENSE
|
|
10
|
+
.. image:: https://img.shields.io/github/actions/workflow/status/baobabsoluciones/mango/build_docs.yml?label=docs&logo=github&style=for-the-badge
|
|
11
|
+
:alt: GitHub Workflow Status
|
|
12
|
+
:target: https://github.com/baobabsoluciones/cornflow/actions
|
|
13
|
+
.. image:: https://img.shields.io/codecov/c/gh/baobabsoluciones/mango?flag=unit-tests&label=coverage&logo=codecov&logoColor=white&style=for-the-badge&token=0KKRF3J95L
|
|
14
|
+
:alt: Codecov
|
|
15
|
+
:target: https://app.codecov.io/gh/baobabsoluciones/mango
|
|
16
|
+
|
|
17
|
+
This a library containing several modules developed by the team at baobab soluciones. These functions, classes and methods are based on their experience, understanding and knowledge of the Python language and its ecosystem.
|
|
18
|
+
|
|
19
|
+
The functions are divided in different modules so even though everything is imported the dependencies can be installed only for the modules that are needed.
|
|
@@ -1,26 +1,33 @@
|
|
|
1
1
|
from math import sin, pi
|
|
2
|
+
from typing import Union
|
|
2
3
|
|
|
4
|
+
import numpy as np
|
|
3
5
|
|
|
4
|
-
|
|
6
|
+
|
|
7
|
+
def gramacy_lee(x: Union[np.array, list, float]) -> float:
|
|
5
8
|
"""
|
|
6
9
|
Gramacy & Lee function.
|
|
7
10
|
|
|
8
11
|
This function is multimodal, with a number of local minima. The global minimum is at x = 0.54.
|
|
9
12
|
|
|
10
|
-
:param
|
|
13
|
+
:param x: array or list with the value or the value itself. Each value is usually between -0.5 and 2.5.
|
|
14
|
+
:type x: :class:`numpy.array`, list or float
|
|
11
15
|
:return: the value of the function
|
|
12
16
|
:rtype: float
|
|
13
17
|
"""
|
|
18
|
+
if isinstance(x, float):
|
|
19
|
+
x = [x]
|
|
14
20
|
return sin(10 * pi * x[0]) / (2 * x[0]) + (x[0] - 1) ** 4
|
|
15
21
|
|
|
16
22
|
|
|
17
|
-
def inverted_gramacy_lee(x: list) -> float:
|
|
23
|
+
def inverted_gramacy_lee(x: Union[np.array, list, float]) -> float:
|
|
18
24
|
"""
|
|
19
25
|
Inverted Gramacy & Lee function.
|
|
20
26
|
|
|
21
27
|
This function is multimodal, with a number of local minima. The global minimum is at x = 0.54.
|
|
22
28
|
|
|
23
|
-
:param
|
|
29
|
+
:param x: array or list with the value or the value itself. Each value is usually between -0.5 and 2.5.
|
|
30
|
+
:type x: :class:`numpy.array`, list or float
|
|
24
31
|
:return: the value of the function
|
|
25
32
|
:rtype: float
|
|
26
33
|
"""
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from math import prod, cos, sqrt
|
|
2
|
-
|
|
3
1
|
import numpy as np
|
|
4
2
|
|
|
5
3
|
|
|
@@ -9,6 +7,8 @@ def griewank(x: np.array) -> float:
|
|
|
9
7
|
|
|
10
8
|
The Griewank function has many widespread local minima, which are regularly distributed
|
|
11
9
|
|
|
10
|
+
The global minima is located at [0, 0, ..., 0] with a value of 0
|
|
11
|
+
|
|
12
12
|
:param x: array of floats
|
|
13
13
|
:type x: :class:`numpy.ndarray`
|
|
14
14
|
:return: the value of the function
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
from math import sin, cos, exp, sqrt, pi
|
|
2
|
+
from typing import Union
|
|
2
3
|
|
|
4
|
+
import numpy as np
|
|
3
5
|
|
|
4
|
-
|
|
6
|
+
|
|
7
|
+
def holder_table(x: Union[np.array, list]) -> float:
|
|
5
8
|
"""
|
|
6
9
|
Holder function.
|
|
7
10
|
|
|
@@ -9,14 +12,15 @@ def holder_table(x: list) -> float:
|
|
|
9
12
|
The global minima is at (8.05502, 9.66459), (-8.05502, 9.66459), (8.05502, -9.66459) and (-8.05502, -9.66459)
|
|
10
13
|
with a value of -19.2085.
|
|
11
14
|
|
|
12
|
-
:param
|
|
15
|
+
:param x: array or list of floats. Each value is usually between -10 and 10.
|
|
16
|
+
:type x: :class:`numpy.array` or list
|
|
13
17
|
:return: the value of the function
|
|
14
18
|
:rtype: float
|
|
15
19
|
"""
|
|
16
20
|
return -abs(sin(x[0]) * cos(x[1]) * exp(abs(1 - sqrt(x[0] ** 2 + x[1] ** 2) / pi)))
|
|
17
21
|
|
|
18
22
|
|
|
19
|
-
def inverted_holder_table(x: list) -> float:
|
|
23
|
+
def inverted_holder_table(x: Union[np.array, list]) -> float:
|
|
20
24
|
"""
|
|
21
25
|
Inverted Holder function.
|
|
22
26
|
|
|
@@ -26,7 +30,8 @@ def inverted_holder_table(x: list) -> float:
|
|
|
26
30
|
The global maxima is at (8.05502, 9.66459), (-8.05502, 9.66459), (8.05502, -9.66459) and (-8.05502, -9.66459)
|
|
27
31
|
with a value of 19.2085.
|
|
28
32
|
|
|
29
|
-
:param
|
|
33
|
+
:param x: list of floats. Each value is usually between -10 and 10.
|
|
34
|
+
:type x: :class:`numpy.array` or list
|
|
30
35
|
:return: the value of the function
|
|
31
36
|
:rtype: float
|
|
32
37
|
"""
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
from math import exp, pi, cos
|
|
2
|
+
from typing import Union
|
|
2
3
|
|
|
4
|
+
import numpy as np
|
|
3
5
|
|
|
4
|
-
|
|
6
|
+
|
|
7
|
+
def langermann(x: Union[np.array, list]) -> float:
|
|
5
8
|
"""
|
|
6
9
|
Langermann function.
|
|
7
10
|
|
|
8
11
|
The Langermann function is a multimodal problem. It has a fairly large number of local minima,
|
|
9
12
|
widely separated and regularly distributed.
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
This implementation is only for the two dimension version of the function using the values for a, c and m
|
|
15
|
+
proposed by Molga & Smutnicki (2005) :cite:p:`molga2005test`.
|
|
16
|
+
|
|
17
|
+
:param x: array or list of floats. Each value is usually between 0 and 10.
|
|
18
|
+
:type x: :class:`numpy.array` or list
|
|
12
19
|
:return: the value of the function
|
|
13
20
|
:rtype: float
|
|
14
21
|
"""
|
|
@@ -29,14 +36,15 @@ def langermann(x: list) -> float:
|
|
|
29
36
|
)
|
|
30
37
|
|
|
31
38
|
|
|
32
|
-
def inverted_langermann(x: list) -> float:
|
|
39
|
+
def inverted_langermann(x: Union[np.array, list]) -> float:
|
|
33
40
|
"""
|
|
34
41
|
Inverted Langermann function.
|
|
35
42
|
|
|
36
43
|
The Langermann function is a multimodal problem. It has a fairly large number of local minima,
|
|
37
44
|
widely separated and regularly distributed. This implementation inverts the function to test out the maximization
|
|
38
45
|
|
|
39
|
-
:param
|
|
46
|
+
:param x: array or list of floats. Each value is usually between 0 and 10.
|
|
47
|
+
:type x: :class:`numpy.array` or list
|
|
40
48
|
:return: the value of the function
|
|
41
49
|
:rtype: float
|
|
42
50
|
"""
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from math import sin, pi
|
|
2
|
+
from typing import Union
|
|
2
3
|
|
|
3
4
|
import numpy as np
|
|
4
5
|
|
|
@@ -9,7 +10,8 @@ def levy(x: np.array) -> float:
|
|
|
9
10
|
|
|
10
11
|
The global minima is at x = [1, 1, 1, ..., 1] and the function value is 0.
|
|
11
12
|
|
|
12
|
-
:param
|
|
13
|
+
:param x: array of floats. Each value is usually between -10 and 10.
|
|
14
|
+
:type x: :class:`numpy.array`
|
|
13
15
|
:return: the value of the function
|
|
14
16
|
:rtype: float
|
|
15
17
|
"""
|
|
@@ -26,20 +28,22 @@ def inverted_levy(x: np.array) -> float:
|
|
|
26
28
|
"""
|
|
27
29
|
Inverted Levy function.
|
|
28
30
|
|
|
29
|
-
:param
|
|
31
|
+
:param x: array of floats. Each value is usually between -10 and 10.
|
|
32
|
+
:type x: :class:`numpy.array`
|
|
30
33
|
:return: the value of the function
|
|
31
34
|
:rtype: float
|
|
32
35
|
"""
|
|
33
36
|
return -levy(x)
|
|
34
37
|
|
|
35
38
|
|
|
36
|
-
def levy_function_no13(x: list) -> float:
|
|
39
|
+
def levy_function_no13(x: Union[np.array, list]) -> float:
|
|
37
40
|
"""
|
|
38
41
|
Levy function N. 13.
|
|
39
42
|
|
|
40
43
|
The global minima is at x = [1, 1] and the function value is 0.
|
|
41
44
|
|
|
42
|
-
:param
|
|
45
|
+
:param x: array or list of floats. Each value is usually between -10 and 10.
|
|
46
|
+
:type x: :class:`numpy.array` or list
|
|
43
47
|
:return: the value of the function
|
|
44
48
|
:rtype: float
|
|
45
49
|
:doc-author: baobab soluciones
|
|
@@ -51,13 +55,14 @@ def levy_function_no13(x: list) -> float:
|
|
|
51
55
|
)
|
|
52
56
|
|
|
53
57
|
|
|
54
|
-
def inverted_levy_no13(x: list) -> float:
|
|
58
|
+
def inverted_levy_no13(x: Union[np.array, list]) -> float:
|
|
55
59
|
"""
|
|
56
60
|
Inverted Levy function N. 13.
|
|
57
61
|
|
|
58
62
|
The global minima is at x = [1, 1] and the function value is 0.
|
|
59
63
|
|
|
60
|
-
:param
|
|
64
|
+
:param x: list of floats. Each value is usually between -10 and 10.
|
|
65
|
+
:type x: :class:`numpy.array` or list
|
|
61
66
|
:return: the value of the function
|
|
62
67
|
:rtype: float
|
|
63
68
|
:doc-author: baobab soluciones
|
|
@@ -1,28 +1,34 @@
|
|
|
1
1
|
from math import cos, pi
|
|
2
2
|
|
|
3
|
+
import numpy as np
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
|
|
6
|
+
def rastrigin(x: np.array) -> float:
|
|
5
7
|
"""
|
|
6
8
|
Rastrigin function.
|
|
7
9
|
|
|
8
10
|
The Rastrigin function has several local minima. It is highly multimodal, but locations of the minima
|
|
9
11
|
are regularly distributed.
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
The global minima is at [0, 0, ..., 0] with a value of 0
|
|
14
|
+
|
|
15
|
+
:param x: array of floats. Values usually are between -5.12 and 5.12.
|
|
16
|
+
:type x: :class:`npumpy.array`
|
|
12
17
|
:return: the value of the function
|
|
13
18
|
:rtype: float
|
|
14
19
|
"""
|
|
15
|
-
return 10 * len(x) + sum(
|
|
20
|
+
return 10 * len(x) + np.sum(x**2 - 10 * np.cos(2 * pi * x))
|
|
16
21
|
|
|
17
22
|
|
|
18
|
-
def
|
|
23
|
+
def inverted_rastrigin(x: np.array) -> float:
|
|
19
24
|
"""
|
|
20
25
|
Inverted Rastrigin function.
|
|
21
26
|
|
|
22
27
|
The Rastrigin function has several local minima. It is highly multimodal, but locations of the minima
|
|
23
28
|
are regularly distributed. This implementation inverts the function to test out the maximization
|
|
24
29
|
|
|
25
|
-
:param
|
|
30
|
+
:param x: array of floats. Values usually are between -5.12 and 5.12.
|
|
31
|
+
:type x: :class:`npumpy.array`
|
|
26
32
|
:return: the value of the function
|
|
27
33
|
:rtype: float
|
|
28
34
|
"""
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def rosenbrock(x: np.array) -> float:
|
|
2
5
|
"""
|
|
3
6
|
Rosenbrock function.
|
|
4
7
|
|
|
@@ -8,16 +11,18 @@ def rosenbrock(x: list) -> float:
|
|
|
8
11
|
The function is unimodal, and the global minimum lies in a narrow, parabolic valley.
|
|
9
12
|
However, even though this valley is easy to find, convergence to the minimum is difficult (Picheny et al., 2012).
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
The global minima is at [1, 1, ..., 1] with a value of 0
|
|
15
|
+
|
|
16
|
+
:param x: array of floats. Values usually are between -5 and 10
|
|
17
|
+
:type x: :class:`numpy.array`
|
|
12
18
|
:return: the value of the function
|
|
13
19
|
:rtype: float
|
|
14
20
|
"""
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
)
|
|
21
|
+
|
|
22
|
+
return np.sum(100.0 * (x[1:] - x[:-1] ** 2.0) ** 2.0 + (1 - x[:-1]) ** 2.0, axis=0)
|
|
18
23
|
|
|
19
24
|
|
|
20
|
-
def inverted_rosenbrock(x:
|
|
25
|
+
def inverted_rosenbrock(x: np.array) -> float:
|
|
21
26
|
"""
|
|
22
27
|
Inverted Rosenbrock function.
|
|
23
28
|
|
|
@@ -27,7 +32,8 @@ def inverted_rosenbrock(x: list) -> float:
|
|
|
27
32
|
The function is unimodal, and the global minimum lies in a narrow, parabolic valley.
|
|
28
33
|
However, even though this valley is easy to find, convergence to the minimum is difficult (Picheny et al., 2012).
|
|
29
34
|
|
|
30
|
-
:param
|
|
35
|
+
:param x: array of floats. Values ussually are between -5 and 10
|
|
36
|
+
:type x: :class:`numpy.array`
|
|
31
37
|
:return: the value of the function
|
|
32
38
|
:rtype: float
|
|
33
39
|
"""
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
from math import sin, cos
|
|
2
|
+
from typing import Union
|
|
2
3
|
|
|
4
|
+
import numpy as np
|
|
3
5
|
|
|
4
|
-
|
|
6
|
+
|
|
7
|
+
def schaffer_function_no2(x: Union[np.array, list]) -> float:
|
|
5
8
|
"""
|
|
6
9
|
Schaffer function N. 2.
|
|
7
10
|
|
|
@@ -9,7 +12,8 @@ def schaffer_function_no2(x: list) -> float:
|
|
|
9
12
|
|
|
10
13
|
The global minima is at x [0, 0] with value 0
|
|
11
14
|
|
|
12
|
-
:param
|
|
15
|
+
:param x: A list of values. Values are evaluated between [-100, 100]
|
|
16
|
+
:type x: :class:`numpy.array` or list
|
|
13
17
|
:return: The value of the Schaffer function N. 2.
|
|
14
18
|
:rtype: float
|
|
15
19
|
"""
|
|
@@ -18,7 +22,7 @@ def schaffer_function_no2(x: list) -> float:
|
|
|
18
22
|
)
|
|
19
23
|
|
|
20
24
|
|
|
21
|
-
def inverted_schaffer_function_no2(x: list) -> float:
|
|
25
|
+
def inverted_schaffer_function_no2(x: Union[np.array, list]) -> float:
|
|
22
26
|
"""
|
|
23
27
|
Inverted Schaffer function N. 2.
|
|
24
28
|
|
|
@@ -28,14 +32,15 @@ def inverted_schaffer_function_no2(x: list) -> float:
|
|
|
28
32
|
|
|
29
33
|
The global maxima is at x [0, 0] with value 0
|
|
30
34
|
|
|
31
|
-
:param
|
|
35
|
+
:param x: A list of values. Values are evaluated between [-100, 100]
|
|
36
|
+
:type x: :class:`numpy.array` or list
|
|
32
37
|
:return: The value of the Inverted Schaffer function N. 2.
|
|
33
38
|
:rtype: float
|
|
34
39
|
"""
|
|
35
40
|
return -schaffer_function_no2(x)
|
|
36
41
|
|
|
37
42
|
|
|
38
|
-
def schaffer_function_no4(x: list) -> float:
|
|
43
|
+
def schaffer_function_no4(x: Union[np.array, list]) -> float:
|
|
39
44
|
"""
|
|
40
45
|
Schaffer function N. 4.
|
|
41
46
|
|
|
@@ -43,7 +48,8 @@ def schaffer_function_no4(x: list) -> float:
|
|
|
43
48
|
|
|
44
49
|
The global minima is at x [0, 1.253115] with value 0.292579
|
|
45
50
|
|
|
46
|
-
:param
|
|
51
|
+
:param x: array or list of values. Values are evaluated between [-100, 100]
|
|
52
|
+
:type x: :class:`numpy.array` or list
|
|
47
53
|
:return: The value of the Schaffer function N. 4.
|
|
48
54
|
:rtype: float
|
|
49
55
|
"""
|
|
@@ -52,7 +58,7 @@ def schaffer_function_no4(x: list) -> float:
|
|
|
52
58
|
)
|
|
53
59
|
|
|
54
60
|
|
|
55
|
-
def inverted_schaffer_function_no4(x: list) -> float:
|
|
61
|
+
def inverted_schaffer_function_no4(x: Union[np.array, list]) -> float:
|
|
56
62
|
"""
|
|
57
63
|
Inverted Schaffer function N. 4.
|
|
58
64
|
|
|
@@ -62,7 +68,8 @@ def inverted_schaffer_function_no4(x: list) -> float:
|
|
|
62
68
|
|
|
63
69
|
The global maxima is at x [0, 1.253115] with value -0.292579
|
|
64
70
|
|
|
65
|
-
:param
|
|
71
|
+
:param x: array or list of values. Values are evaluated between [-100, 100]
|
|
72
|
+
:type x: :class:`numpy.array` or list
|
|
66
73
|
:return: The value of the Inverted Schaffer function N. 4.
|
|
67
74
|
:rtype: float
|
|
68
75
|
"""
|
|
@@ -9,10 +9,10 @@ def schwefel(x: np.array) -> float:
|
|
|
9
9
|
|
|
10
10
|
The global minima is located at [420,9687, ..., 420,9687] with a value of 0
|
|
11
11
|
|
|
12
|
-
:param
|
|
12
|
+
:param x: input vector. The function is usually evaluated between [500, 500]
|
|
13
|
+
:type x: :class:`numpy.array`
|
|
13
14
|
:return: the value of the function
|
|
14
15
|
:rtype: float
|
|
15
|
-
:doc-author: baobab soluciones
|
|
16
16
|
"""
|
|
17
17
|
return 418.9829 * len(x) - np.sum(x * np.sin(np.sqrt(np.abs(x))))
|
|
18
18
|
|
|
@@ -26,9 +26,9 @@ def inverted_schwefel(x: np.array) -> float:
|
|
|
26
26
|
|
|
27
27
|
The global minima is located at [420,9687, ..., 420,9687] with a value of 0
|
|
28
28
|
|
|
29
|
-
:param
|
|
29
|
+
:param x: input vector. The function is usually evaluated between [500, 500]
|
|
30
|
+
:type x: :class:`numpy.array`
|
|
30
31
|
:return: the value of the function
|
|
31
32
|
:rtype: float
|
|
32
|
-
:doc-author: baobab soluciones
|
|
33
33
|
"""
|
|
34
34
|
return -schwefel(x)
|
|
@@ -55,16 +55,17 @@ class ArcGisClient:
|
|
|
55
55
|
f"There was an error on login into ArcGis: {response.json()}. Exception: {e}"
|
|
56
56
|
)
|
|
57
57
|
|
|
58
|
-
def get_geolocation(self, address: str) -> tuple:
|
|
58
|
+
def get_geolocation(self, address: str, country: str="ESP") -> tuple:
|
|
59
59
|
"""
|
|
60
60
|
Get the geolocation of an address.
|
|
61
61
|
|
|
62
62
|
:param str address: the address to get the geolocation
|
|
63
|
+
:param str country: the country of the address to get the geolocation (default Spain)
|
|
63
64
|
:return: a tuple with the longitude and the latitude for the geolocation
|
|
64
65
|
:rtype: tuple
|
|
65
66
|
:doc-author: baobab soluciones
|
|
66
67
|
"""
|
|
67
|
-
url = f"{ARCGIS_GEOCODE_URL}?f=json&token={self.token}&singleLine={address}&sourceCountry=
|
|
68
|
+
url = f"{ARCGIS_GEOCODE_URL}?f=json&token={self.token}&singleLine={address}&sourceCountry={country}&forStorage=false"
|
|
68
69
|
response = requests.get(url=url)
|
|
69
70
|
|
|
70
71
|
if response.status_code != 200:
|
|
@@ -287,6 +288,9 @@ class ArcGisClient:
|
|
|
287
288
|
data = response.json()["odCostMatrix"]
|
|
288
289
|
results = []
|
|
289
290
|
|
|
291
|
+
kilometers = data["costAttributeNames"].index("Kilometers")
|
|
292
|
+
time = data["costAttributeNames"].index("TravelTime")
|
|
293
|
+
|
|
290
294
|
for origin in origins["features"]:
|
|
291
295
|
for destination in destinations["features"]:
|
|
292
296
|
try:
|
|
@@ -296,8 +300,9 @@ class ArcGisClient:
|
|
|
296
300
|
{
|
|
297
301
|
"origin": origin["attributes"]["Name"],
|
|
298
302
|
"destination": destination["attributes"]["Name"],
|
|
299
|
-
"distance": data[origin_id][destination_id][
|
|
300
|
-
|
|
303
|
+
"distance": data[origin_id][destination_id][kilometers]
|
|
304
|
+
* 1000,
|
|
305
|
+
"time": data[origin_id][destination_id][time] * 60,
|
|
301
306
|
}
|
|
302
307
|
)
|
|
303
308
|
except KeyError:
|
|
@@ -3,6 +3,7 @@ import os
|
|
|
3
3
|
|
|
4
4
|
from google.api_core.exceptions import NotFound
|
|
5
5
|
from google.cloud import storage
|
|
6
|
+
|
|
6
7
|
from .cloud_storage import CloudStorage
|
|
7
8
|
|
|
8
9
|
|
|
@@ -215,3 +216,30 @@ class GoogleCloudStorage(CloudStorage):
|
|
|
215
216
|
except NotFound as e:
|
|
216
217
|
log.error(f"Blob {blob_name} does not exist")
|
|
217
218
|
raise e
|
|
219
|
+
|
|
220
|
+
def upload_from_folder(
|
|
221
|
+
self,
|
|
222
|
+
local_path: str,
|
|
223
|
+
blob_name: str,
|
|
224
|
+
):
|
|
225
|
+
"""
|
|
226
|
+
The upload_from_folder function uploads all files from a local folder to the Google Cloud Storage bucket.
|
|
227
|
+
|
|
228
|
+
:param str local_path: Specify the local path to the folder
|
|
229
|
+
:param str blob_name: Specify the name of the blob
|
|
230
|
+
"""
|
|
231
|
+
# Check if the path is a directory
|
|
232
|
+
if not os.path.isdir(local_path):
|
|
233
|
+
raise ValueError("The path is not a directory")
|
|
234
|
+
|
|
235
|
+
# Walk through the directory and upload the files
|
|
236
|
+
for root, dirs, files in os.walk(local_path):
|
|
237
|
+
for file in files:
|
|
238
|
+
local_file_path = os.path.join(root, file)
|
|
239
|
+
relative_path = os.path.relpath(local_file_path, local_path)
|
|
240
|
+
destination_blob_name = os.path.join(blob_name, relative_path).replace(
|
|
241
|
+
os.path.sep, "/"
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
# Upload the file to the bucket
|
|
245
|
+
self.upload_from_filename(local_file_path, destination_blob_name)
|
|
@@ -210,3 +210,25 @@ class BaseConfig:
|
|
|
210
210
|
if section is None:
|
|
211
211
|
return KeyError(f"Parameter {key} not found")
|
|
212
212
|
self.parameters.get(section)[key] = value
|
|
213
|
+
|
|
214
|
+
@classmethod
|
|
215
|
+
def create_config_template(cls, output_path: str):
|
|
216
|
+
"""
|
|
217
|
+
The create_config_template function creates a configuration file with default values for each parameter.
|
|
218
|
+
If the parameter has a default value, it will be used, otherwise an empty string will be used.
|
|
219
|
+
|
|
220
|
+
:param output_file: specify the output path for the template of the config file
|
|
221
|
+
:doc-author: baobab soluciones
|
|
222
|
+
"""
|
|
223
|
+
parser = ConfigParser()
|
|
224
|
+
# Available params are attributes in the form _ChildClass__params
|
|
225
|
+
params = cls.__getattribute__(cls, "_{}__params".format(cls.__name__))
|
|
226
|
+
for section, params in params.items():
|
|
227
|
+
parser.add_section(section)
|
|
228
|
+
for p in params:
|
|
229
|
+
if p.default is None:
|
|
230
|
+
parser.set(section, p.name, value="")
|
|
231
|
+
else:
|
|
232
|
+
parser.set(section, p.name, value=str(p.default))
|
|
233
|
+
with open(output_path, "w") as f:
|
|
234
|
+
parser.write(f)
|
|
@@ -10,7 +10,8 @@ import pandas as pd
|
|
|
10
10
|
import plotly
|
|
11
11
|
import streamlit as st
|
|
12
12
|
from PIL import Image
|
|
13
|
-
|
|
13
|
+
from mango.processing import write_json, load_json
|
|
14
|
+
from mango.table import Table
|
|
14
15
|
|
|
15
16
|
class DisplayablePath(object):
|
|
16
17
|
display_filename_prefix_middle = "├──"
|
|
@@ -467,8 +468,7 @@ class FileExplorerApp:
|
|
|
467
468
|
writer, sheet_name=sheet, index=False
|
|
468
469
|
)
|
|
469
470
|
elif path_selected.endswith(".json"):
|
|
470
|
-
|
|
471
|
-
json.dump(edited_df, f)
|
|
471
|
+
write_json(edited_df, path_selected)
|
|
472
472
|
|
|
473
473
|
@classmethod
|
|
474
474
|
def _read_plot_from_html(cls, path_selected):
|
|
@@ -621,8 +621,9 @@ class FileExplorerApp:
|
|
|
621
621
|
tab["df"],
|
|
622
622
|
use_container_width=True,
|
|
623
623
|
key=f"{key_tab}_{path_selected}_{key}",
|
|
624
|
+
num_rows="dynamic",
|
|
624
625
|
)
|
|
625
|
-
dict_edited = edited_df.
|
|
626
|
+
dict_edited = Table.from_pandas(edited_df).replace_nan()
|
|
626
627
|
data[key_tab] = dict_edited
|
|
627
628
|
if self.editable:
|
|
628
629
|
st.button(
|
|
@@ -38,7 +38,7 @@ def safe_value(x):
|
|
|
38
38
|
This function will return 0 instead.
|
|
39
39
|
|
|
40
40
|
:param x: a pyomo variable
|
|
41
|
-
:return:
|
|
41
|
+
:return: value of the variable
|
|
42
42
|
"""
|
|
43
43
|
try:
|
|
44
44
|
if x is not None:
|
|
@@ -261,6 +261,13 @@ def model_data_to_excel(model_data, path, file_name="model_data.xlsx"):
|
|
|
261
261
|
|
|
262
262
|
|
|
263
263
|
def solver_result_to_json(result, path):
|
|
264
|
+
"""
|
|
265
|
+
Save the result object in a json file.
|
|
266
|
+
|
|
267
|
+
:param result: result object from pyomo
|
|
268
|
+
:param path: path of the file
|
|
269
|
+
:return: nothing
|
|
270
|
+
"""
|
|
264
271
|
def get_val(v):
|
|
265
272
|
try:
|
|
266
273
|
if isinstance(v.value, UndefinedData):
|
|
@@ -280,6 +287,13 @@ def solver_result_to_json(result, path):
|
|
|
280
287
|
|
|
281
288
|
|
|
282
289
|
def solver_result_from_json(path, **kwargs):
|
|
290
|
+
"""
|
|
291
|
+
Load a result object from pyomo
|
|
292
|
+
|
|
293
|
+
:param path: path of the file
|
|
294
|
+
:param kwargs: kwargs for load_json
|
|
295
|
+
:return: the result object
|
|
296
|
+
"""
|
|
283
297
|
data = load_json(path, **kwargs)
|
|
284
298
|
result = SolverResults()
|
|
285
299
|
for k, v in result.items():
|