Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr/1.4.7 #263

Merged
merged 52 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
83e3540
incremented version number
mpvanderschelling Dec 7, 2023
a281051
Fixes #248
mpvanderschelling Dec 7, 2023
b13cd92
Merge pull request #249 from bessagroup/mpvanderschelling/issue248
mpvanderschelling Dec 11, 2023
69dbb8b
Add functionality to select all jobs that are finished
mpvanderschelling Dec 11, 2023
d82fbd0
Add functionality to select all jobs that are finished
mpvanderschelling Dec 13, 2023
89fb54c
Improving usability by implementing helper function to convert arbitr…
mpvanderschelling Dec 13, 2023
dc889e7
Documentation is both hosted by GitHub Pages and ReadTheDocs
mpvanderschelling Dec 13, 2023
68224ce
Documentation is both hosted by GitHub Pages and ReadTheDocs
mpvanderschelling Dec 13, 2023
0208de3
updated paper.md with new homepage link
mpvanderschelling Dec 13, 2023
60b4d24
Merge pull request #255 from bessagroup/mpvanderschelling/issue250
mpvanderschelling Dec 13, 2023
ebe8d20
Merge pull request #254 from bessagroup/mpvanderschelling/issue252
mpvanderschelling Dec 13, 2023
f013604
Merge pull request #256 from bessagroup/mpvanderschelling/issue253
mpvanderschelling Dec 13, 2023
97c2b05
Fix optimizer data assignment
mpvanderschelling Dec 13, 2023
f8d3770
Merge branch 'pr/1.4.7' of https://github.com/bessagroup/F3DASM into …
mpvanderschelling Dec 13, 2023
0991fae
add plot store for matplotlib figures
mpvanderschelling Dec 15, 2023
430669b
added GridSearch sampler
mpvanderschelling Dec 18, 2023
7597a52
Commented out unnecessary code that was causing issues with casting t…
mpvanderschelling Dec 18, 2023
e2000b1
Add method to mark all experiments with 'in progress' status as open
mpvanderschelling Feb 2, 2024
f588152
WIP Update ExperimentData and JobQueue classes
mpvanderschelling Feb 2, 2024
4fe849c
Remove unnecessary print statement in Domain class
mpvanderschelling Feb 5, 2024
f82be66
Add SamplerNames type hint
mpvanderschelling Feb 5, 2024
f442083
Update ExperimentSample class to handle all nan output data
mpvanderschelling Feb 5, 2024
95476c1
Add Sampler and SamplerNames to design module
mpvanderschelling Feb 5, 2024
5aa8491
Added overwrite functionality in optimize
mpvanderschelling Feb 5, 2024
34abed1
Add callback parameter to optimize method
mpvanderschelling Feb 5, 2024
dec5230
WIP Refactor set_x0 method to accept ExperimentData as mode
mpvanderschelling Feb 5, 2024
572711b
Update data.to_numpy() to use np.float32 dtype
mpvanderschelling Feb 6, 2024
65630bb
Refactor _callback method in _SciPyOptimizer class
mpvanderschelling Feb 6, 2024
40c7493
Add method to add experiments to optimizer
mpvanderschelling Feb 6, 2024
a0b2bb4
Refactor experimentdata_total.add_experiments() method
mpvanderschelling Feb 6, 2024
0b633a4
Add test cases for data overwrite and job queue manipulation
mpvanderschelling Feb 6, 2024
99ab40e
Refactor docstrings to improve readability
mpvanderschelling Feb 6, 2024
fbcb186
Merge pull request #260 from bessagroup/mpvanderschelling/issue259
mpvanderschelling Feb 7, 2024
68f8373
RETRY: refactoring optimization iterate and iterate_scipy
mpvanderschelling Feb 7, 2024
dca4c69
Merge pull request #262 from bessagroup/mpvanderschelling/issue259
mpvanderschelling Feb 7, 2024
56da418
bugfix
mpvanderschelling Feb 7, 2024
af9753e
Enable differentiability for benchmark functions
mpvanderschelling Feb 9, 2024
f03eed9
Fix type conversion issue in Noise class
mpvanderschelling Feb 23, 2024
a64f76b
Refactor PyBenchFunction offset generation
mpvanderschelling Feb 23, 2024
e1dc867
Refactor y calculation in Function class
mpvanderschelling Feb 23, 2024
1086a5c
Fix error handling in ExperimentData class
mpvanderschelling Feb 23, 2024
1dcdb40
Add require_gradients attribute to optimizers
mpvanderschelling Feb 23, 2024
77ad679
Add new methods for dropping output parameters and columns
mpvanderschelling Mar 6, 2024
5b95748
allows combining different domains
mpvanderschelling Mar 7, 2024
ad13821
Fix gradient method in SciPy optimizer. Fixes #89
mpvanderschelling Mar 11, 2024
641c725
Add domain to ExperimentData when overwriting data and adding cluster…
mpvanderschelling Mar 26, 2024
24b7699
update documentation about cluster_parallel mode
mpvanderschelling Mar 27, 2024
f96cc24
WIP added hydra utils module
mpvanderschelling Mar 29, 2024
920d9b4
fixes add_constant casts int to float #230
mpvanderschelling Mar 29, 2024
9e60d05
Fixes #223
mpvanderschelling Apr 19, 2024
8fd7d4b
Remove unused import
mpvanderschelling Apr 19, 2024
f286232
Update type hints in samplers.py and experimentsample.py to support 3.7
mpvanderschelling Apr 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions .github/workflows/push_to_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,37 +41,6 @@ jobs:
- name: Test with pytest (excluding abaqus tests)
run: |
python -m pytest -S abaqus
publish-sphinx-documentation:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.8"
cache: "pip" # caching pip dependencies
- name: Install package dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install documentation requirements
run: |
pip install -r docs/requirements.txt
- name: Build documentation
run: |
sphinx-build -b html ./docs/source ./docs/build/html
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: html-docs
path: docs/build/html/
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/build/html
force_orphan: false
build-package:
strategy:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.6
1.4.7
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
project = 'f3dasm'
author = 'Martin van der Schelling'
copyright = '2022, Martin van der Schelling'
version = '1.4.6'
release = '1.4.6'
version = '1.4.7'
release = '1.4.7'


# -- General configuration ----------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ There are three methods available of handeling the :class:`~f3dasm.ExperimentSam
* :code:`sequential`: regular for-loop over each of the :class:`~f3dasm.ExperimentSample` objects in order
* :code:`parallel`: utilizing the multiprocessing capabilities (with the `pathos <https://pathos.readthedocs.io/en/latest/pathos.html>`_ multiprocessing library), each :class:`~f3dasm.ExperimentSample` object is run in a separate core
* :code:`cluster`: utilizing the multiprocessing capabilities, each :class:`~f3dasm.ExperimentSample` object is run in a separate node. After completion of an sample, the node will automatically pick the next available sample. More information on this mode can be found in the :ref:`cluster-mode` section.

* :code:`cluster_parallel`: Combination of the :code:`cluster` and :code:`parallel` mode. Each node will run multiple samples in parallel.

Implement your simulator
^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
5 changes: 1 addition & 4 deletions docs/source/rst_doc_files/classes/sampling/sampling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ The function should return the samples (``input_data``) in one of the following
* A :class:`~pandas.DataFrame` object
* A :class:`~numpy.ndarray` object

.. note::

...


.. _implemented samplers:
Expand All @@ -36,7 +33,6 @@ To use the sampler in the data-driven process, you should pass the function to t
.. code-block:: python

from f3dasm.design import ExperimentData, Domain
from

domain = Domain(...)
# Create the ExperimentData object
Expand All @@ -63,4 +59,5 @@ Name Method
``"random"`` Random Uniform sampling `numpy.random.uniform <https://numpy.org/doc/stable/reference/random/generated/numpy.random.uniform.html>`_
``"latin"`` Latin Hypercube sampling `SALib.latin <https://salib.readthedocs.io/en/latest/api/SALib.sample.html?highlight=latin%20hypercube#SALib.sample.latin.sample>`_
``"sobol"`` Sobol Sequence sampling `SALib.sobol_sequence <https://salib.readthedocs.io/en/latest/api/SALib.sample.html?highlight=sobol%20sequence#SALib.sample.sobol_sequence.sample>`_
``"grid"`` Grid Search sampling `itertools.product <https://docs.python.org/3/library/itertools.html#itertools.product>`_
======================== ====================================================================== ===========================================================================================================
6 changes: 3 additions & 3 deletions docs/source/rst_doc_files/general/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
Overview
========

.. _design-of-experiments: https://bessagroup.github.io/f3dasm/classes/design/experimentdata.html
.. _sampling: https://bessagroup.github.io/f3dasm/classes/sampling/sampling.html
.. _optimizing: https://bessagroup.github.io/f3dasm/classes/optimization/optimizers.html
.. _design-of-experiments: https://f3dasm.readthedocs.io/en/latest/rst_doc_files/classes/design/experimentdata.html
.. _sampling: https://f3dasm.readthedocs.io/en/latest/rst_doc_files/classes/sampling/sampling.html
.. _optimizing: https://f3dasm.readthedocs.io/en/latest/rst_doc_files/classes/optimization/optimizers.html
.. _parallelizing: <URL for parallelizing>
.. _TORQUE system: https://hpc-wiki.info/hpc/Torque

Expand Down
4 changes: 2 additions & 2 deletions paper/paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ An overview of the different levels of abstraction is given in \autoref{fig:f3da

# Documentation and collaborative development

To improve the usability of the `f3dasm` frame­work, thorough documentation has been included with the Sphinx package. Documentation for this package can be accessed on [the homepage](https://bessagroup.github.io/f3dasm/) and will be kept up to date with the latest release of the package.
To improve the usability of the `f3dasm` frame­work, thorough documentation has been included with the Sphinx package. Documentation for this package can be accessed on [the homepage](https://f3dasm.readthedocs.io/en/latest/) and will be kept up to date with the latest release of the package.

The `f3dasm` framework relies on the collaborative efforts of scientists and developers to expand its capabilities. Therefore, it is essential to have a well-defined software development process in place. This is achieved by maintaining strict branching policies, and incorporating comprehensive testing suites and automatic continuous integration with GitHub Workflows.

Expand All @@ -138,7 +138,7 @@ To maintain the integrity of the framework, various (automatic) validation proce

# Availability

`f3dasm` and its extensions are available as a `pip` package and is compatible with Python 3.8 to 3.10 and all major operating systems (Linux, MacOS and Windows). Detailed installation instructions can be found on the ['Getting Started'](https://bessagroup.github.io/f3dasm/general/gettingstarted.html) documentation page.
`f3dasm` and its extensions are available as a `pip` package and is compatible with Python 3.8 to 3.10 and all major operating systems (Linux, MacOS and Windows). Detailed installation instructions can be found on the ['Getting Started'](https://f3dasm.readthedocs.io/en/latest/rst_doc_files/general/gettingstarted.html) documentation page.


# Acknowledgements
Expand Down
68 changes: 67 additions & 1 deletion src/f3dasm/_src/datageneration/datagenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import sys
from abc import abstractmethod
from functools import partial
from typing import Any, Callable, Optional
from typing import Any, Callable, Dict, List, Optional

if sys.version_info < (3, 8): # NOQA
from typing_extensions import Protocol # NOQA
Expand Down Expand Up @@ -187,3 +187,69 @@ def add_post_process(self, func: Callable, **kwargs):
The keyword arguments to pass to the post-processing function
"""
self.post_process = partial(func, **kwargs)


def convert_function(f: Callable,
input: List[str],
output: Optional[List[str]] = None,
kwargs: Optional[Dict[str, Any]] = None,
to_disk: Optional[List[str]] = None) -> DataGenerator:
"""
Converts a given function `f` into a `DataGenerator` object.

Parameters
----------
f : Callable
The function to be converted.
input : List[str]
A list of argument names required by the function.
output : Optional[List[str]], optional
A list of names for the return values of the function.
Defaults to None.
kwargs : Optional[Dict[str, Any]], optional
Additional keyword arguments passed to the function. Defaults to None.
to_disk : Optional[List[str]], optional
The list of output names where the value needs to be stored on disk.
Defaults to None.

Returns
-------
DataGenerator
A converted `DataGenerator` object.

Notes
-----

The function `f` can have any number of arguments and any number of returns
as long as they are consistent with the `input` and `output` arguments that
are given to this function.
"""

kwargs = kwargs if kwargs is not None else {}
to_disk = to_disk if to_disk is not None else []
output = output if output is not None else []

class TempDataGenerator(DataGenerator):
def execute(self, **_kwargs) -> None:
_input = {input_name: self.experiment_sample.get(input_name)
for input_name in input}
_output = f(**_input, **kwargs)

# check if output is empty
if output is None:
return

if len(output) == 1:
_output = (_output,)

for name, value in zip(output, _output):
if name in to_disk:
self.experiment_sample.store(name=name,
object=value,
to_disk=True)
else:
self.experiment_sample.store(name=name,
object=value,
to_disk=False)

return TempDataGenerator()
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ def augment(self, input: np.ndarray) -> np.ndarray:

scale = abs(self.noise * yy)

if isinstance(input, float):
# convert to numpy float
input = np.float64(input)

noise: np.ndarray = np.random.normal(
loc=0.0, scale=scale, size=input.shape)
y_noise = input + float(noise)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,15 @@ def _configure_offset(self):

unscaled_offset = np.atleast_1d(
[
# np.random.uniform(
# low=-abs(g[d] - self.scale_bounds[d, 0]),
# high=abs(g[d] - self.scale_bounds[d, 1]))

# This is added so we only create offsets in one quadrant

np.random.uniform(
low=-abs(g[d] - self.scale_bounds[d, 0]),
high=abs(g[d] - self.scale_bounds[d, 1]))
high=0.0)
for d in range(self.dimensionality)
]
)
Expand Down
4 changes: 2 additions & 2 deletions src/f3dasm/_src/datageneration/functions/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def execute(self, experiment_sample: ExperimentSample) -> ExperimentSample:
x = x._value
if isinstance(x, ArrayBox):
x = x._value

experiment_sample["y"] = float(self(x).ravel().astype(np.float32))
y = np.nan_to_num(self(x), nan=np.nan)
experiment_sample["y"] = float(y.ravel().astype(np.float64))
return experiment_sample

def _run(
Expand Down
28 changes: 14 additions & 14 deletions src/f3dasm/_src/datageneration/functions/pybenchfunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class Bartels(PyBenchFunction):
continuous = True
convex = False
separable = False
differentiable = False
differentiable = True
multimodal = True
randomized_term = False
parametric = False
Expand Down Expand Up @@ -660,7 +660,7 @@ class BukinN6(PyBenchFunction):
continuous = True
convex = True
separable = False
differentiable = False
differentiable = True
multimodal = True
randomized_term = False
parametric = False
Expand Down Expand Up @@ -737,7 +737,7 @@ class CrossInTray(PyBenchFunction):
continuous = True
convex = False
separable = False
differentiable = False
differentiable = True
multimodal = True
randomized_term = False
parametric = False
Expand Down Expand Up @@ -1249,7 +1249,7 @@ class HolderTable(PyBenchFunction):
continuous = True
convex = False
separable = False
differentiable = False
differentiable = True
multimodal = True
randomized_term = False
parametric = False
Expand Down Expand Up @@ -1650,7 +1650,7 @@ class Powell(PyBenchFunction):
continuous = True
convex = True
separable = True
differentiable = False
differentiable = True
multimodal = False
randomized_term = False
parametric = False
Expand Down Expand Up @@ -2116,7 +2116,7 @@ class Schwefel(PyBenchFunction):
continuous = True
convex = False
separable = True
differentiable = False
differentiable = True
multimodal = True
randomized_term = False
parametric = False
Expand Down Expand Up @@ -2155,7 +2155,7 @@ class Schwefel2_20(PyBenchFunction):
continuous = True
convex = True
separable = True
differentiable = False
differentiable = True
multimodal = False
randomized_term = False
parametric = False
Expand Down Expand Up @@ -2193,7 +2193,7 @@ class Schwefel2_21(PyBenchFunction):
continuous = True
convex = True
separable = True
differentiable = False
differentiable = True
multimodal = False
randomized_term = False
parametric = False
Expand Down Expand Up @@ -2231,7 +2231,7 @@ class Schwefel2_22(PyBenchFunction):
continuous = True
convex = True
separable = True
differentiable = False
differentiable = True
multimodal = False
randomized_term = False
parametric = False
Expand Down Expand Up @@ -2270,7 +2270,7 @@ class Schwefel2_23(PyBenchFunction):
continuous = True
convex = True
separable = True
differentiable = False
differentiable = True
multimodal = False
randomized_term = False
parametric = False
Expand Down Expand Up @@ -2490,7 +2490,7 @@ class Sphere(PyBenchFunction):
continuous = True
convex = True
separable = True
differentiable = False
differentiable = True
multimodal = False
randomized_term = False
parametric = False
Expand Down Expand Up @@ -2750,7 +2750,7 @@ class XinSheYangN2(PyBenchFunction):
continuous = False
convex = False
separable = False
differentiable = False
differentiable = True
multimodal = True
randomized_term = False
parametric = False
Expand Down Expand Up @@ -2828,7 +2828,7 @@ class XinSheYangN4(PyBenchFunction):
continuous = True
convex = True
separable = False
differentiable = False
differentiable = True
multimodal = False
randomized_term = False
parametric = False
Expand Down Expand Up @@ -2866,7 +2866,7 @@ class Zakharov(PyBenchFunction):
continuous = True
convex = False
separable = False
differentiable = False
differentiable = True
multimodal = False
randomized_term = False
parametric = False
Expand Down
Loading
Loading