Skip to content

Commit

Permalink
Add GPX surrogate model (SMTorg#530)
Browse files Browse the repository at this point in the history
* Remove obsolete warning in mixed-integer

* Initial wrapper for egobox::Gpx surrogate model (#9)

* first version of the test and new class GPX

* Implement gpx, add gpx in test_all, add an exemple, and a manual test.

* Revert setup change

---------

Co-authored-by: Rémi Lafage <[email protected]>

* Add extra install for GPX

* Add check for egobox install and add options

* Rename lowercase

* Add missing tests for doc examples

* Update doc

* Add kpls_dim option

* Add Gpx doc

* Fix kpls_dim type spec

* Comment out learning airfoil parameters example run (too slow!) in doc

* Add egobox 0.16 in requirements

* Refactor GPX

* Add GPX test guard

* Update doc

---------

Co-authored-by: Antoine-Averland <[email protected]>
  • Loading branch information
relf and Antoine-Averland authored Mar 8, 2024
1 parent 373b7da commit c7b0d73
Show file tree
Hide file tree
Showing 16 changed files with 458 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ Utilities
Main
^^^^

.. embed-module-print-plot :: smt.examples.airfoil_parameters.run_genn , 100
..
Comment out as it is too long! embed-module-print-plot :: smt.examples.airfoil_parameters.run_genn , 100

15 changes: 8 additions & 7 deletions doc/_src_docs/surrogate_models.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions doc/_src_docs/surrogate_models.rstx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ SMT contains the surrogate modeling methods listed below.
surrogate_models/kpls
surrogate_models/kplsk
surrogate_models/gekpls
surrogate_models/gpx
surrogate_models/genn
surrogate_models/mgp
surrogate_models/sgp
Expand Down
182 changes: 182 additions & 0 deletions doc/_src_docs/surrogate_models/gpx.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions doc/_src_docs/surrogate_models/gpx.rstx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
GPX
===

`GPX` is a rewrite of Kriging (aka `KRG`) and `KPLS` models of SMT in Rust.
Actually `GPX` is a wrapper of the `Gpx` model from the `egobox` library which is adapted here to the surrogate models API of SMT.

If you find the performances of the Python implementation (training/prediction time) not sufficient for your use case,
you may want to give `GPX` a try.

You will need to install the `egobox` extra dependency with the command: `pip install smt[gpx]`

More information about the `egobox` library can be found in [1]_.

Limitations
-----------

* wrt `KRG/KPLS`: `GPX` does not implement mixed integer or hierarchical variables, derivatives, noise handling or KRG sampling.

* wrt `egobox::Gpx`: `GPX` does not give access to mixture of gaussian processes, does not give access to GP sampling


See [2]_ for more information on `egobox::Gpx`.


Reference
---------

.. [1] `Lafage, R., (2022). egobox, a Rust toolbox for efficient global optimization. Journal of Open Source Software, 7(78), 4737, <https://doi.org/10.21105/joss.04737>`_

.. [2] `Tutorial egobox::Gpx <https://github.com/relf/egobox/blob/cf7e50cb23b11fda9dd255c2b29178f6d51c3242/doc/Gpx_Tutorial.ipynb>`_

Usage
-----

Example
^^^^^^^

.. embed-test-print-plot :: smt.surrogate_models.tests.test_surrogate_model_examples , Test , test_gpx , 80

Options
-------

.. embed-options-table :: smt.surrogate_models , GPX , options
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ scikit-learn
pyDOE3
numpydoc
matplotlib
ConfigSpace~=0.6.1
jenn >= 1.0.2
ConfigSpace ~= 0.6.1
jenn >= 1.0.2, <2.0
egobox ~= 0.16.0
git+https://github.com/hwangjt/sphinx_auto_embed.git # for doc generation
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ pytest # tests runner
pytest-xdist # allows running parallel testing with pytest -n <num_workers>
pytest-cov # allows to get coverage report
ruff # format and lint code
ConfigSpace~=0.6.1
jenn >= 1.0.2
ConfigSpace ~= 0.6.1
jenn >= 1.0.2, <2.0
egobox ~= 0.16.0
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
"cs": [ # pip install smt[cs]
"ConfigSpace~=0.6.1",
],
"gpx": ["egobox~=0.16"], # pip install smt[gpx]
},
python_requires=">=3.8",
zip_safe=False,
Expand Down
6 changes: 3 additions & 3 deletions smt/applications/mixed_integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ def __init__(
)
and self._surrogate.options["categorical_kernel"] is None
):
self._surrogate.options["categorical_kernel"] = (
MixIntKernelType.HOMO_HSPHERE
)
self._surrogate.options[
"categorical_kernel"
] = MixIntKernelType.HOMO_HSPHERE
warnings.warn(
"Using MixedIntegerSurrogateModel integer model with Continuous Relaxation is not supported. \
Switched to homoscedastic hypersphere kernel instead."
Expand Down
4 changes: 4 additions & 0 deletions smt/applications/tests/test_mixed_integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,11 @@ def test_examples(self):
self.run_mixed_integer_context_example()
self.run_hierarchical_variables_Goldstein()
self.run_mixed_discrete_design_space_example()
self.run_mixed_gower_example()
self.run_mixed_homo_gaussian_example()
self.run_mixed_homo_hyp_example()
if ds.HAS_CONFIG_SPACE:
self.run_mixed_cs_example()
self.run_hierarchical_design_space_example() # works only with config space impl

def run_mixed_integer_lhs_example(self):
Expand Down
2 changes: 2 additions & 0 deletions smt/surrogate_models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .kpls import KPLS
from .gekpls import GEKPLS
from .kplsk import KPLSK
from .gpx import GPX
from .genn import GENN
from .mgp import MGP
from .sgp import SGP
Expand All @@ -25,6 +26,7 @@
"KPLS",
"GEKPLS",
"KPLSK",
"GPX",
"GENN",
"MGP",
"SGP",
Expand Down
Loading

0 comments on commit c7b0d73

Please sign in to comment.