├── .coveragerc ├── .github ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md ├── actions │ └── ubuntu_restore_all │ │ └── action.yml └── workflows │ ├── every_commit.yml │ ├── main.yml │ └── version.yml ├── .gitignore ├── .pre-commit-config.yaml ├── .pylintrc ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── LICENSE ├── MANIFEST.in ├── README.md ├── docs ├── Makefile ├── benchmarking.rst ├── benchmarks.rst ├── conf.py ├── contributing.rst ├── examples │ ├── diversity │ │ └── Diversity in image generation with Nevergrad.md │ ├── guiding │ │ └── Guiding image generation with Nevergrad.md │ ├── lognormal │ │ └── Lognormal mutations in Nevergrad.md │ └── retrofitting │ │ └── Retrofitting with Nevergrad.md ├── getting_started.rst ├── index.rst ├── instrumentations_examples.py ├── machinelearning.rst ├── make.bat ├── opencompetition2020.md ├── optimization.rst ├── optimizers_ref.rst ├── parametrization.rst ├── parametrization_ref.rst ├── pyomo.rst ├── r.rst ├── resources │ ├── Nevergrad-LogoMark.png │ ├── TwoPointsDE.gif │ ├── compabasedillcond_r400s12_xpresults_nameellipsoid,rotationTrue.png │ ├── dim10_select_one_feature_r400s12_xpresults.png │ ├── dim10_select_two_features_r400s12_xpresults.png │ ├── dim10_smallbudget_r400s12_xpresults.png │ ├── doe_dim4_r400s12_xpresults.png │ ├── illcond_r50s12_xpresults_namecigar,rotationTrue.png │ ├── noise_r400s12_xpresults_namecigar,rotationTrue.png │ ├── small_discrete_r10s12_xpresults_dimension330,namehardleadingones5,useless_variables300.png │ ├── small_discrete_r10s12_xpresults_dimension330,namehardonemax5,useless_variables300.png │ └── windows_screenshots │ │ ├── CtrlWindowsAlt.jpg │ │ ├── PR.PNG │ │ ├── anacondanavigator.PNG │ │ ├── commit.PNG │ │ ├── create.PNG │ │ ├── navigator.PNG │ │ ├── newBranch.PNG │ │ ├── prompt.PNG │ │ └── spyder.PNG ├── statistics │ ├── AgStatistics.md │ ├── Statistics.md │ ├── agpie1.png │ ├── agpie3.png │ ├── agpierob1.png │ ├── agpierob3.png │ ├── pie1.png │ ├── pie3.png │ ├── pierob1.png │ └── pierob3.png ├── test_instrum.sh ├── windows.md └── winners2020.rst ├── examples ├── advbinmatrix.py ├── check_metamodel.py ├── convert_ceviche_npy.py ├── datadisc.py ├── disc.py ├── example_for_plotting_optim_curve.py ├── extract_loss_functions.py ├── overfit.py └── raytune_nevergrad_biobjective.py ├── mypy.ini ├── nevergrad ├── __init__.py ├── benchmark │ ├── __init__.py │ ├── __main__.py │ ├── additional │ │ └── example.py │ ├── core.py │ ├── execution.py │ ├── experiments.py │ ├── exporttable.py │ ├── frozenexperiments.py │ ├── gymexperiments.py │ ├── optgroups.py │ ├── optimizer_groups.txt │ ├── plotting.py │ ├── sphere_perf_example.csv │ ├── test_core.py │ ├── test_execution.py │ ├── test_experiments.py │ ├── test_plotting.py │ ├── test_utils.py │ ├── test_xpbase.py │ ├── utils.py │ └── xpbase.py ├── common │ ├── __init__.py │ ├── decorators.py │ ├── errors.py │ ├── sphere.py │ ├── test_decorators.py │ ├── test_testing.py │ ├── test_tools.py │ ├── testing.py │ ├── tools.py │ └── typing.py ├── examples │ └── powersystem.py ├── functions │ ├── __init__.py │ ├── ac │ │ ├── __init__.py │ │ ├── ac.py │ │ └── test_ac.py │ ├── arcoating │ │ ├── __init__.py │ │ ├── core.py │ │ └── test_core.py │ ├── base.py │ ├── control │ │ ├── ARS_LICENSE │ │ ├── __init__.py │ │ ├── core.py │ │ ├── mujoco.py │ │ └── test_mujoco.py │ ├── corefuncs.py │ ├── cycling │ │ ├── Extending Nevergrad, an Optimisation Platform.pdf │ │ ├── Extending Nevergrad, an Optimisation Platform.xlsx │ │ ├── __init__.py │ │ ├── cycling.py │ │ ├── cyclist.py │ │ ├── mensteampursuit.py │ │ ├── simulationresult.py │ │ ├── teampursuit.py │ │ ├── test_cycling.py │ │ └── womensteampursuit.py │ ├── fishing │ │ ├── __init__.py │ │ ├── core.py │ │ └── test_core.py │ ├── functionlib.py │ ├── games │ │ ├── __init__.py │ │ ├── game.py │ │ └── test_game.py │ ├── gym │ │ ├── __init__.py │ │ ├── multigym.py │ │ ├── test_multigym.py │ │ └── tuple_gym_env.py │ ├── helpers.py │ ├── images │ │ ├── __init__.py │ │ ├── core.py │ │ ├── headrgb_olivier.png │ │ ├── imagelosses.py │ │ ├── test_core.py │ │ └── test_imagelosses.py │ ├── iohprofiler │ │ ├── __init__.py │ │ ├── core.py │ │ └── test_core.py │ ├── leaderboard.csv │ ├── lsgo │ │ ├── LICENSE.txt │ │ ├── README.md │ │ ├── __init__.py │ │ ├── _core.py │ │ ├── _funcs.py │ │ ├── cdatafiles │ │ │ ├── F1-xopt.txt │ │ │ ├── F10-R100.txt │ │ │ ├── F10-R25.txt │ │ │ ├── F10-R50.txt │ │ │ ├── F10-p.txt │ │ │ ├── F10-s.txt │ │ │ ├── F10-w.txt │ │ │ ├── F10-xopt.txt │ │ │ ├── F11-R100.txt │ │ │ ├── F11-R25.txt │ │ │ ├── F11-R50.txt │ │ │ ├── F11-p.txt │ │ │ ├── F11-s.txt │ │ │ ├── F11-w.txt │ │ │ ├── F11-xopt.txt │ │ │ ├── F12-xopt.txt │ │ │ ├── F13-R100.txt │ │ │ ├── F13-R25.txt │ │ │ ├── F13-R50.txt │ │ │ ├── F13-p.txt │ │ │ ├── F13-s.txt │ │ │ ├── F13-w.txt │ │ │ ├── F13-xopt.txt │ │ │ ├── F14-R100.txt │ │ │ ├── F14-R25.txt │ │ │ ├── F14-R50.txt │ │ │ ├── F14-p.txt │ │ │ ├── F14-s.txt │ │ │ ├── F14-w.txt │ │ │ ├── F14-xopt.txt │ │ │ ├── F15-xopt.txt │ │ │ ├── F2-xopt.txt │ │ │ ├── F3-xopt.txt │ │ │ ├── F4-R100.txt │ │ │ ├── F4-R25.txt │ │ │ ├── F4-R50.txt │ │ │ ├── F4-p.txt │ │ │ ├── F4-s.txt │ │ │ ├── F4-w.txt │ │ │ ├── F4-xopt.txt │ │ │ ├── F5-R100.txt │ │ │ ├── F5-R25.txt │ │ │ ├── F5-R50.txt │ │ │ ├── F5-p.txt │ │ │ ├── F5-s.txt │ │ │ ├── F5-w.txt │ │ │ ├── F5-xopt.txt │ │ │ ├── F6-R100.txt │ │ │ ├── F6-R25.txt │ │ │ ├── F6-R50.txt │ │ │ ├── F6-p.txt │ │ │ ├── F6-s.txt │ │ │ ├── F6-w.txt │ │ │ ├── F6-xopt.txt │ │ │ ├── F7-R100.txt │ │ │ ├── F7-R25.txt │ │ │ ├── F7-R50.txt │ │ │ ├── F7-p.txt │ │ │ ├── F7-s.txt │ │ │ ├── F7-w.txt │ │ │ ├── F7-xopt.txt │ │ │ ├── F8-R100.txt │ │ │ ├── F8-R25.txt │ │ │ ├── F8-R50.txt │ │ │ ├── F8-p.txt │ │ │ ├── F8-s.txt │ │ │ ├── F8-w.txt │ │ │ ├── F8-xopt.txt │ │ │ ├── F9-R100.txt │ │ │ ├── F9-R25.txt │ │ │ ├── F9-R50.txt │ │ │ ├── F9-p.txt │ │ │ ├── F9-s.txt │ │ │ ├── F9-w.txt │ │ │ └── F9-xopt.txt │ │ ├── test_core.py │ │ └── test_funcs.py │ ├── mixsimulator │ │ ├── __init__.py │ │ ├── core.py │ │ └── test_core.py │ ├── ml │ │ ├── __init__.py │ │ ├── mlfunctionlib.py │ │ └── test_mlfunctionlib.py │ ├── mlda │ │ ├── __init__.py │ │ ├── datasets.py │ │ ├── problems.py │ │ ├── test_datasets.py │ │ └── test_problems.py │ ├── multiobjective │ │ └── __init__.py │ ├── olympussurfaces │ │ ├── __init__.py │ │ ├── core.py │ │ └── test_core.py │ ├── pbt.py │ ├── photonics │ │ ├── __init__.py │ │ ├── bender.py │ │ ├── core.py │ │ ├── epsilon_epscSi.npy │ │ ├── epsilon_solar.npy │ │ ├── functions.py │ │ ├── gambas.py │ │ ├── mode_converter.py │ │ ├── photonics.py │ │ ├── test_core.py │ │ └── wavelength_solar.npy │ ├── powersystems │ │ ├── __init__.py │ │ ├── core.py │ │ └── test_core.py │ ├── pyomo │ │ ├── __init__.py │ │ ├── core.py │ │ ├── test_core.py │ │ ├── test_model_1.dat │ │ └── test_pyomo_doc.py │ ├── rl │ │ ├── __init__.py │ │ ├── agents.py │ │ ├── base.py │ │ ├── envs.py │ │ ├── test_agents.py │ │ └── test_envs.py │ ├── rocket │ │ ├── __init__.py │ │ ├── rocket.py │ │ └── test_rocket.py │ ├── stsp │ │ ├── __init__.py │ │ ├── core.py │ │ └── test_core.py │ ├── test_base.py │ ├── test_corefuncs.py │ ├── test_functionlib.py │ ├── test_utils.py │ ├── topology_optimization │ │ ├── __init__.py │ │ ├── core.py │ │ └── test_core.py │ ├── unitcommitment │ │ ├── __init__.py │ │ ├── core.py │ │ └── test_core.py │ └── utils.py ├── ops │ ├── __init__.py │ ├── constraints.py │ └── test_constraints.py ├── optimization │ ├── __init__.py │ ├── base.py │ ├── callbacks.py │ ├── differentialevolution.py │ ├── es.py │ ├── experimentalvariants.py │ ├── externalbo.py │ ├── families.py │ ├── helpers.py │ ├── metamodel.py │ ├── multiobjective │ │ ├── __init__.py │ │ ├── core.py │ │ ├── hypervolume.py │ │ ├── nsga2.py │ │ ├── test_core.py │ │ ├── test_hypervolume.py │ │ └── test_nsga2.py │ ├── mutations.py │ ├── oneshot.py │ ├── optimizerlib.py │ ├── recaster.py │ ├── recastlib.py │ ├── recorded_recommendations.csv │ ├── requirements_check.py │ ├── sequences.py │ ├── test_base.py │ ├── test_callbacks.py │ ├── test_doc.py │ ├── test_externalbo.py │ ├── test_mutations.py │ ├── test_optimizerlib.py │ ├── test_recaster.py │ ├── test_sa.py │ ├── test_sequences.py │ ├── test_special.py │ ├── test_suggest.py │ ├── test_tabu.py │ ├── test_utils.py │ └── utils.py └── parametrization │ ├── __init__.py │ ├── _datalayers.py │ ├── _layering.py │ ├── choice.py │ ├── container.py │ ├── core.py │ ├── data.py │ ├── discretization.py │ ├── examples │ └── script.py │ ├── helpers.py │ ├── instantiate.py │ ├── mutation.py │ ├── parameter.py │ ├── test_discretization.py │ ├── test_instantiate.py │ ├── test_layers.py │ ├── test_mutation.py │ ├── test_param_doc.py │ ├── test_parameter.py │ ├── test_parameters_legacy.py │ ├── test_transforms.py │ ├── test_utils.py │ ├── transforms.py │ └── utils.py ├── pyproject.toml ├── requirements ├── bench.txt ├── dev.txt └── main.txt ├── scripts ├── ceviche.sh ├── cevicheplots.sh ├── check_best_ceviche.sh ├── compare.sh ├── create_overview.sh ├── createbestof.sh ├── dagstuhloid.sh ├── findbuggylineincsvfile.sh ├── get_statistics.sh ├── latexize.sh ├── multirank.sh ├── multirank_robust.sh ├── othercompare.sh ├── overfit.sh ├── pies_multirank.sh ├── plot_ceviche.sh ├── plot_dagstuhloid.sh ├── plot_post_ceviche.sh ├── regularized_ceviche.sh ├── tex │ ├── beginning.tex │ ├── biblio.bib │ ├── conclusion.tex │ └── end.tex ├── txt │ ├── aquacrop_fao.txt │ ├── bonnans.txt │ ├── deceptive.txt │ ├── double_o_seven.txt │ ├── fishing.txt │ ├── instrum_discrete.txt │ ├── keras_tuning.txt │ ├── lsgo.txt │ ├── mldakmeans.txt │ ├── mltuning.txt │ ├── mono_rocket.txt │ ├── ms_bbob.txt │ ├── multimodal.txt │ ├── multiobjective_example.txt │ ├── multiobjective_example_hd.txt │ ├── multiobjective_example_many_hd.txt │ ├── naive_seq_keras_tuning.txt │ ├── naive_seq_mltuning.txt │ ├── naive_veryseq_keras_tuning.txt │ ├── naivemltuning.txt │ ├── nano_naive_seq_mltuning.txt │ ├── nano_naive_veryseq_mltuning.txt │ ├── nano_seq_mltuning.txt │ ├── nano_veryseq_mltuning.txt │ ├── oneshot_mltuning.txt │ ├── pbbob.txt │ ├── pbo_reduced_suite.txt │ ├── powersystems.txt │ ├── ranknoisy.txt │ ├── reduced_yahdlbbbob.txt │ ├── rocket.txt │ ├── seq_keras_tuning.txt │ ├── seq_mltuning.txt │ ├── sequential_instrum_discrete.txt │ ├── sequential_topology_optimization.txt │ ├── spsa_benchmark.txt │ ├── topology_optimization.txt │ ├── ultrasmall_photonics.txt │ ├── ultrasmall_photonics2.txt │ ├── veryseq_keras_tuning.txt │ ├── verysmall_photonics.txt │ ├── verysmall_photonics2.txt │ ├── yabbob.txt │ ├── yabigbbob.txt │ ├── yaboundedbbob.txt │ ├── yaboxbbob.txt │ ├── yahdbbob.txt │ ├── yamegapenbbob.txt │ ├── yamegapenbigbbob.txt │ ├── yamegapenboundedbbob.txt │ ├── yamegapenboxbbob.txt │ ├── yamegapenhdbbob.txt │ ├── yanoisybbob.txt │ ├── yaonepenbbob.txt │ ├── yaonepenbigbbob.txt │ ├── yaonepenboundedbbob.txt │ ├── yaonepenboxbbob.txt │ ├── yaonepennoisybbob.txt │ ├── yaonepenparabbob.txt │ ├── yaonepensmallbbob.txt │ ├── yaparabbob.txt │ ├── yapenbbob.txt │ ├── yapenboundedbbob.txt │ ├── yapenboxbbob.txt │ ├── yapennoisybbob.txt │ ├── yapenparabbob.txt │ ├── yapensmallbbob.txt │ ├── yasmallbbob.txt │ ├── yatinybbob.txt │ ├── yatuningbbob.txt │ ├── zp_ms_bbob.txt │ └── zp_pbbob.txt └── warmstart_ceviche.sh └── setup.py /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | omit = */test_*.py 3 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to nevergrad 2 | 3 | We want to make contributing to this project as easy and transparent as possible. 4 | 5 | Whether you want to contribute or not, don't hesitate to join [Nevergrad users' Facebook group](https://www.facebook.com/groups/nevergradusers/) 6 | 7 | Guidelines are available in the [Contributing to Nevergrad](https://facebookresearch.github.io/nevergrad/contributing.html) section of the [documentation](https://facebookresearch.github.io/nevergrad/) 8 | 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Steps to reproduce 2 | 3 | 1. _____ 4 | 2. _____ 5 | 3. _____ 6 | 7 | ## Observed Results 8 | 9 | * What happened? This could be a description, log output, etc. 10 | 11 | ## Expected Results 12 | 13 | * What did you expect to happen? 14 | 15 | ## Relevant Code 16 | 17 | ``` 18 | // TODO(you): code here to reproduce the problem 19 | ``` 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Types of changes 2 | 3 | 4 | 5 | - [ ] Docs change / refactoring / dependency upgrade 6 | - [ ] Bug fix (non-breaking change which fixes an issue) 7 | - [ ] New feature (non-breaking change which adds functionality) 8 | - [ ] Breaking change (fix or feature that would cause existing functionality to change) 9 | 10 | ## Motivation and Context / Related issue 11 | 12 | 13 | 14 | 15 | 16 | ## How Has This Been Tested (if it applies) 17 | 18 | 19 | 20 | ## Checklist 21 | 22 | 23 | 24 | 25 | - [ ] The documentation is up-to-date with the changes I made. 26 | - [ ] I have read the [**CONTRIBUTING**](https://facebookresearch.github.io/nevergrad/contributing.html) document and completed the CLA (see [**CLA**](https://facebookresearch.github.io/nevergrad/contributing.html#contributor-license-agreement-cla)). 27 | - [ ] All tests passed, and additional code has been covered with new tests. 28 | 29 | 30 | -------------------------------------------------------------------------------- /.github/actions/ubuntu_restore_all/action.yml: -------------------------------------------------------------------------------- 1 | name: ubuntu_restore_all 2 | runs: 3 | using: composite 4 | steps: 5 | - name: restore_cache 6 | uses: actions/cache@v4 7 | with: 8 | key: v4-dependencies-{{ checksum "requirements/dev.txt" }}-{{ checksum "requirements/main.txt"}}-{{ checksum "requirements/bench.txt"}} 9 | path: ./venv 10 | restore-keys: | 11 | v4-dependencies-{{ checksum "requirements/dev.txt" }}-{{ checksum "requirements/main.txt"}}-{{ checksum "requirements/bench.txt"}} 12 | v4-dependencies-main-{{ checksum "requirements/main.txt"}} 13 | - name: "[all] Install dependencies" 14 | run: | 15 | #python3 -m venv venv 16 | rm -rf venv && python3 -m venv venv 17 | . venv/bin/activate 18 | pip install --progress-bar off -U pip setuptools==71.0.0 19 | ( unset GITHUB_REF ; pip install --progress-bar off IOHexperimenter>=0.2.9.2 ) 20 | pip install --progress-bar off -e .[all] 21 | #pip install --progress-bar off --use-deprecated=legacy-resolver -e .[all] 22 | pip install --progress-bar off -U numpy==1.24.0 matplotlib==3.9.0 pyomo==5.7.1 23 | pip install keras==2.6.0 # issue on Nov 4th 2021 24 | shell: bash 25 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: facebookresearch/nevergrad/main 2 | on: 3 | push: 4 | branches: 5 | - main 6 | jobs: 7 | docs-links: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/setup-python@v5 11 | with: 12 | python-version: '3.9' 13 | - uses: actions/checkout@v4.1.0 14 | - uses: "./.github/actions/ubuntu_restore_all" 15 | - name: Check links 16 | run: | 17 | . venv/bin/activate 18 | cd docs/ 19 | make linkcheck 20 | -------------------------------------------------------------------------------- /.github/workflows/version.yml: -------------------------------------------------------------------------------- 1 | name: facebookresearch/nevergrad/release 2 | on: 3 | push: 4 | tags: 5 | - '[0-9]+.[0-9]+.[0-9]+' 6 | - '[0-9]+.[0-9]+.[0-9]+.post[0-9]+' 7 | env: 8 | PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} 9 | CIRCLE_TAG: ${{ github.ref_name }} 10 | jobs: 11 | pypi-deploy: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/setup-python@v5 15 | with: 16 | python-version: '3.9' 17 | - uses: actions/checkout@v4.1.0 18 | - uses: "./.github/actions/ubuntu_restore_all" 19 | - name: Run wheel and check package 20 | run: | 21 | . venv/bin/activate 22 | pip install wheel 23 | rm -rf dist # make sure it's clean 24 | echo "Creating sdist" 25 | python setup.py sdist 26 | echo "Created sdist, now creating wheel" 27 | python setup.py bdist_wheel 28 | echo "Created wheel" 29 | mkdir nevergrad-build 30 | mv dist nevergrad-build/ 31 | - name: Create .pypirc 32 | run: | 33 | echo -e "[pypi]" >> ~/.pypirc 34 | echo -e "username = __token__" >> ~/.pypirc 35 | echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc 36 | - name: Verify tag 37 | run: python setup.py verify_circleci_version 38 | - name: upload to pypi 39 | run: | 40 | echo "Deploying" 41 | . venv/bin/activate 42 | du -h nevergrad-build/dist/* 43 | twine check nevergrad-build/dist/nevergrad-* 44 | twine upload nevergrad-build/dist/nevergrad-* --verbose 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files / tmp 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | *.swp 6 | *_build 7 | 8 | # C extensions 9 | *.so 10 | 11 | # OS specific files 12 | .DS_Store 13 | 14 | # Distribution / packaging / data storage 15 | data/ 16 | outputs/ 17 | .Python 18 | env/ 19 | build/ 20 | develop-eggs/ 21 | dist/ 22 | downloads/ 23 | eggs/ 24 | .eggs/ 25 | lib/ 26 | lib64/ 27 | parts/ 28 | sdist/ 29 | var/ 30 | wheels/ 31 | *.egg-info/ 32 | .installed.cfg 33 | *.egg 34 | 35 | # PyInstaller 36 | # Usually these files are written by a python script from a template 37 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 38 | *.manifest 39 | *.spec 40 | 41 | # Installer logs 42 | pip-log.txt 43 | pip-delete-this-directory.txt 44 | 45 | # Unit test / coverage reports 46 | htmlcov/ 47 | .tox/ 48 | .coverage 49 | .coverage.* 50 | .cache 51 | coverage.xml 52 | *.cover 53 | .hypothesis/ 54 | 55 | # Translations 56 | *.mo 57 | *.pot 58 | 59 | # Django stuff: 60 | *.log 61 | local_settings.py 62 | 63 | # Flask stuff: 64 | instance/ 65 | .webassets-cache 66 | 67 | # Scrapy stuff: 68 | .scrapy 69 | 70 | # Sphinx documentation 71 | docs/_build/ 72 | 73 | # PyBuilder 74 | target/ 75 | 76 | # Jupyter Notebook 77 | .ipynb_checkpoints 78 | 79 | # pyenv 80 | .python-version 81 | 82 | # celery beat schedule file 83 | celerybeat-schedule 84 | 85 | # SageMath parsed files 86 | *.sage.py 87 | 88 | # dotenv 89 | .env 90 | 91 | # virtualenv 92 | .venv 93 | venv/ 94 | ENV/ 95 | 96 | # Spyder project settings 97 | .spyderproject 98 | .spyproject 99 | 100 | # Rope project settings 101 | .ropeproject 102 | 103 | # mkdocs documentation 104 | /site 105 | 106 | # mypy 107 | .mypy_cache/ 108 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/pre-commit/pre-commit-hooks 3 | rev: v2.2.3 4 | hooks: 5 | - id: trailing-whitespace 6 | - id: end-of-file-fixer 7 | - id: check-added-large-files 8 | # - repo: https://github.com/pre-commit/mirrors-autopep8 9 | # rev: v1.4.4 # Use the sha / tag you want to point at 10 | # hooks: 11 | # - id: autopep8 12 | # exclude: ^scripts/ 13 | # args: ['-i', '--max-line-length=140'] 14 | - repo: https://github.com/python/black 15 | rev: 22.3.0 16 | hooks: 17 | - id: black 18 | language_version: python3 19 | - repo: https://github.com/pre-commit/mirrors-pylint 20 | rev: v2.4.4 21 | hooks: 22 | - id: pylint 23 | exclude: ^scripts/ 24 | args: ['--disable=bad-continuation'] # coz incompatible with black 25 | - repo: https://github.com/google/yamlfmt 26 | rev: v0.14.0 27 | hooks: 28 | - id: yamlfmt 29 | -------------------------------------------------------------------------------- /.pylintrc: -------------------------------------------------------------------------------- 1 | [MASTER] 2 | extension-pkg-whitelist= 3 | numpy, nose, nose.tools, numpy.testing, pathlib.PurePath, pathlib.PosixPath, pathlib.Path 4 | 5 | [MESSAGES CONTROL] 6 | # disabled messages 7 | disable= 8 | invalid-name, missing-docstring, too-few-public-methods, protected-access, import-error, 9 | fixme, no-else-return, no-member, useless-import-alias, unsubscriptable-object, 10 | too-many-arguments, too-many-instance-attributes, too-many-lines, too-many-locals 11 | 12 | [TYPECHECK] 13 | ignored-modules = numpy, numpy.testing 14 | ignored-classes = numpy, numpy.testing 15 | 16 | 17 | [FORMAT] 18 | # Maximum number of characters on a single line. 19 | max-line-length=140 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Facebook, Inc. and its affiliates. 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. 22 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE README.md 2 | include requirements/*.txt 3 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | # Configuration file for the Sphinx documentation builder. 7 | # 8 | # This file only contains a selection of the most common options. For a full 9 | # list see the documentation: 10 | # http://www.sphinx-doc.org/en/master/config 11 | 12 | # -- Path setup -------------------------------------------------------------- 13 | 14 | # If extensions (or modules to document with autodoc) are in another directory, 15 | # add these directories to sys.path here. If the directory is relative to the 16 | # documentation root, use os.path.abspath to make it absolute, like shown here. 17 | 18 | import os 19 | import sys 20 | 21 | sys.path.insert(0, os.path.abspath("..")) 22 | 23 | 24 | # -- Project information ----------------------------------------------------- 25 | 26 | project = "nevergrad" 27 | copyright = "2019, Facebook AI Research" # pylint: disable=redefined-builtin 28 | author = "Facebook AI Research" 29 | 30 | 31 | # -- General configuration --------------------------------------------------- 32 | 33 | # Add any Sphinx extension module names here, as strings. They can be 34 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 35 | # ones. 36 | extensions = [ 37 | "sphinx.ext.autodoc", 38 | "sphinx.ext.githubpages", 39 | "sphinx.ext.coverage", 40 | "sphinx.ext.napoleon", 41 | "sphinx.ext.autosummary", 42 | "recommonmark", 43 | ] 44 | 45 | source_suffix = { 46 | ".rst": "restructuredtext", 47 | ".txt": "markdown", 48 | ".md": "markdown", 49 | } 50 | 51 | master_doc = "index" 52 | 53 | # Add any paths that contain templates here, relative to this directory. 54 | templates_path = [] 55 | 56 | # List of patterns, relative to source directory, that match files and 57 | # directories to ignore when looking for source files. 58 | # This pattern also affects html_static_path and html_extra_path. 59 | exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] 60 | 61 | 62 | # -- Options for HTML output ------------------------------------------------- 63 | 64 | # The theme to use for HTML and HTML Help pages. See the documentation for 65 | # a list of builtin themes. 66 | # 67 | html_theme = "sphinx_rtd_theme" 68 | 69 | # Add any paths that contain custom static files (such as style sheets) here, 70 | # relative to this directory. They are copied after the builtin static files, 71 | # so a file named "default.css" will overwrite the builtin "default.css". 72 | html_static_path = [] 73 | 74 | # -- Other -- 75 | linkcheck_ignore = [ 76 | r"https://gecco-2020.sigevo.org/*", 77 | "windows.html", 78 | "https://ieeexplore.ieee.org/*", 79 | "https://iohprofiler.liacs.nl/", # server error: bad gateway 80 | "https://www.facebook.com/whitehat/", # server error: 500 81 | r"https://arxiv.org/abs/*", 82 | ] # Transient certificate error :( 83 | -------------------------------------------------------------------------------- /docs/examples/diversity/Diversity in image generation with Nevergrad.md: -------------------------------------------------------------------------------- 1 | 2 | Related paper: https://arxiv.org/abs/2310.12583 3 | 4 | Related plugin: https://github.com/mathuvu/sd-webui-diversity 5 | 6 | Comments welcome here: https://www.facebook.com/groups/nevergradusers/ 7 | 8 | ## Diversity 9 | 10 | Randomly generating points in a domain can be disappointing: sometimes ten random values are poorly distributed in the domain. 11 | 12 | Therefore, quasi-random has been invented for improving the diversity (a.k.a reducing the redundancies). 13 | 14 | For example, 15 | - Van Der Corput sequences are more evenly distributed than random sequences in [0,1] 16 | - Halton sequences are more evenly distributed than random points in the hypersquare 17 | - Hammersley sequences are more evenly distributed than random points in the high-dimensional hypersquare. 18 | 19 | ## Diversity in high-dimensional contexts 20 | 21 | 22 | Using Nevergrad, we create points which are more evenly distributed than random points in high-dimensional spheres or high-dimensional normal random variables. 23 | 24 | For example: 25 | ` 26 | `# x is a batch of 50 random latent vectors, with size 256x256 and 3 channels 27 | 28 | `x = np.random.randn(50,256,256,3)` 29 | 30 | `from nevergrad.common import sphere` 31 | 32 | `derand_x = quasi_randomize(x)` 33 | 34 | creates a point set with the same shape as x, and with some nice properties. 35 | 36 | ## Application to image generation 37 | 38 | Many latent diffusion models use random latent variables. 39 | They create an image, with as inputs: 40 | - a randomly drawn normal latent tensor, e.g. 256x256x3 41 | - a prompt, chosen by the user 42 | When creating a batch of 50 images, they therefore might need a tensor of shape 50x256x256x3, i.e. 50 latent variables of shape 256x256x3. 43 | If we quasi-randomize these latent variables, we get more diversity. 44 | 45 | For example: 46 | `# x is a batch of 50 random latent vectors, with size 256x256 and 3 channels 47 | x = np.random.randn(50,256,256,3)` 48 | `from nevergrad.common import sphere` 49 | `derand_x = quasi_randomize(x)` 50 | `Images=[]` 51 | `for i in range(50):` 52 | `Images+= my_latent_image_generator(derand_x[i]) # Should have more diversity than with x[i]` 53 | 54 | 55 | ## Citation 56 | 57 | ``` 58 | @misc{imagesdiversity_nevergrad, 59 | author = {Evergrad, N.}, 60 | title = {Image diversity with Nevergrad}, 61 | year = {2024}, 62 | publisher = {GitHub}, 63 | journal = {GitHub repository}, 64 | howpublished = {\url{https://github.com/facebookresearch/nevergrad/blob/main/nevergrad/common/sphere.py}}, 65 | commit = {01e1bc02e366783d37adfbf7af6326457977ef1f} 66 | } 67 | 68 | @misc{zameshina2023diversediffusionenhancingimage, 69 | title={Diverse Diffusion: Enhancing Image Diversity in Text-to-Image Generation}, 70 | author={Mariia Zameshina and Olivier Teytaud and Laurent Najman}, 71 | year={2023}, 72 | eprint={2310.12583}, 73 | archivePrefix={arXiv}, 74 | primaryClass={cs.CV}, 75 | url={https://arxiv.org/abs/2310.12583}, 76 | } 77 | 78 | ``` 79 | -------------------------------------------------------------------------------- /docs/examples/lognormal/Lognormal mutations in Nevergrad.md: -------------------------------------------------------------------------------- 1 | We present a family of black-box optimization algorithms recently added in Nevergrad. We explain how they can be used for improving fake detection algorithms. 2 | ## Lognormal algorithm 3 | 4 | Lognormal mutations have been added in Nevergrad. 5 | 6 | Papers: 7 | - https://dl.acm.org/doi/10.1145/1389095.1389298 8 | - https://dl.acm.org/doi/abs/10.1145/2001576.2001699 9 | 10 | ## Extension to the discrete setting 11 | 12 | Nevergrad contains an automatic adaptation of continuous algorithms to discrete settings and of discrete algorithms to continuous settings. It turns out that the lognormal algorithm performs quite well in some continuous cases: 13 | - when the problem is very difficult (in particular, highly multimodal); 14 | - when there is a good prior (a probability distribution) on the local of the optimum. 15 | ## Application to fake images 16 | 17 | We observe the followings: 18 | - No-box attacks are excellent for some fake detectors 19 | - Square-Attacks are excellent for many fake detectors 20 | 21 | However, both attacks can be detected by a ResNet trained on a few thousands images. 22 | 23 | We observe that: 24 | - Lognormal is not necessarily better than square-attacks, but it succeeds on many detectors. 25 | - Lognormal attacks are not detected by detectors specialized on no-box or square-attacks 26 | 27 | Therefore they must be included in a good defense mechanism. 28 | We also note that using algorithms coming from generic black-box optimization algorithms creates a wide range of attacks, all of them have to be detected. 29 | 30 | ## Citation 31 | 32 | ``` 33 | @misc{lognormal_nevergrad, 34 | author = {Evergrad, N.}, 35 | title = {Log-Normal mutations in Nevergrad}, 36 | year = {2024}, 37 | publisher = {GitHub}, 38 | journal = {GitHub repository}, 39 | howpublished = {\url{https://github.com/facebookresearch/nevergrad/optimization/optimizerlib.py}}, 40 | commit = {6f952d4e7a883fa2bbf3fe0fd0e38b22bd953a1f} 41 | } 42 | ``` 43 | -------------------------------------------------------------------------------- /docs/examples/retrofitting/Retrofitting with Nevergrad.md: -------------------------------------------------------------------------------- 1 | 2 | Comments welcome here: https://www.facebook.com/groups/nevergradusers/ 3 | ## What is retrofitting ? 4 | 5 | Retrofitting is, in general, the addition of new features. 6 | 7 | In machine learning, Retrofitting is typically the modification of a model using high-level information. 8 | 9 | ## When is classical gradient-based deep learning limited ? 10 | 11 | Consider a model obtained by deep learning: 12 | - MiDaS for depth estimation https://github.com/isl-org/MiDaS 13 | - Arnold for killing monsters at Doom https://github.com/glample/Arnold 14 | - Code generation 15 | 16 | Then, one can find non-differentiable criteria which are close to the expected figure of merit, but can not easily be used in a deep-learning optimization: 17 | - In MiDaS, many use cases need excellent performance for an ad hoc loss function, e.g. the frequency of failing by more than X%. This loss function has a gradient zero almost everywhere. 18 | - In Doom, we might consider a combination of kills per life and life expectancy. These criteria are not directly differentiable 19 | - In Code generation, we might consider performance (speed) at test time. 20 | 21 | ## Nevergrad for retrofitting 22 | 23 | Nevergrad does not use gradients, this is all the point of Nevergrad. Therefore we propose the following approach: 24 | - Identify a small set of parameters, which have a big impact on the behavior of the model. For example, rescaling factors, or a single layer of a deep net. 25 | - identify a loss function and data. It makes sense only if you use elements in this loss function that can not be used in a classical deep learning framework: 26 | - because it is not differentiable 27 | - because it can be computed only after running many time steps, as in reinforcement learning. 28 | 29 | Then, use Nevergrad for optimizing these parameters using that loss function. 30 | 31 | We got positive results for MiDaS, Arnold, Code generation, and others. 32 | 33 | ## Enhancements 34 | 35 | Post in https://www.facebook.com/groups/nevergradusers/ if you need code or help. 36 | 37 | 38 | ## Citation 39 | 40 | ``` 41 | @misc{retrofitting_nevergrad, 42 | author = {Evergrad, N.}, 43 | title = {Retrofitting with Nevergrad}, 44 | year = {2024}, 45 | publisher = {GitHub}, 46 | journal = {GitHub repository}, 47 | howpublished = {\url{https://github.com/facebookresearch/nevergrad/blob/main/nevergrad/common/sphere.py}}, 48 | commit = {01e1bc02e366783d37adfbf7af6326457977ef1f} 49 | } 50 | 51 | 52 | 53 | ``` 54 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | REM Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 2 | REM 3 | REM This source code is licensed under the MIT license found in the 4 | REM LICENSE file in the root directory of this source tree. 5 | 6 | 7 | @ECHO OFF 8 | 9 | pushd %~dp0 10 | 11 | REM Command file for Sphinx documentation 12 | 13 | if "%SPHINXBUILD%" == "" ( 14 | set SPHINXBUILD=sphinx-build 15 | ) 16 | set SOURCEDIR=. 17 | set BUILDDIR=_build 18 | 19 | if "%1" == "" goto help 20 | 21 | %SPHINXBUILD% >NUL 2>NUL 22 | if errorlevel 9009 ( 23 | echo. 24 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 25 | echo.installed, then set the SPHINXBUILD environment variable to point 26 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 27 | echo.may add the Sphinx directory to PATH. 28 | echo. 29 | echo.If you don't have Sphinx installed, grab it from 30 | echo.http://sphinx-doc.org/ 31 | exit /b 1 32 | ) 33 | 34 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 35 | goto end 36 | 37 | :help 38 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 39 | 40 | :end 41 | popd 42 | -------------------------------------------------------------------------------- /docs/optimizers_ref.rst: -------------------------------------------------------------------------------- 1 | Optimizers API Reference 2 | ======================== 3 | 4 | Optimizer API 5 | ------------- 6 | 7 | All the optimizers share the following common API: 8 | 9 | .. autoclass:: nevergrad.optimizers.base.Optimizer 10 | :members: 11 | 12 | 13 | 14 | .. _callbacks: 15 | 16 | Callbacks 17 | --------- 18 | 19 | Callbacks can be registered through the :code:`optimizer.register_callback` for call on either :code:`ask` or :code:`tell` methods. Two of them are available through the 20 | `ng.callbacks` namespace. 21 | 22 | .. automodule:: nevergrad.callbacks 23 | :members: OptimizerDump, ParametersLogger, ProgressBar, EarlyStopping 24 | 25 | Configurable optimizers 26 | ----------------------- 27 | 28 | Configurable optimizers share the following API to create optimizers instances: 29 | 30 | .. autoclass:: nevergrad.optimizers.base.ConfiguredOptimizer 31 | :members: 32 | :special-members: __call__ 33 | 34 | 35 | Here is a list of the available configurable optimizers: 36 | 37 | .. automodule:: nevergrad.families 38 | :members: 39 | 40 | Optimizers 41 | ---------- 42 | 43 | Here are all the other optimizers available in :code:`nevergrad`: 44 | 45 | .. Caution:: 46 | Only non-family-based optimizers are listed in the documentation, 47 | you can get a full list of available optimizers with :code:`sorted(nevergrad.optimizers.registry.keys())` 48 | 49 | .. automodule:: nevergrad.optimization.optimizerlib 50 | :members: 51 | :undoc-members: 52 | -------------------------------------------------------------------------------- /docs/parametrization_ref.rst: -------------------------------------------------------------------------------- 1 | .. _parametrization_ref: 2 | 3 | Parametrization API reference 4 | ============================= 5 | 6 | **Please note that parametrization is still a work in progress and changes are on their way (including for this documentation)! We are trying to update it to make it simpler and simpler to use (all feedbacks are welcome ;) ), with the side effect that there will be breaking changes.** 7 | 8 | The aim of parametrization is to specify what are the parameters that the optimization should be performed upon. 9 | The parametrization subpackage will help you do thanks to: 10 | 11 | - the `parameter` modules (accessed by the shortcut `nevergrad.p`) providing classes that should be used to specify each parameter. 12 | - the `ops` module (accessed through `ng.ops`) providing experimental objects for modifying a parameter behavior (eg: casting to int, adding complex constraints). 13 | - the `FolderFunction` which helps transform any code into a Python function in a few lines. This can be especially helpful to optimize parameters in non-Python 3.6+ code (C++, Octave, etc...) or parameters in scripts. 14 | 15 | 16 | Parameters 17 | ---------- 18 | 19 | Here are the current types of parameters currently provided: 20 | 21 | .. autosummary:: 22 | nevergrad.p.Array 23 | nevergrad.p.Scalar 24 | nevergrad.p.Log 25 | nevergrad.p.Dict 26 | nevergrad.p.Tuple 27 | nevergrad.p.Instrumentation 28 | nevergrad.p.Choice 29 | nevergrad.p.TransitionChoice 30 | 31 | .. automodule:: nevergrad.p 32 | :members: Array, Scalar, Log, Dict, Tuple, Instrumentation, Choice, TransitionChoice 33 | :show-inheritance: 34 | :exclude-members: freeze, recombine, get_value_hash, mutate, satisfies_constraints, args, kwargs, sample 35 | 36 | 37 | Parameter API 38 | ------------- 39 | 40 | .. autoclass:: nevergrad.p.Parameter 41 | :members: 42 | :inherited-members: 43 | 44 | Operators 45 | --------- 46 | These experimental operators are designed to be instantiated and called with a parameter as input, creating a new parameter with the required behavior. 47 | 48 | .. automodule:: nevergrad.ops 49 | :members: Int 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /docs/resources/Nevergrad-LogoMark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/resources/Nevergrad-LogoMark.png -------------------------------------------------------------------------------- /docs/resources/TwoPointsDE.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/resources/TwoPointsDE.gif -------------------------------------------------------------------------------- /docs/resources/compabasedillcond_r400s12_xpresults_nameellipsoid,rotationTrue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/resources/compabasedillcond_r400s12_xpresults_nameellipsoid,rotationTrue.png -------------------------------------------------------------------------------- /docs/resources/dim10_select_one_feature_r400s12_xpresults.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/resources/dim10_select_one_feature_r400s12_xpresults.png -------------------------------------------------------------------------------- /docs/resources/dim10_select_two_features_r400s12_xpresults.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/resources/dim10_select_two_features_r400s12_xpresults.png -------------------------------------------------------------------------------- /docs/resources/dim10_smallbudget_r400s12_xpresults.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/resources/dim10_smallbudget_r400s12_xpresults.png -------------------------------------------------------------------------------- /docs/resources/doe_dim4_r400s12_xpresults.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/resources/doe_dim4_r400s12_xpresults.png -------------------------------------------------------------------------------- /docs/resources/illcond_r50s12_xpresults_namecigar,rotationTrue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/resources/illcond_r50s12_xpresults_namecigar,rotationTrue.png -------------------------------------------------------------------------------- /docs/resources/noise_r400s12_xpresults_namecigar,rotationTrue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/resources/noise_r400s12_xpresults_namecigar,rotationTrue.png -------------------------------------------------------------------------------- /docs/resources/small_discrete_r10s12_xpresults_dimension330,namehardleadingones5,useless_variables300.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/resources/small_discrete_r10s12_xpresults_dimension330,namehardleadingones5,useless_variables300.png -------------------------------------------------------------------------------- /docs/resources/small_discrete_r10s12_xpresults_dimension330,namehardonemax5,useless_variables300.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/resources/small_discrete_r10s12_xpresults_dimension330,namehardonemax5,useless_variables300.png -------------------------------------------------------------------------------- /docs/resources/windows_screenshots/CtrlWindowsAlt.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/resources/windows_screenshots/CtrlWindowsAlt.jpg -------------------------------------------------------------------------------- /docs/resources/windows_screenshots/PR.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/resources/windows_screenshots/PR.PNG -------------------------------------------------------------------------------- /docs/resources/windows_screenshots/anacondanavigator.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/resources/windows_screenshots/anacondanavigator.PNG -------------------------------------------------------------------------------- /docs/resources/windows_screenshots/commit.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/resources/windows_screenshots/commit.PNG -------------------------------------------------------------------------------- /docs/resources/windows_screenshots/create.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/resources/windows_screenshots/create.PNG -------------------------------------------------------------------------------- /docs/resources/windows_screenshots/navigator.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/resources/windows_screenshots/navigator.PNG -------------------------------------------------------------------------------- /docs/resources/windows_screenshots/newBranch.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/resources/windows_screenshots/newBranch.PNG -------------------------------------------------------------------------------- /docs/resources/windows_screenshots/prompt.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/resources/windows_screenshots/prompt.PNG -------------------------------------------------------------------------------- /docs/resources/windows_screenshots/spyder.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/resources/windows_screenshots/spyder.PNG -------------------------------------------------------------------------------- /docs/statistics/AgStatistics.md: -------------------------------------------------------------------------------- 1 | This page records statistics on the benchmarks in Nevergrad. 2 | Contrarily to [[Statistics]], we here exclude wizards and consider only one method per category (Bayesian Optimization, Evolutionary Computation, Direct Search, Particle Swarm, Differential Evolution, Math. Programming...). 3 | 4 | Overall, we get excellent for discrete optimization methods, because they are compatible with any search space, any context, and methods (such as wizards) which adapt to different contexts are excluded. 5 | 6 | In all cases, we count +0.2 for making figures more readable (so this figures are not exactly proportional). 7 | 8 | 9 | # Comparison on all benchmarks, for the simple regret criterion: the wizard performs best 10 | We record the number of times each algorithm performs best, for the simple regret criterion. 11 | 12 | **![Simple regret](./agpie1.png)** 13 | 14 | # Comparing all methods, with a robustness criterion: the wizard still performs best 15 | Same figure, but with Nevergrad's Robust criterion instead of the simple regret: this means that for each benchmark, instead of the simple regret, we consider the frequency at which a method outperforms the others. We still count how many times each method is best. 16 | **![Simple regret](./agpierob1.png)** 17 | 18 | 19 | # Comparing from the point of view of the frequency at which a method is in the three best: methods from discrete optimization perform best 20 | We report the two previous figures, but for the frequency of being in the 3 best instead of the frequency of being the best. Those methods are the most robust and can deal with nearly any context dimension/budget/type/parallelism. 21 | **![Simple regret](./agpie3.png)** 22 | 23 | The superiority of methods from Discrete Optimization (specifically Lengler) is even more visible in the robust setting. 24 | 25 | **![Simple regret](./agpierob3.png)** 26 | -------------------------------------------------------------------------------- /docs/statistics/Statistics.md: -------------------------------------------------------------------------------- 1 | This page records statistics on the benchmarks in Nevergrad. 2 | 3 | In all cases, we count +0.2 for making figures more readable (so these figures are not exactly proportional). 4 | Overall, the result is that the wizard NgIohTuned performs best. 5 | As NgIohTuned is a wizard, and given that it is tuned on the same benchamrks, and also because the present document compares many methods possibly close to each other, we maintain another page [[AgStatistics]] 6 | which uses only one method per category (e.g. Random Search, Bayesian Optimization, Evolutionary Computation, Direct Search, Differential Evolution, Particle Swarm Optimization...) and excludes wizards and excludes methods tuned on Nevergrad benchmarks. 7 | 8 | # Comparison on all benchmarks, for the simple regret criterion: the wizard performs best 9 | We record the number of times each algorithm performs best, for the simple regret criterion. 10 | 11 | **![Simple regret](./pie1.png)** 12 | 13 | # Comparing all methods, with a robustness criterion: the wizard still performs best 14 | Same figure, but with Nevergrad's Robust criterion instead of the simple regret: this means that for each benchmark, instead of the simple regret, we consider the frequency at which a method outperforms the others. We still count how many times each method is best. 15 | **![Simple regret](./pierob1.png)** 16 | 17 | 18 | # Comparing from the point of view of the frequency at which a method is in the three best: the wizard NgIohTuned still performs best 19 | We report the two previous figures, but for the frequency of being in the 3 best instead of the frequency of being the best. 20 | **![Simple regret](./pie3.png)** 21 | 22 | **![Simple regret](./pierob3.png)** 23 | -------------------------------------------------------------------------------- /docs/statistics/agpie1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/statistics/agpie1.png -------------------------------------------------------------------------------- /docs/statistics/agpie3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/statistics/agpie3.png -------------------------------------------------------------------------------- /docs/statistics/agpierob1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/statistics/agpierob1.png -------------------------------------------------------------------------------- /docs/statistics/agpierob3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/statistics/agpierob3.png -------------------------------------------------------------------------------- /docs/statistics/pie1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/statistics/pie1.png -------------------------------------------------------------------------------- /docs/statistics/pie3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/statistics/pie3.png -------------------------------------------------------------------------------- /docs/statistics/pierob1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/statistics/pierob1.png -------------------------------------------------------------------------------- /docs/statistics/pierob3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/docs/statistics/pierob3.png -------------------------------------------------------------------------------- /docs/test_instrum.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | N=10 4 | for i in `seq 0 $(( $N - 1 ))` 5 | do 6 | #python -u instrumentations_examples.py $i 20 7 | sbatch --partition=learnlab --time=72:00:00 --job-name=tt${i}inst$N --gres=gpu:0 --cpus-per-task=50 --wrap="python -u instrumentations_examples.py $i $N" 8 | done 9 | -------------------------------------------------------------------------------- /docs/winners2020.rst: -------------------------------------------------------------------------------- 1 | .. _winners2020: 2 | 3 | Results of the `Open Competition 2020 `_ are in :-) 4 | 5 | Open competition 2020 6 | ===================== 7 | 8 | First rank winners (alphabetic order): 9 | 10 | - Corwinpro 11 | - Foloso 12 | - nojhan 13 | - pacowong 14 | - Teftimov 15 | 16 | Second rank winners (alphabetic order): 17 | 18 | - Alexd314 19 | - fteytaud 20 | - herilalaina 21 | 22 | Winners (above) should contact oteytaud@fb.com and Carola.Doerr@mpi-inf.mpg.de. 23 | 24 | Honorable mention: 25 | 26 | - thomasWeise 27 | - Ljialin 28 | - Dvermetten 29 | - Dietermarwo 30 | - Fmder 31 | -------------------------------------------------------------------------------- /examples/check_metamodel.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import time 4 | sys.path.insert(0, os.path.abspath(".")) 5 | 6 | from joblib import Parallel, delayed 7 | import nevergrad as ng 8 | import numpy as np 9 | 10 | 11 | print(ng.__file__) 12 | 13 | 14 | for kbudget in [1, 5, 10, 25, 40]: 15 | print("kbudget =", kbudget) 16 | for dim in [2]: 17 | print("Experiment in dimension ", dim) 18 | Nk=1 # we might play with greater values later 19 | N = 30 20 | #budget = 10*((N**dim)**2) 21 | budget = int(1*((N**1)**1)*kbudget) 22 | print(dim, N, budget) 23 | 24 | 25 | Y = [] 26 | for k in range(Nk): 27 | y = np.random.rand(N**dim).reshape([N]*dim) 28 | Y += [y] 29 | 30 | def f(x): 31 | def subf(x, y): 32 | v = np.sum(np.abs(x.flatten())) if dim == 2 else 0 33 | v += np.sum(np.abs(x.transpose().flatten())) if dim == 2 else 0 34 | return v + np.sum((y-x)**2) #np.sum(2. + ((x-.5)*(y-.5))) 35 | 36 | return np.min([subf(x,y) for y in Y]) 37 | 38 | num_manips = 80 39 | #for optim in ["LognormalDiscreteOnePlusOne", "RFMetaModelLogNormal", "NeuralMetaModelLogNormal"]: 40 | for optim in ["DiscreteLenglerOnePlusOne", "LognormalDiscreteOnePlusOne", "OnePlusOne", "CMASL", "CLengler", "VoxelizeMetaModelOnePlusOne", "MetaModelOnePlusOne", "ImageMetaModelOnePlusOne", "DiagonalCMA", "PSO", "DE", "CMA"]: 41 | loss = [] 42 | #for k in range(num_manips): 43 | # opt = ng.optimizers.registry[optim](domain, budget).minimize(f).value 44 | # loss += [np.log(f(opt))] 45 | def manip(): 46 | domain = ng.p.Array(shape=[N]*dim, lower=0., upper=1.) 47 | return ng.optimizers.registry[optim](domain, budget).minimize(f).value 48 | t0 = time.time() 49 | loss = Parallel(n_jobs=10)(delayed(manip)() for i in range(num_manips)) 50 | print(optim, "==>", np.average(loss), "+-", np.std(loss)/np.sqrt(num_manips-1), " t=", time.time()-t0, flush=True) 51 | -------------------------------------------------------------------------------- /examples/convert_ceviche_npy.py: -------------------------------------------------------------------------------- 1 | import glob 2 | import numpy as np 3 | import matplotlib.pyplot as plt 4 | import os.path 5 | 6 | def rename(s): 7 | return s.replace("pb0", "pb0bend").replace("pb1","pb1beamsplitter").replace("pb2", "pb2modeconverter") 8 | 9 | num = len(glob.glob("*.npy")) 10 | 11 | 12 | for idx, f in enumerate(glob.glob("*iel*.npy")): 13 | printing = False 14 | if int(np.sqrt(idx)) < int(np.sqrt(idx+1)): 15 | print(idx, " / ", num, " : ", f) 16 | printing = True 17 | if (("0.000" not in f and "pb0" in f) or ("0.00" not in f) or ("pb3" in f and "0.0" not in f)) and "WS" not in f: 18 | if printing: 19 | print(" ... skipping ") 20 | continue 21 | data = np.load(f) 22 | #print('Shape:',data.shape) 23 | if len(data.shape) <3: 24 | continue 25 | assert data.shape[0] < 3, f"{f} leads to an issue!" 26 | assert data.shape[1] == 1 27 | assert len(data.shape) == 4 28 | if data.shape[0]==2: 29 | target_name = rename(f) + "_1st_wavelength.png" 30 | target_name2 = rename(f) + "_2nd_wavelength.png" 31 | if not os.path.isfile(target_name): 32 | field = np.abs(data[0, 0, :, :])**2 33 | plt.imshow(field.T, cmap='viridis') 34 | plt.savefig(target_name) 35 | field = np.abs(data[1, 0, :, :])**2 36 | plt.imshow(field.T, cmap='viridis') 37 | plt.savefig(target_name2) 38 | else: 39 | target_name = rename(f) + ".png" 40 | if not os.path.isfile(target_name): 41 | field = np.abs(data[0, 0, :, :])**2 42 | plt.imshow(field.T, cmap='viridis') 43 | plt.savefig(target_name) 44 | 45 | -------------------------------------------------------------------------------- /examples/datadisc.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import nevergrad as ng 3 | from joblib import Parallel, delayed 4 | from glob import glob 5 | 6 | 7 | def deal_with_method(method): 8 | for idx in range(10000): 9 | if idx > 3: 10 | method = np.random.choice(list(ng.optimizers.registry.keys())) 11 | files = glob("examples/francois_data/*.txt") 12 | this_file = np.random.choice(files) 13 | print("We work on ", this_file) 14 | with open(this_file) as f: 15 | d, n, discrepancy_lower_bound = [float(x) for x in next(f).split()] # read first line 16 | array = [] 17 | for line in f: # read rest of lines 18 | array.append([float(x) for x in line.split()]) 19 | #d = np.random.choice([2, 5, 12, 24, 48, 96]) 20 | #n = np.random.choice([10, 100, 1000]) 21 | d = int(d) 22 | n = int(n) 23 | assert len(array) == n 24 | assert len(array[0]) == d 25 | b = np.random.choice([1000, 10000, 100000, 1000000, 10000000]) 26 | #L = np.random.RandomState(d*37+n*101+b*12).rand(n,d) 27 | L = np.array(array) 28 | 29 | def localdisc(x): 30 | points_in_interior=0 31 | points_in=0 32 | volume = 1 33 | for i in range (0,n): 34 | if all(L[i] < x): 35 | points_in_interior += 1 36 | if all(L[i] <= x): 37 | points_in += 1 38 | for i in range (0,len(x)): 39 | volume=volume*x[i] 40 | disc=max(volume-points_in_interior/n, points_in/n-volume) 41 | return(1. - disc) 42 | 43 | instrum = ng.p.Array(shape=(int(d),), lower=0., upper=1.) 44 | try: 45 | optim = ng.optimizers.registry[method](instrum, int(b*d)) 46 | recom = optim.minimize(localdisc) 47 | val = localdisc(recom.value) 48 | assert len(recom.value) == d 49 | print(f"We get {1-val} for n={n} and d={d} and b/d={b}, file={this_file} and disclowerbound={discrepancy_lower_bound}, our result is {(1-val) / discrepancy_lower_bound}") 50 | print(f"Recom = {recom.value}") 51 | print(f"RESLD_{d}_{n}_{b}_{method} gets {val}") 52 | except Exception as e: 53 | print(f"Failure {e} for {method}") 54 | 55 | 56 | num=70 57 | #list_of_methods = [np.random.choice(list(ng.optimizers.registry.keys()))] * num 58 | list_of_methods = list(np.random.choice(list(ng.optimizers.registry.keys()), num)) 59 | for i in range(4): 60 | list_of_methods[i] = "NGOptF" 61 | for i in range(4, 8): 62 | list_of_methods[i] = "NGOptF2" 63 | for i in range(8, 14): 64 | list_of_methods[i] = "NGOptF3" 65 | for i in range(15, 21): 66 | list_of_methods[i] = "NGOptF5" 67 | list_of_methods[22] = "FSQPCMA" 68 | list_of_methods[23] = "F2SQPCMA" 69 | list_of_methods[24] = "F3SQPCMA" 70 | print(" RESULT", list_of_methods) 71 | results = Parallel(n_jobs=num)(delayed(deal_with_method)(method) for method in list_of_methods) 72 | 73 | 74 | -------------------------------------------------------------------------------- /examples/disc.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import nevergrad as ng 3 | from joblib import Parallel, delayed 4 | 5 | 6 | def deal_with_method(method): 7 | for idx in range(10000): 8 | if idx > 3: 9 | method = np.random.choice(list(ng.optimizers.registry.keys())) 10 | d = np.random.choice([2, 5, 12, 24, 48, 96]) 11 | n = np.random.choice([10, 100, 1000]) 12 | b = np.random.choice([10,100,1000,10000,100000, 1000000]) 13 | L = np.random.RandomState(d*37+n*101+b*12).rand(n,d) 14 | 15 | def localdisc(x): 16 | points_in_interior=0 17 | points_in=0 18 | volume = 1 19 | for i in range (0,n): 20 | if all(L[i] < x): 21 | points_in_interior += 1 22 | if all(L[i] <= x): 23 | points_in += 1 24 | for i in range (0,len(x)): 25 | volume=volume*x[i] 26 | disc=max(volume-points_in_interior/n, points_in/n-volume) 27 | return(1. - disc) 28 | 29 | instrum = ng.p.Array(shape=(int(d),), lower=0., upper=1.) 30 | try: 31 | optim = ng.optimizers.registry[method](instrum, int(b*d)) 32 | recom = optim.minimize(localdisc) 33 | val = localdisc(recom.value) 34 | assert len(recom.value) == d 35 | if val < 1e-9: 36 | print(f"We get {val} for n={n} and d={d} with x={recom.value}") 37 | print(L) 38 | print(f"RESULT_{d}_{n}_{b}_{method} gets {val}") 39 | except Exception as e: 40 | print(f"Failure {e} for {method}") 41 | 42 | 43 | num=70 44 | #list_of_methods = [np.random.choice(list(ng.optimizers.registry.keys()))] * num 45 | list_of_methods = list(np.random.choice(list(ng.optimizers.registry.keys()), num)) 46 | for i in range(4): 47 | list_of_methods[i] = "NGOptF" 48 | for i in range(4, 8): 49 | list_of_methods[i] = "NGOptF2" 50 | for i in range(8, 14): 51 | list_of_methods[i] = "NGOptF3" 52 | list_of_methods[14] = "FSQPCMA" 53 | list_of_methods[15] = "F2SQPCMA" 54 | list_of_methods[16] = "F3SQPCMA" 55 | print(" RESULT", list_of_methods) 56 | results = Parallel(n_jobs=num)(delayed(deal_with_method)(method) for method in list_of_methods) 57 | 58 | 59 | -------------------------------------------------------------------------------- /examples/example_for_plotting_optim_curve.py: -------------------------------------------------------------------------------- 1 | import nevergrad as ng 2 | 3 | def f(x): 4 | return sum((x-1.234)**2) 5 | opt = ng.optimizers.TwoPointsDE(3, 500) 6 | opt.minimize(f) 7 | print(opt.optim_curve) 8 | -------------------------------------------------------------------------------- /mypy.ini: -------------------------------------------------------------------------------- 1 | [mypy] 2 | 3 | #[mypy-scipy.*,requests,smac,smac.*,pandas,compiler_gym,compiler_gym.*,gym,gym.*,gym_anm,matplotlib.*,pytest,cma,bayes_opt.*,torchvision.models,torch.*,mpl_toolkits.*,fcmaes.*,tqdm,pillow,PIL,PIL.Image,sklearn.*,pyomo.*,pyproj,IOHexperimenter.*,tensorflow,koncept.models,cv2,imquality,imquality.brisque,lpips,mixsimulator.*,networkx.*,cdt.*,] 4 | [mypy-scipy.*,requests,pandas,compiler_gym,compiler_gym.*,gym_anm,matplotlib.*,pytest,cma,bayes_opt.*,torchvision.models,torch.*,mpl_toolkits.*,fcmaes.*,tqdm,pillow,PIL,PIL.Image,sklearn.*,pyomo.*,pyproj,IOHexperimenter.*,tensorflow,koncept.models,cv2,imquality,imquality.brisque,lpips,mixsimulator.*,networkx.*,cdt.*,pymoo,pymoo.*,bayes_optim.*,olympus.*,pymoo,pymoo.*,pybullet,pybullet_envs,pybulletgym,pyvirtualdisplay,nlopt,aquacrop.*,gomea,autograd,ceviche-challenges] 5 | ignore_missing_imports = True 6 | 7 | [mypy-nevergrad.functions.rl.*,torchvision,torchvision.*,nevergrad.functions.games.*,nevergrad.functions.multiobjective.pyhv,nevergrad.optimization.test_doc,nevergrad.functions.gym.multigym,nevergrad.functions.gym.tuple_gym_env,nevergrad.common.sphere,nevergrad.examples.*] 8 | ignore_missing_imports = True 9 | ignore_errors = True 10 | 11 | [mypy-torch.*,torch.nn.*,autograd,ceviche-challenges] 12 | follow_imports = skip 13 | follow_imports_for_stubs = True 14 | disallow_subclassing_any = True 15 | -------------------------------------------------------------------------------- /nevergrad/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .common import typing as typing 7 | from .parametrization import parameter as p 8 | from .optimization import optimizerlib as optimizers # busy namespace, likely to be simplified 9 | from .optimization import families as families 10 | from .optimization import callbacks as callbacks 11 | from .common import errors as errors 12 | from . import ops as ops 13 | 14 | 15 | __all__ = ["optimizers", "families", "callbacks", "p", "typing", "errors", "ops"] 16 | 17 | 18 | __version__ = "1.0.12" 19 | -------------------------------------------------------------------------------- /nevergrad/benchmark/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .xpbase import Experiment as Experiment 7 | from .experiments import registry as registry 8 | -------------------------------------------------------------------------------- /nevergrad/benchmark/additional/example.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import nevergrad as ng 7 | from nevergrad import functions as ngfuncs 8 | from nevergrad.benchmark import registry as xpregistry 9 | from nevergrad.benchmark import Experiment 10 | 11 | # this file implements: 12 | # - an additional test function: CustomFunction 13 | # - an additional optimizer: NewOptimizer 14 | # - an addition experiment plan: additional_experiment 15 | # it can be used with the --imports parameters if nevergrad.benchmark commandline function 16 | 17 | 18 | class CustomFunction(ngfuncs.ExperimentFunction): 19 | """Example of a new test function""" 20 | 21 | def __init__(self, offset): 22 | super().__init__(self.oracle_call, ng.p.Scalar().set_name("")) 23 | self.offset = offset 24 | # add your own function descriptors if need be with add_descriptors 25 | # (from base class, we already get "dimension" etc... 26 | # and all str/int/bool/float parameters such as offset here - for all those types, no need to use add_descriptors) 27 | # those will be recorded during benchmarks 28 | 29 | def oracle_call(self, x): # np.ndarray as input 30 | """Implements the call of the function. 31 | Under the hood, __call__ delegates to oracle_call + add some noise if noise_level > 0. 32 | """ 33 | return (x - self.offset) ** 2 34 | 35 | 36 | @ng.optimizers.registry.register # register optimizers in the optimization registry 37 | class NewOptimizer(ng.optimizers.registry["NoisyBandit"]): # type: ignore 38 | pass 39 | 40 | 41 | @xpregistry.register # register experiments in the experiment registry 42 | def additional_experiment(): # The signature can also include a seed argument if need be (see experiments.py) 43 | funcs = [ngfuncs.ArtificialFunction(name="sphere", block_dimension=10), CustomFunction(2)] 44 | for budget in [10, 100]: 45 | for optimizer in ["NewOptimizer", "RandomSearch"]: 46 | for func in funcs: # 2 realizations of the same function 47 | yield Experiment(func, optimizer=optimizer, budget=budget, num_workers=1) 48 | -------------------------------------------------------------------------------- /nevergrad/benchmark/test_utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import itertools 7 | import typing as tp 8 | import numpy as np 9 | from nevergrad.common import testing 10 | from . import utils 11 | 12 | 13 | @testing.parametrized( 14 | void=({}, ["i1", "i2", "i3"]), 15 | value=({"c1": "i2-c1"}, ["i2"]), 16 | function=({"c1": lambda x: x == "i2-c1"}, ["i2"]), 17 | values=({"c1": ["i3-c1", "i2-c1"]}, ["i2", "i3"]), 18 | conditions=({"c1": ["i3-c1", "i2-c1"], "c2": "i3-c2"}, ["i3"]), 19 | ) 20 | def test_selector(criteria: tp.Any, expected: tp.List[str]) -> None: 21 | df = utils.Selector(index=["i1", "i2", "i3"], columns=["c1", "c2"]) 22 | for i, c in itertools.product(df.index, df.columns): 23 | df.loc[i, c] = f"{i}-{c}" 24 | df_select = df.select(**criteria) 25 | df_drop = df.select_and_drop(**criteria) 26 | # indices 27 | testing.assert_set_equal(df_select.index, expected) 28 | testing.assert_set_equal(df_drop.index, expected) 29 | # columns 30 | testing.assert_set_equal(df_select.columns, df) 31 | testing.assert_set_equal(df_drop.columns, set(df_select.columns) - set(criteria)) 32 | # values 33 | for i, c in itertools.product(df_select.index, df_select.columns): 34 | assert df.loc[i, c] == f"{i}-{c}", "Erroneous values" 35 | # instance 36 | assert isinstance(df_select, utils.Selector) 37 | assert isinstance(df_drop, utils.Selector) 38 | 39 | 40 | @testing.parametrized( 41 | multiple=(["c1", "c2"], {(2, 1), (2, 2)}), 42 | unique=(["c1"], {(2,)}), 43 | unique_2=(["c2"], {(1,), (2,)}), 44 | none=([], set()), 45 | ) 46 | def test_selector_unique(columns: tp.List[str], expected: tp.Iterable[tp.Tuple[int, int]]) -> None: 47 | df = utils.Selector(index=["i1", "i2", "i3"], columns=["c1", "c2"], data=[[2, 1], [2, 2], [2, 1]]) 48 | testing.printed_assert_equal(df.unique(columns), expected) 49 | 50 | 51 | def test_selector_assert_equivalent() -> None: 52 | select1 = utils.Selector(columns=["a", "b"], data=[[0, 1], [2, 3]]) 53 | select2 = utils.Selector(columns=["b", "a"], data=[[3, 2], [1, 0]]) 54 | select3 = utils.Selector(columns=["a", "b"], data=[[0, 5], [2, 3]]) 55 | select1.assert_equivalent(select2) 56 | np.testing.assert_raises(AssertionError, select1.assert_equivalent, select3) 57 | -------------------------------------------------------------------------------- /nevergrad/common/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | -------------------------------------------------------------------------------- /nevergrad/common/decorators.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import typing as tp 7 | import functools 8 | 9 | 10 | X = tp.TypeVar("X") 11 | 12 | 13 | # pylint does not understand Dict[str, X], 14 | # so we reimplement the MutableMapping interface 15 | class Registry(tp.MutableMapping[str, X]): 16 | """Registers function or classes as a dict.""" 17 | 18 | def __init__(self) -> None: 19 | super().__init__() 20 | self.data: tp.Dict[str, X] = {} 21 | self._information: tp.Dict[str, tp.Dict[tp.Hashable, tp.Any]] = {} 22 | 23 | def register(self, obj: X, info: tp.Optional[tp.Dict[tp.Hashable, tp.Any]] = None) -> X: 24 | """Decorator method for registering functions/classes 25 | The info variable can be filled up using the register_with_info 26 | decorator instead of this one. 27 | """ 28 | name = getattr(obj, "__name__", obj.__class__.__name__) 29 | self.register_name(name, obj, info) 30 | return obj 31 | 32 | def register_name( 33 | self, name: str, obj: X, info: tp.Optional[tp.Dict[tp.Hashable, tp.Any]] = None 34 | ) -> None: 35 | """Register an object with a provided name""" 36 | if name in self: 37 | raise RuntimeError(f'Encountered a name collision "{name}"') 38 | self[name] = obj 39 | if info is not None: 40 | assert isinstance(info, dict) 41 | self._information[name] = info 42 | 43 | def unregister(self, name: str) -> None: 44 | """Remove a previously-registered function or class, e.g. so you can 45 | re-register it in a Jupyter notebook. 46 | """ 47 | if name in self: 48 | del self[name] 49 | 50 | def register_with_info(self, **info: tp.Any) -> tp.Callable[[X], X]: 51 | """Decorator for registering a function and information about it""" 52 | return functools.partial(self.register, info=info) # type: ignore 53 | 54 | def get_info(self, name: str) -> tp.Dict[tp.Hashable, tp.Any]: 55 | if name not in self: 56 | raise ValueError(f'"{name}" is not registered.') 57 | return self._information.setdefault(name, {}) 58 | 59 | def __getitem__(self, key: str) -> X: 60 | return self.data[key] 61 | 62 | def __setitem__(self, key: str, value: X) -> None: 63 | self.data[key] = value 64 | 65 | def __delitem__(self, key: str) -> None: 66 | del self.data[key] 67 | 68 | def __iter__(self) -> tp.Iterator[str]: 69 | return iter(self.data) 70 | 71 | def __len__(self) -> int: 72 | return len(self.data) 73 | -------------------------------------------------------------------------------- /nevergrad/common/errors.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import unittest 7 | 8 | 9 | # base classes 10 | 11 | 12 | class NevergradError(Exception): 13 | """Base class for error raised by Nevergrad""" 14 | 15 | 16 | class NevergradWarning(Warning): 17 | pass 18 | 19 | 20 | # errors 21 | # pylint: disable=too-many-ancestors 22 | 23 | 24 | class NevergradEarlyStopping(StopIteration, NevergradError): 25 | """Stops the minimization loop if raised""" 26 | 27 | 28 | class NevergradRuntimeError(RuntimeError, NevergradError): 29 | """Runtime error raised by Nevergrad""" 30 | 31 | 32 | class NevergradTypeError(TypeError, NevergradError): 33 | """Runtime error raised by Nevergrad""" 34 | 35 | 36 | class NevergradValueError(ValueError, NevergradError): 37 | """Runtime error raised by Nevergrad""" 38 | 39 | 40 | class NevergradNotImplementedError(NotImplementedError, NevergradError): 41 | """Not implemented functionality""" 42 | 43 | 44 | class TellNotAskedNotSupportedError(NevergradNotImplementedError): 45 | """To be raised by optimizers which do not support the tell_not_asked interface.""" 46 | 47 | 48 | class ExperimentFunctionCopyError(NevergradNotImplementedError): 49 | """Raised when the experiment function fails to copy itself (for benchmarks)""" 50 | 51 | 52 | class UnsupportedExperiment(unittest.SkipTest, NevergradRuntimeError): 53 | """Raised if the experiment is not compatible with the current settings: 54 | Eg: missing data, missing import, unsupported OS etc 55 | This automatically skips tests. 56 | """ 57 | 58 | 59 | class NevergradDeprecationError(NevergradRuntimeError): 60 | """Deprecated function/class""" 61 | 62 | 63 | class UnsupportedParameterOperationError(NevergradRuntimeError): 64 | """This type of operation is not supported by the parameter""" 65 | 66 | 67 | # warnings 68 | 69 | 70 | class NevergradDeprecationWarning(DeprecationWarning, NevergradWarning): 71 | """Deprecated function/class""" 72 | 73 | 74 | class NevergradRuntimeWarning(RuntimeWarning, NevergradWarning): 75 | """Runtime warning raise by nevergrad""" 76 | 77 | 78 | class InefficientSettingsWarning(NevergradRuntimeWarning): 79 | """Optimization settings are not optimal for the optimizer""" 80 | 81 | 82 | class BadLossWarning(NevergradRuntimeWarning): 83 | """Provided loss is unhelpful""" 84 | 85 | 86 | class LossTooLargeWarning(BadLossWarning): 87 | """Sent when Loss is clipped because it is too large""" 88 | 89 | 90 | class NevergradBehaviorChangesWarning(NevergradRuntimeWarning): 91 | """Notifies a change of behavior""" 92 | 93 | 94 | class FinishedUnderlyingOptimizerWarning(NevergradRuntimeWarning): 95 | """Underlying scipy optimizer finished""" 96 | 97 | 98 | class FailedConstraintWarning(NevergradRuntimeWarning): 99 | """Constraint could not be applied""" 100 | -------------------------------------------------------------------------------- /nevergrad/common/test_decorators.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import typing as tp 7 | from unittest import TestCase 8 | import numpy as np 9 | from . import decorators 10 | 11 | 12 | class DecoratorTests(TestCase): 13 | def test_registry(self) -> None: 14 | functions: decorators.Registry[tp.Callable[[], int]] = decorators.Registry() 15 | other: decorators.Registry[tp.Callable[[], int]] = decorators.Registry() 16 | 17 | @functions.register 18 | def dummy() -> int: 19 | return 12 20 | 21 | np.testing.assert_equal(dummy(), 12) 22 | np.testing.assert_array_equal(list(functions.keys()), ["dummy"]) 23 | np.testing.assert_array_equal(list(other.keys()), []) 24 | functions.unregister("dummy") 25 | functions.unregister("other_dummy_that_does_not_exist") 26 | np.testing.assert_array_equal(list(functions.keys()), []) 27 | 28 | def test_info_registry(self) -> None: 29 | functions: decorators.Registry[tp.Callable[[], int]] = decorators.Registry() 30 | 31 | @functions.register_with_info(tag="info") 32 | def dummy_info() -> int: 33 | return 10 34 | 35 | np.testing.assert_equal(dummy_info(), 10) 36 | np.testing.assert_equal(functions.get_info("dummy_info"), {"tag": "info"}) 37 | np.testing.assert_raises(ValueError, functions.get_info, "no_dummy") 38 | 39 | def test_registry_error(self) -> None: 40 | functions: decorators.Registry[tp.Any] = decorators.Registry() 41 | 42 | @functions.register 43 | def dummy() -> int: 44 | return 12 45 | 46 | np.testing.assert_raises(RuntimeError, functions.register, dummy) 47 | -------------------------------------------------------------------------------- /nevergrad/common/test_tools.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import os 7 | import typing as tp 8 | import numpy as np 9 | from . import tools 10 | from . import testing 11 | 12 | 13 | @testing.parametrized( 14 | void=([], []), 15 | one=(["a"], []), 16 | two=([1, 2], [(1, 2)]), 17 | three=([1, 2, 3], [(1, 2), (2, 3)]), 18 | ) 19 | def test_pairwise(iterator: tp.Iterable[tp.Any], expected: tp.List[tp.Tuple[tp.Any, ...]]) -> None: 20 | output = list(tools.pairwise(iterator)) 21 | testing.printed_assert_equal(output, expected) 22 | 23 | 24 | def test_roundrobin() -> None: 25 | output = list(tools.roundrobin([1, 2, 3], (x for x in [4, 5, 6, 7]), (8,))) 26 | np.testing.assert_array_equal(output, [1, 4, 8, 2, 5, 3, 6, 7]) 27 | 28 | 29 | def test_grouper() -> None: 30 | output = list(tools.grouper("ABCDEFG", 3, "x")) 31 | testing.printed_assert_equal(output, [list(x) for x in ["ABC", "DEF", "Gxx"]]) 32 | 33 | 34 | def test_sleeper() -> None: 35 | min_sleep = 1e-5 36 | sleeper = tools.Sleeper(min_sleep=min_sleep) 37 | np.testing.assert_almost_equal(sleeper._get_advised_sleep_duration(), min_sleep, decimal=5) 38 | sleeper.start_timer() 39 | # not precise enough to test for exact time 40 | # np.testing.assert_almost_equal(sleeper._get_advised_sleep_duration(), min_sleep, decimal=5) 41 | sleeper.stop_timer() 42 | # np.testing.assert_almost_equal(sleeper._get_advised_sleep_duration(), min_sleep, decimal=5) 43 | 44 | 45 | def test_mutable_set() -> None: 46 | s: tools.OrderedSet[int] = tools.OrderedSet((1, 2, 3)) 47 | assert tuple(s) == (1, 2, 3) 48 | s.add(1) 49 | s.add(4) 50 | assert tuple(s) == (2, 3, 1, 4) 51 | # 52 | union = s & {3, 2} 53 | assert isinstance(union, tools.OrderedSet) 54 | assert tuple(union) == (2, 3) 55 | # 56 | assert s.pop() == 2 57 | assert s.popright() == 4 58 | assert tuple(s) == (3, 1) 59 | # 60 | s = tools.OrderedSet((1, 2, 3)) 61 | intersect = s | {5, 6} 62 | assert isinstance(intersect, tools.OrderedSet) 63 | assert tuple(intersect) == (1, 2, 3, 5, 6) 64 | intersect = {5, 6} | s 65 | assert isinstance(intersect, tools.OrderedSet) 66 | assert tuple(intersect) == (1, 2, 3, 5, 6) # same behavior, always appended to the end 67 | 68 | 69 | def test_set_env() -> None: 70 | with tools.set_env(BLUBLU=1): 71 | assert os.environ.get("BLUBLU", None) == "1" 72 | assert os.environ.get("BLUBLU", None) is None 73 | 74 | 75 | def test_flatten() -> None: 76 | out = tools.flatten(["a", {"truc": [4, 5]}]) 77 | assert out == {"0": "a", "1.truc.0": 4, "1.truc.1": 5} 78 | 79 | 80 | def test_hyperballs() -> None: 81 | tools.quasi_randomize(np.random.randn(8, 10, 10, 2)) 82 | -------------------------------------------------------------------------------- /nevergrad/common/typing.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | """Definitions of some convenient types. 7 | If you know better practices, feel free to submit it ;) 8 | """ 9 | # pylint: disable=unused-import 10 | # structures 11 | from typing import Any as Any 12 | from typing import Generic as Generic 13 | from typing import Type as Type 14 | from typing import TypeVar as TypeVar 15 | from typing import Optional as Optional 16 | from typing import Union as Union 17 | 18 | # containers 19 | from typing import Dict as Dict 20 | from typing import Tuple as Tuple 21 | from typing import List as List 22 | from typing import Set as Set 23 | from typing import Deque as Deque 24 | from typing import Sequence as Sequence 25 | from typing import NamedTuple as NamedTuple 26 | from typing import MutableMapping as MutableMapping 27 | 28 | # iterables 29 | from typing import Iterator as Iterator 30 | from typing import Iterable as Iterable 31 | from typing import Generator as Generator 32 | from typing import KeysView as KeysView 33 | from typing import ValuesView as ValuesView 34 | from typing import ItemsView as ItemsView 35 | 36 | # others 37 | from typing import Callable as Callable 38 | from typing import Hashable as Hashable 39 | from typing import Match as Match 40 | from typing import cast as cast 41 | from pathlib import Path as Path 42 | 43 | try: 44 | from typing import Protocol 45 | except: 46 | from typing_extensions import Protocol # type: ignore 47 | 48 | # 49 | import numpy as _np 50 | 51 | 52 | ArgsKwargs = Tuple[Tuple[Any, ...], Dict[str, Any]] 53 | ArrayLike = Union[Tuple[float, ...], List[float], _np.ndarray] # most common 54 | PathLike = Union[str, Path] 55 | FloatLoss = float 56 | Loss = Union[float, ArrayLike] 57 | BoundValue = Optional[Union[float, int, _np.int_, _np.float64, ArrayLike]] 58 | 59 | 60 | # %% Protocol definitions for executor typing 61 | 62 | X = TypeVar("X", covariant=True) 63 | 64 | 65 | class JobLike(Protocol[X]): 66 | # pylint: disable=pointless-statement 67 | 68 | def done(self) -> bool: ... 69 | 70 | def result(self) -> X: ... 71 | 72 | 73 | class ExecutorLike(Protocol): 74 | # pylint: disable=pointless-statement, unused-argument 75 | 76 | def submit(self, fn: Callable[..., X], *args: Any, **kwargs: Any) -> JobLike[X]: ... 77 | -------------------------------------------------------------------------------- /nevergrad/examples/powersystem.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | # 6 | # run this with: 7 | # echo 'import nevergrad.examples.powersystem' | python 8 | # or (e.g. MacOS): 9 | # echo 'import nevergrad.examples.powersystem' | pythonw 10 | 11 | import nevergrad as ng 12 | from nevergrad.functions.powersystems.core import PowerSystem 13 | 14 | budget = 3500 15 | width = 6 16 | depth = 6 17 | num_dams = 6 18 | year_to_day_ratio = 0.5 19 | back_to_normal = 0.5 20 | num_thermal_plants = 6 21 | constant_to_year_ratio = 4.0 22 | # Default values for various options: 23 | # year_to_day_ratio: float = 2., # Ratio between std of consumption in the year and std of consumption in the day. 24 | # constant_to_year_ratio: float = 1., # Ratio between constant baseline consumption and std of consumption in the year. 25 | # back_to_normal: float = 0.5, # Part of the variability which is forgotten at each time step. 26 | # consumption_noise: float = 0.1, # Instantaneous variability. 27 | # num_thermal_plants: int = 7, # Number of thermal plants. 28 | # num_years: int = 1, # Number of years. 29 | # failure_cost: float = 500., # Cost of not satisfying the demand. Equivalent to an expensive infinite capacity thermal plant. 30 | 31 | power_system_loss = PowerSystem( 32 | num_dams=num_dams, 33 | depth=depth, 34 | width=width, 35 | year_to_day_ratio=year_to_day_ratio, 36 | back_to_normal=back_to_normal, 37 | num_thermal_plants=num_thermal_plants, 38 | constant_to_year_ratio=constant_to_year_ratio, 39 | ) 40 | optimizer = ng.optimizers.SplitOptimizer( 41 | parametrization=power_system_loss.dimension, budget=budget, num_workers=10 42 | ) 43 | optimizer.minimize(power_system_loss) 44 | power_system_loss(optimizer.provide_recommendation().value) 45 | power_system_loss.make_plots( 46 | f"ps_{num_dams}dams_{depth}_{width}_ytdr{year_to_day_ratio}_btn{back_to_normal}" 47 | f"_num_thermal_plants{num_thermal_plants}_ctyr{constant_to_year_ratio}_budget{budget}.png" 48 | ) 49 | -------------------------------------------------------------------------------- /nevergrad/functions/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .functionlib import ArtificialFunction as ArtificialFunction 7 | from .functionlib import FarOptimumFunction as FarOptimumFunction 8 | from .multiobjective import MultiobjectiveFunction as MultiobjectiveFunction 9 | from .base import ExperimentFunction as ExperimentFunction 10 | 11 | # BEWARE: do not add imports here that rely on non-standard packages 12 | # this is to make the subpackage importable even without installing all 13 | # benchmark requirements 14 | -------------------------------------------------------------------------------- /nevergrad/functions/ac/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .ac import NgAquacrop as NgAquacrop 7 | -------------------------------------------------------------------------------- /nevergrad/functions/ac/test_ac.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import numpy as np 7 | from . import ac 8 | 9 | 10 | def test_ac() -> None: 11 | func = ac.NgAquacrop(4, 12.0) 12 | x = 50.0 * np.random.rand(func.dimension) 13 | value = func(x) 14 | value2 = func(x) 15 | x = 50.0 * np.random.rand(func.dimension) 16 | value3 = func(x) 17 | np.testing.assert_almost_equal(value, value2) 18 | assert value != value3 19 | -------------------------------------------------------------------------------- /nevergrad/functions/arcoating/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .core import ARCoating as ARCoating 7 | -------------------------------------------------------------------------------- /nevergrad/functions/arcoating/test_core.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import typing as tp 7 | import numpy as np 8 | import nevergrad as ng 9 | from . import core 10 | 11 | 12 | def test_impedence_pix() -> None: 13 | ep0 = 1 14 | epf = 9 15 | x = np.array([3.0, 5.0, 1.0, 9.0]) 16 | dpix = 37 17 | lam = 400 18 | output = core.impedance_pix(x, dpix, lam, ep0, epf) 19 | np.testing.assert_almost_equal(output, 46.64, decimal=2) 20 | 21 | 22 | def test_arcoating_reflexion_function() -> None: 23 | func = core.ARCoating(nbslab=4) 24 | output = func._get_minimum_average_reflexion(np.array([4.56386701, 5.65210553, 6.24006888, 7.18400555])) 25 | # np.testing.assert_almost_equal(output, 13.320815699203614) # Before change 26 | np.testing.assert_almost_equal(output, 12.702, decimal=3) 27 | 28 | 29 | def test_arcoating_recombination() -> None: 30 | func = core.ARCoating(nbslab=6) 31 | func.parametrization.random_state.seed(24) 32 | arrays: tp.List[ng.p.Array] = [] 33 | for num in [3, 5]: 34 | arrays.append(func.parametrization.spawn_child()) # type: ignore 35 | arrays[-1].value = num * np.ones(arrays[0].value.shape) 36 | arrays[0].recombine(arrays[1]) 37 | expected = [3.0, 3.0, 3.0, 5.0, 3.0, 3.0] 38 | np.testing.assert_array_equal(arrays[0].value, expected) 39 | 40 | 41 | def test_arcoating_transform_and_call() -> None: 42 | nbslab = 8 43 | func = core.ARCoating(nbslab=nbslab) 44 | x = 7 * np.random.normal(size=nbslab) # make sure it touches space boundaries 45 | data = func.parametrization.spawn_child().set_standardized_data(x).args[0] 46 | value = func(data) # should not touch boundaries, so value should be < np.inf 47 | assert isinstance(value, float) 48 | assert value < np.inf 49 | param = func.parametrization.spawn_child().set_standardized_data(np.arange(8)) 50 | np.testing.assert_almost_equal(func(param.value), 16.5538936) 51 | np.testing.assert_almost_equal(func.evaluation_function(param), 16.5538936) 52 | -------------------------------------------------------------------------------- /nevergrad/functions/control/ARS_LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2018, ARS contributors (Horia Mania, Aurelia Guy, Benjamin Recht) 3 | All rights reserved. 4 | 5 | Redistribution and use of ARS in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation and/or 13 | other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 19 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 22 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /nevergrad/functions/control/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .core import Ant as Ant 7 | from .core import Swimmer as Swimmer 8 | from .core import HalfCheetah as HalfCheetah 9 | from .core import Hopper as Hopper 10 | from .core import Walker2d as Walker2d 11 | from .core import Humanoid as Humanoid 12 | -------------------------------------------------------------------------------- /nevergrad/functions/control/mujoco.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import gym 7 | import numpy as np 8 | 9 | 10 | class GenericMujocoEnv: 11 | """This class evaluates policy of OpenAI Gym environment. 12 | 13 | Parameters 14 | ----------- 15 | env_name: str 16 | Gym environment name 17 | state_mean: list 18 | Average state values of multiple independent runs. 19 | state_std: list 20 | Standard deviation of state values of multiple independent runs. 21 | num_rollouts: int 22 | number of independent runs. 23 | activation: str: 24 | activation function 25 | layer_rescaling_coef: float 26 | Scaling coefficient of output layers 27 | random_state: int or None 28 | random state for reproducibility in Gym environment. 29 | """ 30 | 31 | def __init__( 32 | self, 33 | env_name, 34 | state_mean, 35 | state_std, 36 | num_rollouts, 37 | activation, 38 | layer_rescaling_coef, 39 | noise_level, 40 | random_state, 41 | ): 42 | self.mean = state_mean 43 | self.std = state_std 44 | self.env = gym.make(env_name) 45 | self.num_rollouts = num_rollouts 46 | self.random_state = random_state 47 | self.activation = activation 48 | self.layer_rescaling_coef = layer_rescaling_coef 49 | self.noise_level = noise_level 50 | 51 | def _activation(self, x): 52 | if self.activation == "tanh": 53 | return np.tanh(x) 54 | elif self.activation == "sigmoid": 55 | return 1.0 / (1 + np.exp(-x)) 56 | else: 57 | raise NotImplementedError(r"Activation {self.activation} not implemented.") 58 | 59 | def __call__(self, layers): 60 | """Compute loss (average cumulative negative reward) of a given policy.""" 61 | returns = [] 62 | for _ in range(self.num_rollouts): 63 | obs = self.env.reset() 64 | done = False 65 | totalr = 0.0 66 | while not done: 67 | action = ( 68 | np.matmul(obs, layers[0]) 69 | if (self.mean is None) 70 | else (np.matmul((obs - self.mean) / self.std, layers[0])) 71 | ) 72 | action = action * self.layer_rescaling_coef[0] 73 | for x, r_coef in zip(layers[1:], self.layer_rescaling_coef[1:]): 74 | action = np.matmul(self._activation(action) + 1.0e-3, x) * r_coef 75 | if self.noise_level > 0.0: 76 | action += action * self.noise_level * self.random_state.normal(size=action.shape) 77 | obs, r, done, _ = self.env.step(action) 78 | totalr += r 79 | returns.append(totalr) 80 | 81 | return -np.mean(returns) 82 | -------------------------------------------------------------------------------- /nevergrad/functions/control/test_mujoco.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import pytest 7 | import numpy as np 8 | from .core import BaseFunction 9 | 10 | 11 | class MountainCarContinuous(BaseFunction): 12 | env_name = "MountainCarContinuous-v0" 13 | policy_dim = (2, 1) 14 | state_mean = [0, 0] 15 | state_std = [1, 1] 16 | 17 | 18 | @pytest.mark.parametrize("intermediate_layer_dim", [None, (4,), (3, 3)]) 19 | @pytest.mark.parametrize("noise_level", [0.0, 0.9]) 20 | @pytest.mark.parametrize("deterministic_sim", [0.0, 0.9]) 21 | @pytest.mark.parametrize("states_normalization", [True, False]) 22 | def test_gym(intermediate_layer_dim, noise_level, deterministic_sim, states_normalization) -> None: 23 | func = MountainCarContinuous( 24 | num_rollouts=2, 25 | intermediate_layer_dim=intermediate_layer_dim, 26 | noise_level=noise_level, 27 | deterministic_sim=deterministic_sim, 28 | states_normalization=states_normalization, 29 | random_state=42, 30 | ) 31 | 32 | x = func.parametrization.value 33 | value = func(x) 34 | np.testing.assert_almost_equal(value, 0.0) 35 | x = func.parametrization.sample().value 36 | assert func(x) != 0 37 | if noise_level == 0.0 and deterministic_sim: 38 | assert func(x) == func(x) 39 | else: 40 | assert func(x) != func(x) 41 | 42 | 43 | @pytest.mark.parametrize("module", ["Ant", "Swimmer", "HalfCheetah", "Hopper", "Walker2d", "Humanoid"]) 44 | @pytest.mark.parametrize("intermediate_layer_dim", [None, (50,)]) 45 | @pytest.mark.parametrize("noise_level", [0.0, 0.9]) 46 | @pytest.mark.parametrize("deterministic_sim", [0.0, 0.9]) 47 | @pytest.mark.parametrize("states_normalization", [True, False]) 48 | def test_all_mujoco_envs( 49 | module, intermediate_layer_dim, noise_level, deterministic_sim, states_normalization 50 | ) -> None: 51 | pytest.importorskip("mujoco_py") 52 | core = pytest.importorskip("nevergrad.functions.control.core") 53 | func = getattr(core, module)( 54 | num_rollouts=1, 55 | intermediate_layer_dim=intermediate_layer_dim, 56 | noise_level=noise_level, 57 | deterministic_sim=deterministic_sim, 58 | states_normalization=states_normalization, 59 | random_state=42, 60 | ) 61 | for _ in range(3): 62 | assert isinstance(func(func.parametrization.sample().value), float) 63 | -------------------------------------------------------------------------------- /nevergrad/functions/cycling/Extending Nevergrad, an Optimisation Platform.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/nevergrad/functions/cycling/Extending Nevergrad, an Optimisation Platform.pdf -------------------------------------------------------------------------------- /nevergrad/functions/cycling/Extending Nevergrad, an Optimisation Platform.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/nevergrad/functions/cycling/Extending Nevergrad, an Optimisation Platform.xlsx -------------------------------------------------------------------------------- /nevergrad/functions/cycling/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .cycling import Cycling as Cycling 7 | -------------------------------------------------------------------------------- /nevergrad/functions/cycling/simulationresult.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import math 7 | 8 | 9 | class simulationresult: 10 | def __init__(self, finish_time, proportion_completed, energy_remaining, velocity_profile): 11 | self.finish_time = finish_time 12 | self.energy_remaining = energy_remaining 13 | self.proportion_completed = proportion_completed 14 | self.velocity_profile = velocity_profile 15 | self.results = [] 16 | 17 | def get_finish_time(self): 18 | return self.finish_time 19 | 20 | def get_proportion_completed(self): 21 | return self.proportion_completed 22 | 23 | def get_energy_remaining(self): 24 | return self.energy_remaining 25 | 26 | def get_velocity_profile(self): 27 | return self.velocity_profile 28 | 29 | def to_string(self): 30 | output = "Simulation Result\n-----------------\n" 31 | if self.finish_time < math.inf: 32 | output = f"{output} Finish Time: {self.finish_time} seconds\n" 33 | for i in range(0, len(self.energy_remaining)): 34 | output = f"{output} Cyclist {i+1} Energy Remaining: {self.energy_remaining[i]} joules\n" 35 | else: 36 | output = f"{output} Riders had insufficient energy for race completion\nProportion of race completed: {self.proportion_completed * 100}%\n" 37 | return output 38 | -------------------------------------------------------------------------------- /nevergrad/functions/cycling/test_cycling.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import numpy as np 7 | from . import cycling 8 | 9 | 10 | def test_cycling() -> None: 11 | func = cycling.Cycling(30) 12 | x = 0 * np.random.rand(func.dimension) 13 | assert func(x) 14 | np.testing.assert_almost_equal(func(x), 282.8, decimal=1) 15 | for index in [31, 22, 23, 45, 61]: 16 | func2 = cycling.Cycling(index) 17 | strategy = func2.parametrization.sample().value 18 | func2(strategy) 19 | -------------------------------------------------------------------------------- /nevergrad/functions/fishing/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .core import OptimizeFish as OptimizeFish 7 | -------------------------------------------------------------------------------- /nevergrad/functions/fishing/core.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | # Based on https://github.com/Foloso/MixSimulator/tree/nevergrad_experiment 7 | 8 | import numpy as np 9 | from nevergrad.parametrization import parameter as p 10 | from .. import base 11 | 12 | 13 | class OptimizeFish(base.ExperimentFunction): 14 | """ 15 | Fishing simulator. 16 | 17 | Parameters 18 | ---------- 19 | time: int 20 | number of days of the planning 21 | 22 | """ 23 | 24 | def __init__(self, time: int = 365) -> None: 25 | init = 0.5 * np.ones(time) 26 | parameter = p.Array(init=init) 27 | parameter.set_bounds(0.0 * init, 2.0 * init) 28 | parameter.set_name("raw_encoding") 29 | super().__init__(_compute_total_fishing, parameter) 30 | 31 | 32 | def _compute_total_fishing(list_number_fishermen: np.ndarray) -> float: 33 | """Lotka-Volterra equations. 34 | 35 | This computes the total fishing, given the fishing effort every day. 36 | The problem makes sense for abritrary number of days, so that this works for 37 | any length of the input. 365 means one year.""" 38 | number_dogfishes = 0.2 39 | number_haddocks = 0.8 40 | total_fishing = 0.0 41 | 42 | for number_fishermen in list(list_number_fishermen): 43 | number_fishermen = max(0, number_fishermen) 44 | # Number of haddocks eaten_haddocks today. 45 | number_eaten_haddocks = number_dogfishes * number_haddocks * 4 / 30 46 | # Haddock growth. 47 | number_haddocks += number_haddocks * 2 / 30 48 | number_haddocks -= number_eaten_haddocks 49 | # Natural growth of dogfishes. 50 | number_dogfishes -= (1 / 30) * number_dogfishes 51 | number_dogfishes += (5 / 2) * number_eaten_haddocks 52 | # Number of captured dogfishes. 53 | capture = min((1 / 10) * number_fishermen, number_dogfishes) 54 | number_dogfishes -= capture 55 | assert number_dogfishes >= 0.0 56 | total_fishing += capture 57 | number_dogfishes = min(1.0, number_dogfishes) 58 | number_haddocks = min(1.0, number_haddocks) 59 | return -total_fishing 60 | -------------------------------------------------------------------------------- /nevergrad/functions/fishing/test_core.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import numpy as np 7 | from . import core 8 | 9 | 10 | def test_fishing() -> None: 11 | np.random.seed(17) 12 | func = core.OptimizeFish() 13 | x = np.random.rand(func.dimension) 14 | value = func(x) # should not touch boundaries, so value should be < np.inf 15 | np.testing.assert_almost_equal(value, -0.985, decimal=2) 16 | -------------------------------------------------------------------------------- /nevergrad/functions/games/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from . import game 7 | -------------------------------------------------------------------------------- /nevergrad/functions/games/test_game.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import typing as tp 7 | import numpy as np 8 | from nevergrad.common import testing 9 | from . import game 10 | 11 | 12 | @testing.parametrized(**{name: (name,) for name in game._Game().get_list_of_games()}) 13 | def test_games(name: str) -> None: 14 | dimension = game._Game().play_game(name) 15 | res: tp.List[tp.Any] = [] 16 | for k in range(200): 17 | res.append(game._Game().play_game(name, np.random.uniform(0, 1, dimension), None)) 18 | score = float(sum(1 if r == 2 else 0 if r == 1 else 0.5 for r in res)) / len(res) 19 | if k >= 20 and 0.2 <= score <= 0.8: 20 | break 21 | assert score >= 0.1 22 | assert score <= 0.9 23 | assert any(res), "All ties" 24 | function = game.Game(name) 25 | function(function.parametrization.random_state.normal(size=function.dimension)) 26 | -------------------------------------------------------------------------------- /nevergrad/functions/gym/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .multigym import GymMulti as GymMulti 7 | from .tuple_gym_env import TupleActionSpace 8 | -------------------------------------------------------------------------------- /nevergrad/functions/gym/tuple_gym_env.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import gym 7 | import numpy as np 8 | from gym.spaces import Box, Tuple, MultiDiscrete 9 | 10 | 11 | class TupleActionSpace(gym.Env): 12 | """ 13 | Environment with tuple of discrete spaces at each time step. 14 | """ 15 | 16 | def __init__(self): 17 | 18 | super().__init__() 19 | self.current_step = 0 20 | self.num_cells = 71 21 | self.action_space = Tuple((MultiDiscrete(self.num_cells * [2]), MultiDiscrete(self.num_cells * [6]))) 22 | self.horizon = 168 23 | self._reward = 0.0 24 | 25 | self.observation_space = Box( 26 | low=np.array([0, 0, 0]), 27 | high=np.array([1, 1, 1]), 28 | dtype=np.float16, 29 | ) 30 | 31 | def _next_observation(self): 32 | 33 | return np.asarray((0.5, 0.5, 0.5), dtype="float16") 34 | 35 | def reward( 36 | self, 37 | ) -> float: 38 | return float(self._reward) 39 | 40 | def _take_action(self, action): 41 | assert len(action) == 2 42 | assert len(action[0]) == self.num_cells 43 | for u in action[1]: 44 | assert int(u) == u 45 | self._reward = np.sum(action[1]) - np.sum(action[0]) 46 | return self._reward 47 | 48 | def reset(self): 49 | return self._next_observation() 50 | 51 | def step(self, action): 52 | # Execute one time step within the environment 53 | self._take_action(action) 54 | obs = self._next_observation() 55 | self.current_step += 1 56 | return obs, self.reward(), self.current_step == self.horizon, {} 57 | -------------------------------------------------------------------------------- /nevergrad/functions/images/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .core import Image as Image 7 | from .core import ImageAdversarial as ImageAdversarial 8 | -------------------------------------------------------------------------------- /nevergrad/functions/images/headrgb_olivier.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/nevergrad/functions/images/headrgb_olivier.png -------------------------------------------------------------------------------- /nevergrad/functions/images/test_core.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import numpy as np 7 | 8 | from . import core 9 | 10 | 11 | def test_images_adversarial() -> None: 12 | func = next(core.ImageAdversarial.make_folder_functions(None, model="test")) 13 | x = np.zeros(func.image.shape) 14 | value = func(x) 15 | assert isinstance(value, float) 16 | assert value < np.inf 17 | other_func = func.copy().copy() 18 | value2 = other_func(x) 19 | assert value2 == value # same function 20 | 21 | 22 | def test_image_adversarial_eval() -> None: 23 | func = next(core.ImageAdversarial.make_folder_functions(None, model="test")) 24 | output = func.evaluation_function(func.parametrization) 25 | assert output == 1 26 | func.targeted = True 27 | output = func.evaluation_function(func.parametrization) 28 | assert output == 0 29 | 30 | 31 | def test_images() -> None: 32 | func = core.Image() 33 | x = 7 * np.fabs(np.random.normal(size=func.domain_shape)) 34 | # data = func.parametrization.spawn_child().set_standardized_data(x.flatten()).value 35 | value = func(x) # should not touch boundaries, so value should be < np.inf 36 | assert isinstance(value, float) 37 | assert value < np.inf 38 | other_func = func.copy() 39 | value2 = other_func(x) 40 | assert value == value2 41 | -------------------------------------------------------------------------------- /nevergrad/functions/images/test_imagelosses.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from pathlib import Path 7 | import PIL.Image 8 | import numpy as np 9 | import pytest 10 | from nevergrad.functions.images import imagelosses 11 | 12 | 13 | def test_reference() -> None: 14 | assert imagelosses.SumAbsoluteDifferences.REQUIRES_REFERENCE 15 | assert not imagelosses.Blur.REQUIRES_REFERENCE 16 | assert not imagelosses.Koncept512.REQUIRES_REFERENCE 17 | assert not imagelosses.Brisque.REQUIRES_REFERENCE 18 | assert len([loss for loss in imagelosses.registry.values() if loss.REQUIRES_REFERENCE]) == 5 19 | assert len([loss for loss in imagelosses.registry.values() if not loss.REQUIRES_REFERENCE]) == 2 20 | 21 | 22 | def test_l1_loss() -> None: 23 | loss = imagelosses.SumAbsoluteDifferences(reference=124.0 * np.ones((300, 400, 3))) 24 | assert loss(np.ones((300, 400, 3))) == 44280000.0 25 | 26 | 27 | @pytest.mark.parametrize("loss_name", imagelosses.registry) # type: ignore 28 | def test_consistency_losses_with_oteytaud(loss_name: str) -> None: 29 | path = Path(__file__).with_name("headrgb_olivier.png") 30 | image = PIL.Image.open(path).resize((256, 256)) # , PIL.Image.BICUBIC) 31 | data = np.asarray(image)[:, :, :3] # 4th Channel is pointless here, only 255. 32 | 33 | data_flip = np.flip(data, 0).copy() # Copy necessary as some nets do not support negative stride. 34 | loss_class = imagelosses.registry[loss_name] 35 | loss = loss_class(reference=data) 36 | random_data = np.random.uniform(low=0.0, high=255.0, size=data.shape) 37 | loss_data = loss(data) 38 | assert loss_data < 1000.0 39 | assert loss_data > -1000.0 40 | assert loss_data == loss(data) 41 | assert isinstance(loss_data, float) 42 | loss_random_data = loss(random_data) 43 | assert loss_random_data == loss(random_data) 44 | assert "Blur" in loss_name or loss_data < loss_random_data, f"Loss {loss_name} fails on oteytaud's photo." 45 | if loss.REQUIRES_REFERENCE: 46 | assert loss_data == 0.0 47 | if "Histogram" not in loss_name: 48 | assert loss_data < loss(data_flip) 49 | else: 50 | assert loss_data == loss(data_flip) 51 | -------------------------------------------------------------------------------- /nevergrad/functions/iohprofiler/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .core import PBOFunction as PBOFunction 7 | from .core import WModelFunction as WModelFunction 8 | -------------------------------------------------------------------------------- /nevergrad/functions/iohprofiler/test_core.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from unittest import SkipTest 7 | import pytest 8 | import numpy as np 9 | from nevergrad.optimization.optimizerlib import OnePlusOne 10 | from . import core 11 | 12 | 13 | @pytest.mark.parametrize("fid", range(1, 24)) # type: ignore 14 | @pytest.mark.parametrize("iid", range(1, 6)) # type: ignore 15 | def test_PBO(fid: int, iid: int) -> None: 16 | values = [] 17 | try: 18 | func = core.PBOFunction(fid, iid, 16) 19 | except ModuleNotFoundError as e: 20 | raise SkipTest("IOH is not installed") from e 21 | for _ in range(30): 22 | x = func.parametrization.sample() 23 | assert not set(x.value) - {0, 1}, f"Non binary sample {x}." 24 | value = func(x.value) 25 | assert isinstance(value, float), "All output of the iohprofiler-functions should be float" 26 | assert np.isfinite(value) 27 | values.append(value) 28 | optim = OnePlusOne(func.parametrization, budget=100) 29 | recom = optim.minimize(func) 30 | values.append(func(recom.value)) # type: ignore 31 | assert ( 32 | fid in [19, 20, 21, 22, 23] or min(values) >= 0.0 or max(values) <= 0.0 33 | ), f"IOH profile functions should have constant sign: pb with fid={fid},iid={iid}." 34 | 35 | 36 | @pytest.mark.parametrize("instrumentation", ["Softmax", "Ordered"]) # type: ignore 37 | def test_PBO_parameterization(instrumentation: str) -> None: 38 | try: 39 | func = core.PBOFunction(1, 0, 16, instrumentation=instrumentation) 40 | except ModuleNotFoundError as e: 41 | raise SkipTest("IOH is not installed") from e 42 | x = func.parametrization.sample() 43 | value = func(x.value) 44 | assert isinstance(value, float), "All output of the iohprofiler-functions should be float" 45 | assert np.isfinite(value) 46 | 47 | 48 | def test_W_model() -> None: 49 | try: 50 | func = core.WModelFunction() 51 | except ModuleNotFoundError as e: 52 | raise SkipTest("IOH is not installed") from e 53 | x = func.parametrization.sample() 54 | func2 = core.PBOFunction(1, 0, 16) 55 | assert func(x.value) == func2(x.value), "W-model with default setting should equal base_function" 56 | func = core.WModelFunction(base_function="LeadingOnes") 57 | x = func.parametrization.sample() 58 | func2 = core.PBOFunction(2, 0, 16) 59 | assert func(x.value) == func2(x.value), "W-model with default setting should equal base_function" 60 | -------------------------------------------------------------------------------- /nevergrad/functions/lsgo/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2013, Mohammad N. Omidvar and Xiaodong Li All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | 2. Redistributions in binary form must reproduce the above copyright notice, 9 | this list of conditions and the following disclaimer in the documentation 10 | and/or other materials provided with the distribution. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 13 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 15 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 16 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 17 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 18 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 19 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 20 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 21 | USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | 23 | The views and conclusions contained in the software and documentation are 24 | those of the authors and should not be interpreted as representing official 25 | policies, either expressed or implied, of the FreeBSD Project. 26 | 27 | (This is the so-called Simplified BSD License AKA FreeBSD License) 28 | -------------------------------------------------------------------------------- /nevergrad/functions/lsgo/README.md: -------------------------------------------------------------------------------- 1 | # Large-scale global optimization 2 | 3 | ## Technical report 4 | 5 | ```bibtex 6 | @techreport{lsgo2013, 7 | author = {Li, Xiaodong and Tang, Ke and Omidvar, Mohammmad Nabi and Yang, Zhenyu and Qin, Kai}, 8 | title = {Benchmark Functions for the CEC'2013 Special Session and Competition on Large-Scale Global Optimization}, 9 | institution = {RMIT University}, 10 | year = {2013} 11 | } 12 | ``` 13 | 14 | ## Differences 15 | 16 | Here are a few notable differences from the paper: 17 | 18 | - `F3`, `F6`, `F10`: in the Octave version of the paper, the Ackley function lacks ` Tosz`, `Tasy` and `Lambda`. This implementation reproduces the CPP implementation, which has them activated. 19 | - `F7`: in both the Octave version and the CPP version, `Tasy` and `Tosz` are missing for the side sphere loss. Since this implementation aims at reproducing the CPP results, it is missing here too. 20 | - `F14` optimum is not specified since it is not straightforward to compute. 21 | 22 | ## API 23 | 24 | More to come? 25 | -------------------------------------------------------------------------------- /nevergrad/functions/lsgo/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | # 6 | # This is based on the specifications of: 7 | # X. Li, K. Tang, M. Omidvar, Z. Yang and K. Qin, 8 | # "Benchmark Functions for the CEC’2013 Special Session and Competition on Large Scale Global Optimization", 9 | # Technical Report, Evolutionary Computation and Machine Learning Group, RMIT University, Australia, 2013. 10 | # and the corresponding source code. 11 | 12 | from ._funcs import make_function 13 | -------------------------------------------------------------------------------- /nevergrad/functions/lsgo/cdatafiles/F10-s.txt: -------------------------------------------------------------------------------- 1 | 50 2 | 50 3 | 25 4 | 25 5 | 100 6 | 100 7 | 25 8 | 25 9 | 50 10 | 25 11 | 100 12 | 25 13 | 100 14 | 50 15 | 25 16 | 25 17 | 25 18 | 100 19 | 50 20 | 25 21 | -------------------------------------------------------------------------------- /nevergrad/functions/lsgo/cdatafiles/F10-w.txt: -------------------------------------------------------------------------------- 1 | 0.3127435060483861 2 | 15.12775129002843 3 | 2323.355051932917 4 | 0.0008059163159991055 5 | 11.42081047046656 6 | 3.554186402049341 7 | 29.98730853486525 8 | 0.99814770438828 9 | 1.615139127369899 10 | 1.512835249551407 11 | 0.6084813080072065 12 | 4464853.632306907 13 | 6.807672126970494e-05 14 | 0.1363174627449513 15 | 0.0007887145947891588 16 | 59885.12760160356 17 | 1.85232881407715 18 | 24.78342741548038 19 | 0.5431794716904831 20 | 39.24040541316312 21 | -------------------------------------------------------------------------------- /nevergrad/functions/lsgo/cdatafiles/F11-s.txt: -------------------------------------------------------------------------------- 1 | 50 2 | 50 3 | 25 4 | 25 5 | 100 6 | 100 7 | 25 8 | 25 9 | 50 10 | 25 11 | 100 12 | 25 13 | 100 14 | 50 15 | 25 16 | 25 17 | 25 18 | 100 19 | 50 20 | 25 21 | -------------------------------------------------------------------------------- /nevergrad/functions/lsgo/cdatafiles/F11-w.txt: -------------------------------------------------------------------------------- 1 | 0.01613441050029006 2 | 0.1286113102576636 3 | 0.001204762698494153 4 | 0.3492354534770768 5 | 3.988703102369622 6 | 7.446972342274892 7 | 2.613875947071485 8 | 1.860151050804902e-05 9 | 0.07799241383970082 10 | 4946500.039233495 11 | 907.5677350872909 12 | 1245.438955040323 13 | 0.0001277872704005029 14 | 0.002545171687133515 15 | 0.01229630267562622 16 | 0.2253262515782924 17 | 16011.68013995448 18 | 4.152882294482328 19 | 4208.608600430911 20 | 8.983034451382988e-06 21 | -------------------------------------------------------------------------------- /nevergrad/functions/lsgo/cdatafiles/F13-s.txt: -------------------------------------------------------------------------------- 1 | 50 2 | 50 3 | 25 4 | 25 5 | 100 6 | 100 7 | 25 8 | 25 9 | 50 10 | 25 11 | 100 12 | 25 13 | 100 14 | 50 15 | 25 16 | 25 17 | 25 18 | 100 19 | 50 20 | 25 21 | -------------------------------------------------------------------------------- /nevergrad/functions/lsgo/cdatafiles/F13-w.txt: -------------------------------------------------------------------------------- 1 | 0.4353328319185867 2 | 0.009916326715665044 3 | 0.05427408462402158 4 | 29.36277114669338 5 | 11490.33037696204 6 | 24.12830828465555 7 | 3.451118275947202 8 | 2.326453155544301 9 | 0.001766789509539211 10 | 0.02539477160659147 11 | 19.9959220973553 12 | 0.0003668001927378567 13 | 0.001356048928320048 14 | 0.03874911849895608 15 | 88.89452353634552 16 | 57901.31382337087 17 | 0.008485316099078568 18 | 0.07362038148350014 19 | 0.688309295752457 20 | 119314.8936123031 21 | -------------------------------------------------------------------------------- /nevergrad/functions/lsgo/cdatafiles/F14-s.txt: -------------------------------------------------------------------------------- 1 | 50 2 | 50 3 | 25 4 | 25 5 | 100 6 | 100 7 | 25 8 | 25 9 | 50 10 | 25 11 | 100 12 | 25 13 | 100 14 | 50 15 | 25 16 | 25 17 | 25 18 | 100 19 | 50 20 | 25 21 | -------------------------------------------------------------------------------- /nevergrad/functions/lsgo/cdatafiles/F14-w.txt: -------------------------------------------------------------------------------- 1 | 0.4753902976291743 2 | 498729.4349012464 3 | 328.1032851136715 4 | 0.3231599525017396 5 | 136.4562810151285 6 | 9.025518074644136 7 | 0.092439618796505 8 | 0.0001099484417540517 9 | 0.009366186525282616 10 | 299.6790409975172 11 | 4.939589864702469 12 | 81.36413957775696 13 | 0.6544027477491213 14 | 11.61197332124502 15 | 2860774.320110003 16 | 8.583578119678344e-05 17 | 23.56951753728851 18 | 0.04810314216448019 19 | 1.4318494811719 20 | 12.16976123256558 21 | -------------------------------------------------------------------------------- /nevergrad/functions/lsgo/cdatafiles/F4-s.txt: -------------------------------------------------------------------------------- 1 | 50 2 | 25 3 | 25 4 | 100 5 | 50 6 | 25 7 | 25 8 | -------------------------------------------------------------------------------- /nevergrad/functions/lsgo/cdatafiles/F4-w.txt: -------------------------------------------------------------------------------- 1 | 45.69963061477328 2 | 1.564615888932325 3 | 18465.32344576193 4 | 0.01108949891829191 5 | 13.62598489888553 6 | 0.3015150617722511 7 | 59.6078373100912 8 | -------------------------------------------------------------------------------- /nevergrad/functions/lsgo/cdatafiles/F5-s.txt: -------------------------------------------------------------------------------- 1 | 50 2 | 25 3 | 25 4 | 100 5 | 50 6 | 25 7 | 25 8 | -------------------------------------------------------------------------------- /nevergrad/functions/lsgo/cdatafiles/F5-w.txt: -------------------------------------------------------------------------------- 1 | 0.1807559981875739 2 | 9081.137957372908 3 | 24.27180711217444 4 | 1.86308808032975e-06 5 | 17698.08075760589 6 | 0.0002815181918094626 7 | 0.01525403796219806 8 | -------------------------------------------------------------------------------- /nevergrad/functions/lsgo/cdatafiles/F6-s.txt: -------------------------------------------------------------------------------- 1 | 50 2 | 25 3 | 25 4 | 100 5 | 50 6 | 25 7 | 25 8 | -------------------------------------------------------------------------------- /nevergrad/functions/lsgo/cdatafiles/F6-w.txt: -------------------------------------------------------------------------------- 1 | 0.03527316509198532 2 | 5.315636074945294e-05 3 | 0.8707826395272957 4 | 49513.74201115565 5 | 0.08312474568178191 6 | 3.476438011305293e-05 7 | 282.2934975418022 8 | -------------------------------------------------------------------------------- /nevergrad/functions/lsgo/cdatafiles/F7-s.txt: -------------------------------------------------------------------------------- 1 | 50 2 | 25 3 | 25 4 | 100 5 | 50 6 | 25 7 | 25 8 | -------------------------------------------------------------------------------- /nevergrad/functions/lsgo/cdatafiles/F7-w.txt: -------------------------------------------------------------------------------- 1 | 679.9025375867747 2 | 0.9321555273560842 3 | 2122.850158593588 4 | 0.5060110308419518 5 | 434.5961765462675 6 | 33389.62449652032 7 | 2.569238407592332 8 | -------------------------------------------------------------------------------- /nevergrad/functions/lsgo/cdatafiles/F8-s.txt: -------------------------------------------------------------------------------- 1 | 50 2 | 50 3 | 25 4 | 25 5 | 100 6 | 100 7 | 25 8 | 25 9 | 50 10 | 25 11 | 100 12 | 25 13 | 100 14 | 50 15 | 25 16 | 25 17 | 25 18 | 100 19 | 50 20 | 25 21 | -------------------------------------------------------------------------------- /nevergrad/functions/lsgo/cdatafiles/F8-w.txt: -------------------------------------------------------------------------------- 1 | 4.630303898328862 2 | 0.6864279131323788 3 | 1143756360.088768 4 | 2.007758000992542 5 | 789.3671746186714 6 | 16.33320168691342 7 | 6.074996976773932 8 | 0.06466850615348552 9 | 0.07569676542592878 10 | 35.67259952037679 11 | 7.972550897120909e-06 12 | 10.78226361560055 13 | 4.199965822662956e-06 14 | 0.001923872337445647 15 | 0.001677064168931893 16 | 686.7975656834401 17 | 0.1571465735122922 18 | 0.04417781474359776 19 | 0.3543888360330344 20 | 0.006051787005326174 21 | -------------------------------------------------------------------------------- /nevergrad/functions/lsgo/cdatafiles/F9-s.txt: -------------------------------------------------------------------------------- 1 | 50 2 | 50 3 | 25 4 | 25 5 | 100 6 | 100 7 | 25 8 | 25 9 | 50 10 | 25 11 | 100 12 | 25 13 | 100 14 | 50 15 | 25 16 | 25 17 | 25 18 | 100 19 | 50 20 | 25 21 | -------------------------------------------------------------------------------- /nevergrad/functions/lsgo/cdatafiles/F9-w.txt: -------------------------------------------------------------------------------- 1 | 1756.996997333392 2 | 570.7338357630722 3 | 3.355970801461051 4 | 1.036411046690371 5 | 62822.29234664552 6 | 1.731558445257169 7 | 0.08980493862761418 8 | 0.0008071244581233227 9 | 1403745.636331398 10 | 8716.208361607407 11 | 0.003344616275362139 12 | 1.34951151390475 13 | 0.004776798216929033 14 | 5089.913308957042 15 | 12.66641964611824 16 | 0.0003588940639560592 17 | 0.2400156872122657 18 | 3.964353127212945 19 | 0.001428559155593465 20 | 0.005228218198001427 21 | -------------------------------------------------------------------------------- /nevergrad/functions/mixsimulator/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .core import OptimizeMix as OptimizeMix 7 | -------------------------------------------------------------------------------- /nevergrad/functions/mixsimulator/core.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | # Based on https://github.com/Foloso/MixSimulator 7 | 8 | from .. import base 9 | 10 | 11 | class OptimizeMix(base.ExperimentFunction): 12 | """ 13 | MixSimulator is an application with an optimization model for calculating 14 | and simulating the least cost of an energy mix under certain constraints. 15 | 16 | For now, it uses a default dataset (more will be added soon). 17 | 18 | For more information, visit : https://github.com/Foloso/MixSimulator 19 | 20 | Parameters 21 | ---------- 22 | time: int 23 | total time over which it evaluates the mix (must be in hour) 24 | 25 | """ 26 | 27 | def __init__(self, time: int = 8760) -> None: 28 | try: 29 | from mixsimulator.MixSimulator import MixSimulator # pylint: disable=import-outside-toplevel 30 | from mixsimulator.Demand import Demand 31 | 32 | self._mix = MixSimulator() 33 | self._mix.set_data_to("Toamasina") 34 | self._demand = Demand() 35 | self._demand.set_data_to("Toamasina", delimiter=",") 36 | self._mix.set_demand(self._demand) 37 | 38 | except (KeyError, AttributeError, ModuleNotFoundError) as e: 39 | # send a skip error so that this does not break the test suit 40 | raise base.UnsupportedExperiment("mixsimulator dependency issue") from e 41 | self._mix.set_penalisation_cost(100) 42 | self._mix.set_carbon_cost(10) 43 | parameters = self._mix.get_opt_params(time) 44 | parameters.set_name("dims") 45 | super().__init__(self._mix.loss_function, parameters) 46 | -------------------------------------------------------------------------------- /nevergrad/functions/mixsimulator/test_core.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import numpy as np 7 | from . import core 8 | 9 | 10 | def test_mixsimulator() -> None: 11 | func = core.OptimizeMix() 12 | x = 2 * np.random.rand(func.dimension) 13 | value = func(x) # should not touch boundaries, so value should be < np.inf 14 | assert isinstance(value, float) 15 | assert value < np.inf 16 | -------------------------------------------------------------------------------- /nevergrad/functions/ml/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .mlfunctionlib import MLTuning as MLTuning 7 | -------------------------------------------------------------------------------- /nevergrad/functions/mlda/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .problems import Clustering as Clustering 7 | from .problems import Perceptron as Perceptron 8 | from .problems import SammonMapping as SammonMapping 9 | from .problems import Landscape as Landscape 10 | -------------------------------------------------------------------------------- /nevergrad/functions/multiobjective/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from nevergrad.common import errors 7 | import nevergrad.common.typing as tp 8 | 9 | 10 | class MultiobjectiveFunction: 11 | """MultiobjectiveFunction is deprecated and is removed after v0.4.3 " 12 | because it is no more needed. You should just pass a multiobjective loss to " 13 | optimizer.tell.\nSee https://facebookresearch.github.io/nevergrad/" 14 | optimization.html#multiobjective-minimization-with-nevergrad\n", 15 | """ 16 | 17 | def __init__( 18 | self, 19 | multiobjective_function: tp.Callable[..., tp.ArrayLike], 20 | upper_bounds: tp.Optional[tp.ArrayLike] = None, 21 | ) -> None: 22 | raise errors.NevergradDeprecationError( 23 | "MultiobjectiveFunction is deprecated and is removed after v0.4.3 " 24 | "because it is no more needed. You should just pass a multiobjective loss to " 25 | "optimizer.tell.\nSee https://facebookresearch.github.io/nevergrad/" 26 | "optimization.html#multiobjective-minimization-with-nevergrad\n", 27 | ) 28 | -------------------------------------------------------------------------------- /nevergrad/functions/olympussurfaces/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .core import OlympusSurface as OlympusSurface 7 | from .core import OlympusEmulator as OlympusEmulator 8 | -------------------------------------------------------------------------------- /nevergrad/functions/olympussurfaces/test_core.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import os 7 | import numpy as np 8 | import nevergrad as ng 9 | from . import core 10 | import pytest 11 | 12 | 13 | @pytest.mark.parametrize("kind", core.OlympusSurface.SURFACE_KINDS) 14 | @pytest.mark.parametrize("noise_kind", ["GaussianNoise", "UniformNoise", "GammaNoise"]) 15 | def skip_test_olympus_surface(kind: str, noise_kind: str) -> None: 16 | try: 17 | func = core.OlympusSurface(kind=kind, noise_kind=noise_kind) 18 | except Exception as e: 19 | if os.name == "nt": 20 | raise ng.errors.UnsupportedExperiment("Unavailable under Windows.") 21 | else: 22 | raise e 23 | func2 = core.OlympusSurface(kind=kind, noise_kind=noise_kind) # Let us check the randomization. 24 | x = 2 * np.random.rand(func.dimension) 25 | value = func(x) # should not touch boundaries, so value should be < np.inf 26 | value2 = func2(x) # should not touch boundaries, so value should be < np.inf 27 | assert isinstance(value, float) 28 | assert value < np.inf 29 | assert value != value2 or noise_kind == "GammaNoise" 30 | 31 | 32 | # @pytest.mark.parametrize("dataset_kind", core.OlympusEmulator.DATASETS) 33 | # @pytest.mark.parametrize("model_kind", ["NeuralNet"]) # ["BayesNeuralNet", "NeuralNet"]) 34 | # def test_olympus_emulator(dataset_kind: str, model_kind: str) -> None: 35 | # func = core.OlympusEmulator(dataset_kind=dataset_kind, model_kind=model_kind) 36 | # x = 2 * np.random.rand(func.dimension) 37 | # value = func(x) # should not touch boundaries, so value should be < np.inf 38 | # assert isinstance(value, float) 39 | # assert value < np.inf 40 | -------------------------------------------------------------------------------- /nevergrad/functions/photonics/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .core import Photonics as Photonics 7 | from .core import ceviche 8 | from .core import gambas 9 | from .gambas import gambas_function 10 | from .mode_converter import mode_converter 11 | -------------------------------------------------------------------------------- /nevergrad/functions/photonics/epsilon_epscSi.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/nevergrad/functions/photonics/epsilon_epscSi.npy -------------------------------------------------------------------------------- /nevergrad/functions/photonics/epsilon_solar.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/nevergrad/functions/photonics/epsilon_solar.npy -------------------------------------------------------------------------------- /nevergrad/functions/photonics/wavelength_solar.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/nevergrad/b2fec24d93a1f79e40880b462887a0c8be0e1a25/nevergrad/functions/photonics/wavelength_solar.npy -------------------------------------------------------------------------------- /nevergrad/functions/powersystems/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .core import PowerSystem as PowerSystem 7 | -------------------------------------------------------------------------------- /nevergrad/functions/powersystems/test_core.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import typing as tp 7 | from unittest.mock import patch 8 | import numpy as np 9 | from . import core 10 | 11 | 12 | def test_powersystem_small() -> None: 13 | np.random.seed(12) 14 | dams = 2 15 | func = core.PowerSystem(num_dams=dams, num_years=0.2) 16 | x = [np.random.rand(func.dimension // dams) for _ in range(dams)] 17 | value = func.function(*x) 18 | np.testing.assert_almost_equal(value, 4266.8177479) 19 | 20 | 21 | @patch(f"{__name__}.core.plt") 22 | def test_make_plots(mock_plt: tp.Any) -> None: 23 | func = core.PowerSystem() 24 | func.losses = [0.1] 25 | func.make_plots("not_valid.png") 26 | assert mock_plt.clf.call_count == 1 27 | assert mock_plt.subplot.call_count == 4 28 | assert mock_plt.savefig.call_count == 1 29 | -------------------------------------------------------------------------------- /nevergrad/functions/pyomo/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .core import Pyomo as Pyomo 7 | -------------------------------------------------------------------------------- /nevergrad/functions/pyomo/test_model_1.dat: -------------------------------------------------------------------------------- 1 | param: F: Xmin := 2 | "New York" 1.85 3 | "Hong Kong" 0.80 ; 4 | -------------------------------------------------------------------------------- /nevergrad/functions/rl/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from . import envs as envs 7 | from . import agents as agents 8 | from .base import EnvironmentRunner as EnvironmentRunner 9 | -------------------------------------------------------------------------------- /nevergrad/functions/rocket/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .rocket import Rocket as Rocket 7 | -------------------------------------------------------------------------------- /nevergrad/functions/rocket/test_rocket.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import numpy as np 7 | from . import rocket 8 | 9 | 10 | def notest_rocket() -> None: 11 | func = rocket.Rocket() 12 | x = 0 * np.random.rand(func.dimension) 13 | value = func(x) # should not touch boundaries, so value should be < np.inf 14 | np.testing.assert_almost_equal(value, 0.0) 15 | -------------------------------------------------------------------------------- /nevergrad/functions/stsp/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .core import STSP as STSP 7 | -------------------------------------------------------------------------------- /nevergrad/functions/stsp/core.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | # 6 | # Based on a discussion at Dagstuhl's seminar on Computational Intelligence in Games with: 7 | # - Dan Ashlock 8 | # - Chiara Sironi 9 | # - Guenter Rudolph 10 | # - Jialin Liu 11 | 12 | import matplotlib.pyplot as plt 13 | import numpy as np 14 | from nevergrad.parametrization import parameter as p 15 | from ..base import ExperimentFunction 16 | 17 | 18 | class STSP(ExperimentFunction): 19 | def __init__(self, dimension: int = 500, complex_tsp: bool = False) -> None: 20 | super().__init__(self._simulate_stsp, p.Array(shape=(dimension,))) 21 | self.order = np.arange(0, self.dimension) 22 | self.complex = complex_tsp 23 | self.x = self.parametrization.random_state.normal(size=self.dimension) 24 | self.y = self.parametrization.random_state.normal(size=self.dimension) 25 | 26 | def _simulate_stsp(self, x: np.ndarray) -> float: 27 | order = np.argsort(x) 28 | self.order = order 29 | x = self.x[order] 30 | y = self.y[order] 31 | output = np.sqrt((x[0] - x[-1]) ** 2 + (y[0] - y[-1]) ** 2) + sum( 32 | np.sqrt((x[i] - x[i + 1]) ** 2 + (y[i] - y[i + 1]) ** 2) for i in range(self.dimension - 1) 33 | ) 34 | if self.complex: 35 | output += np.sum(np.diff(order) ** 2) / np.sqrt(self.dimension + 1.0) 36 | return float(output) 37 | 38 | def make_plots(self, filename: str = "stsp.png") -> None: 39 | plt.clf() 40 | # Plot the optimization run. 41 | ax = plt.subplot(1, 1, 1) 42 | ax.set_xlabel("iteration number") 43 | order = self.order 44 | x = self.x 45 | y = self.y 46 | ax.plot((x[o] for o in order), (y[o] for o in order)) # type: ignore 47 | plt.savefig(filename) 48 | -------------------------------------------------------------------------------- /nevergrad/functions/stsp/test_core.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import numpy as np 7 | import pytest 8 | from . import core 9 | 10 | 11 | @pytest.mark.parametrize("complex_tsp", [True, False]) 12 | def test_stsp(complex_tsp: bool) -> None: 13 | func = core.STSP(complex_tsp=complex_tsp) 14 | x = 7 * np.random.rand(func.dimension) 15 | value = func(x) # should not touch boundaries, so value should be < np.inf 16 | assert isinstance(value, float) 17 | assert value < np.inf 18 | -------------------------------------------------------------------------------- /nevergrad/functions/test_utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import numpy as np 7 | from . import utils 8 | 9 | 10 | def test_transform() -> None: 11 | indices = list(range(12)) 12 | transform = utils.Transform(indices, rotation=True) 13 | assert transform.rotation_matrix is not None 14 | rot: np.ndarray = transform.rotation_matrix 15 | np.testing.assert_array_almost_equal(rot.T.dot(rot), np.identity(12)) 16 | x = np.random.normal(0, 1, 16) 17 | y = transform(x) 18 | np.testing.assert_equal(len(y), 12) 19 | np.testing.assert_array_equal(y, transform(x)) 20 | -------------------------------------------------------------------------------- /nevergrad/functions/topology_optimization/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .core import TO as TO 7 | -------------------------------------------------------------------------------- /nevergrad/functions/topology_optimization/core.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | # 6 | # Based on a discussion at Dagstuhl's seminar on Computational Intelligence in Games with: 7 | # - Dan Ashlock 8 | # - Chiara Sironi 9 | # - Guenter Rudolph 10 | # - Jialin Liu 11 | 12 | import numpy as np 13 | from nevergrad.parametrization import parameter as p 14 | from ..base import ExperimentFunction 15 | from scipy.ndimage import gaussian_filter 16 | 17 | 18 | class TO(ExperimentFunction): 19 | def __init__(self, n: int = 50) -> None: 20 | super().__init__( 21 | self._simulate_to, p.Array(shape=(n, n), lower=-1.0, upper=1.0).set_name(f"array{n}x{n}") 22 | ) 23 | self.n = n 24 | self.idx = self.parametrization.random_state.randint(50000) 25 | 26 | def _simulate_to(self, x: np.ndarray) -> float: 27 | x = x.reshape(self.n, self.n) 28 | idx = self.idx 29 | n = self.n 30 | xa = idx % 3 31 | size = n * n 32 | sqrtsize = n 33 | xb = 2 - xa 34 | if (idx // 12) % 2 > 0: 35 | xs = 1.5 * ( 36 | np.array( 37 | [ 38 | float(np.cos(self.idx * 0.01 + xa * i + xb * j) < 0.0) 39 | for i in range(n) 40 | for j in range(n) 41 | ] 42 | ).reshape(n, n) 43 | - 0.5 44 | ) 45 | else: 46 | xs = 1.5 * ( 47 | np.array( 48 | [float((self.idx * 0.01 + xa * i + xb * j) > 1.6 * n) for i in range(n) for j in range(n)] 49 | ).reshape(n, n) 50 | - 0.5 51 | ) 52 | if (idx // 3) % 2 > 0: 53 | xs = np.transpose(xs) 54 | if (idx // 6) % 2 > 0: 55 | xs = -xs 56 | return ( 57 | 5.0 * np.sum(np.abs(x - xs) > 0.3) / size 58 | + 3.0 * np.linalg.norm(x - gaussian_filter(x, sigma=3)) / sqrtsize 59 | ) 60 | -------------------------------------------------------------------------------- /nevergrad/functions/topology_optimization/test_core.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import numpy as np 7 | from . import core 8 | 9 | 10 | def test_to() -> None: 11 | func = core.TO(10) 12 | x = 7 * np.random.rand(func.dimension).reshape(10, 10) 13 | value = func(x) # should not touch boundaries, so value should be < np.inf 14 | assert isinstance(value, float) 15 | assert value < np.inf 16 | -------------------------------------------------------------------------------- /nevergrad/functions/unitcommitment/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .core import UnitCommitmentProblem as UnitCommitmentProblem 7 | -------------------------------------------------------------------------------- /nevergrad/functions/unitcommitment/test_core.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import numpy as np 7 | from . import core 8 | 9 | 10 | def test_unit_commitment_p1() -> None: 11 | np.random.seed(0) 12 | T = 10 13 | N = 5 14 | func = core.UnitCommitmentProblem(problem_name="semi-continuous", num_timepoints=T, num_generators=N) 15 | op_out = np.ones((N, T)) 16 | op_states = np.ones((N, T)) 17 | value = func.function(operational_output=op_out, operational_states=op_states) 18 | assert isinstance(value, float) 19 | assert np.allclose([value], [38721960.61493097], rtol=1e-04, atol=1e-05) 20 | -------------------------------------------------------------------------------- /nevergrad/functions/utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import typing as tp 7 | import numpy as np 8 | 9 | 10 | class Transform: 11 | """Defines a unique random transformation (index selection, translation, and optionally rotation) 12 | which can be applied to a point 13 | """ 14 | 15 | def __init__( 16 | self, 17 | indices: tp.List[int], 18 | translation_factor: float = 1, 19 | rotation: bool = False, 20 | random_state: tp.Optional[np.random.RandomState] = None, 21 | expo: float = 1.0, 22 | ) -> None: 23 | dim = len(indices) 24 | assert dim 25 | if random_state is None: 26 | random_state = np.random.RandomState(0) 27 | random_state.set_state(np.random.get_state()) 28 | self.indices = np.asarray(indices) 29 | self.translation: np.ndarray = (random_state.normal(0, 1, dim) ** expo) * translation_factor 30 | self.rotation_matrix: tp.Optional[np.ndarray] = None 31 | if rotation: 32 | self.rotation_matrix = np.linalg.qr(random_state.normal(0, 1, size=(dim, dim)))[0] 33 | 34 | def __call__(self, x: np.ndarray) -> np.ndarray: 35 | y: np.ndarray = x[self.indices] - self.translation 36 | if self.rotation_matrix is not None: 37 | y = self.rotation_matrix.dot(y) # type: ignore 38 | return y 39 | -------------------------------------------------------------------------------- /nevergrad/ops/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from ..parametrization import mutation as mutations 7 | from ..parametrization._datalayers import Int as Int 8 | from . import constraints as constraints 9 | 10 | 11 | __all__ = ["mutations", "constraints", "Int"] 12 | -------------------------------------------------------------------------------- /nevergrad/ops/test_constraints.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import typing as tp 7 | import pytest 8 | import numpy as np 9 | import nevergrad as ng 10 | from . import constraints 11 | 12 | 13 | def function(*args: float) -> tp.Any: 14 | if len(args) == 1: 15 | return args[0] 16 | return args 17 | 18 | 19 | @pytest.mark.parametrize("num", (1, 3)) # type: ignore 20 | def test_constraint(num: int) -> None: 21 | parameter = ng.p.Instrumentation(*(ng.p.Scalar(np.random.randn()) for _ in range(num))) 22 | constrained = constraints.Constraint(function)(parameter) 23 | # check basic layer functionalities 24 | layer: constraints.Constraint = constrained._layers[-1] # type: ignore 25 | assert layer.function(*([1] * num)) == 1 if num == 1 else [1] * num 26 | assert layer.function(*([-1] * num)) == 0 if num == 1 else [0] * num 27 | assert ( 28 | np.mean([x < 0.1 for x in constrained.args]) > 0.5 29 | ), constrained.args # some slack to avoid flakiness 30 | -------------------------------------------------------------------------------- /nevergrad/optimization/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .base import Optimizer # abstract class, for type checking 7 | from . import optimizerlib 8 | from .optimizerlib import registry as registry 9 | -------------------------------------------------------------------------------- /nevergrad/optimization/families.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | """Parametrizable families of optimizers. 6 | 7 | Caution 8 | ------- 9 | This module and its available classes are experimental and may change quickly in the near future. 10 | """ 11 | from .optimizerlib import ParametrizedOnePlusOne 12 | from .optimizerlib import ParametrizedTBPSA 13 | from .optimizerlib import ParametrizedMetaModel 14 | 15 | try: 16 | from .optimizerlib import ParametrizedBO 17 | except ImportError: 18 | pass # bayes_opt not available 19 | from .optimizerlib import ParametrizedCMA 20 | from .optimizerlib import EMNA 21 | from .optimizerlib import Chaining 22 | from .optimizerlib import NoisySplit 23 | from .optimizerlib import ConfPortfolio 24 | from .optimizerlib import ConfPSO 25 | from .optimizerlib import ConfSplitOptimizer 26 | from .optimizerlib import BayesOptim 27 | from .differentialevolution import DifferentialEvolution 28 | from .es import EvolutionStrategy 29 | from .recastlib import NonObjectOptimizer 30 | from .recastlib import Pymoo 31 | from .oneshot import RandomSearchMaker 32 | from .oneshot import SamplingSearch 33 | 34 | 35 | __all__ = [ 36 | "ParametrizedOnePlusOne", 37 | "ParametrizedCMA", 38 | "ParametrizedBO", 39 | "ParametrizedTBPSA", 40 | "ParametrizedMetaModel", 41 | "DifferentialEvolution", 42 | "EvolutionStrategy", 43 | "NonObjectOptimizer", 44 | "Pymoo", 45 | "RandomSearchMaker", 46 | "SamplingSearch", 47 | "Chaining", 48 | "EMNA", 49 | "NoisySplit", 50 | "ConfPortfolio", 51 | "ConfPSO", 52 | "ConfSplitOptimizer", 53 | "BayesOptim", 54 | ] 55 | -------------------------------------------------------------------------------- /nevergrad/optimization/multiobjective/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .core import HypervolumePareto as HypervolumePareto 7 | from .core import AUTO_BOUND as AUTO_BOUND 8 | from .hypervolume import HypervolumeIndicator as HypervolumeIndicator 9 | -------------------------------------------------------------------------------- /nevergrad/optimization/requirements_check.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import sys 7 | from pathlib import Path 8 | import nevergrad as ng 9 | from nevergrad.parametrization import FolderFunction 10 | 11 | 12 | if __name__ == "__main__": 13 | folder = Path(__file__).parents[1] / "parametrization" / "examples" 14 | func = FolderFunction(folder, [sys.executable, "examples/script.py"], clean_copy=True) 15 | instrumentation = ng.p.Instrumentation( 16 | value1=ng.p.Scalar(), value2=12, string=ng.p.Choice(["plop", "blublu", "plouf"]) 17 | ) 18 | opt = ng.optimizers.registry["OnePlusOne"](instrumentation, budget=4) 19 | opt.minimize(func) 20 | ng.families.ParametrizedOnePlusOne() 21 | -------------------------------------------------------------------------------- /nevergrad/optimization/test_sa.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import pytest 7 | 8 | # import numpy as np 9 | import sys 10 | 11 | # from scipy import stats 12 | # import nevergrad as ng 13 | 14 | 15 | # decorators to be used when testing on Windows is unecessary 16 | # or cumbersome 17 | skip_win_perf = pytest.mark.skipif( 18 | sys.platform == "win32", reason="Slow, and no need to test performance on all platforms" 19 | ) 20 | 21 | 22 | @skip_win_perf # type: ignore 23 | def test_sa() -> None: 24 | pass 25 | 26 | 27 | # num_tests = 77 28 | # for o in []: # ["DiscreteOnePlusOne"]: dirty temporary hack. # type: ignore 29 | # values = [] 30 | # valuesT = [] 31 | # for _ in range(num_tests): 32 | # dim = 30 33 | # arity = 3 34 | # budget = 57 35 | # domain = ng.p.TransitionChoice(range(arity), ordered=False, repetitions=dim) 36 | # optimum = np.random.randint(arity, size=dim) 37 | # 38 | # def of(x): 39 | # return np.abs(np.abs(sum(x) - sum(optimum)) - 7.0) 40 | # 41 | # recom = ng.optimizers.registry[o](domain, budget).minimize(of).value 42 | # recomT = ng.optimizers.registry["SA" + o + "Exp09"](domain, budget).minimize(of).value 43 | # values += [of(recom)] 44 | # valuesT += [of(recomT)] 45 | # pval = stats.mannwhitneyu(valuesT, values, alternative="less").pvalue 46 | # assert pval < 0.2, f"Simulated Annealing {o} fails the test: pval = {pval}." 47 | -------------------------------------------------------------------------------- /nevergrad/optimization/test_tabu.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import pytest 7 | import numpy as np 8 | import sys 9 | from scipy import stats 10 | import nevergrad as ng 11 | import nevergrad.common.typing as tp 12 | 13 | 14 | # decorators to be used when testing on Windows is unecessary 15 | # or cumbersome 16 | skip_win_perf = pytest.mark.skipif( 17 | sys.platform == "win32", reason="Slow, and no need to test performance on all platforms" 18 | ) 19 | 20 | 21 | @skip_win_perf # type: ignore 22 | def no_test_tabu() -> None: 23 | 24 | num_tests = 97 25 | for o in ["DiscreteOnePlusOne"]: 26 | values = [] 27 | valuesT = [] 28 | for _ in range(num_tests): 29 | dim = 4 30 | arity = 7 31 | budget = (arity**dim) // 50 32 | domain = ng.p.TransitionChoice(range(arity), ordered=False, repetitions=dim) 33 | optimum = np.random.randint(arity, size=dim) 34 | 35 | def of(x): 36 | return -np.sum((np.asarray(x) == optimum)) 37 | 38 | recom = ng.optimizers.registry[o](domain, budget).minimize(of).value 39 | recomT = ng.optimizers.registry[o + "T"](domain, budget).minimize(of).value 40 | values += [of(recom)] 41 | valuesT += [of(recomT)] 42 | pval = stats.mannwhitneyu(valuesT, values, alternative="less").pvalue 43 | assert pval < 0.15, f"{o} fails the Tabu search test: pval = {pval}." 44 | 45 | 46 | def summation(x: tp.ArrayLike) -> float: 47 | return sum(x) 48 | 49 | 50 | @skip_win_perf # type: ignore 51 | def no_test_tabu_sum() -> None: 52 | 53 | num_tests = 147 54 | for o in ["DiscreteOnePlusOne"]: 55 | values = [] 56 | valuesT = [] 57 | for _ in range(num_tests): 58 | dim = 24 59 | arity = 3 60 | budget = 7 61 | domain = ng.p.TransitionChoice(range(arity), ordered=False, repetitions=dim) 62 | domain.tabu_congruence = summation 63 | optimum = np.random.randint(arity, size=dim) 64 | 65 | def of(x): 66 | return np.abs(sum(x) - sum(optimum)) 67 | 68 | recom = ng.optimizers.registry[o](domain, budget).minimize(of).value 69 | recomT = ng.optimizers.registry[o + "T"](domain, budget).minimize(of).value 70 | values += [of(recom)] 71 | valuesT += [of(recomT)] 72 | pval = stats.mannwhitneyu(valuesT, values, alternative="less").pvalue 73 | assert pval < 0.1, f"{o} fails the Tabu search test: pval = {pval}." 74 | -------------------------------------------------------------------------------- /nevergrad/parametrization/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from nevergrad.parametrization.instantiate import FolderFunction as FolderFunction 7 | from nevergrad.parametrization.utils import TemporaryDirectoryCopy as TemporaryDirectoryCopy 8 | from nevergrad.parametrization.utils import CommandFunction as CommandFunction 9 | from . import parameter as parameter 10 | -------------------------------------------------------------------------------- /nevergrad/parametrization/examples/script.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | """This is a very basic example of an instrumented python script""" 7 | value1 = 10 8 | # @nevergrad@ value1 = NG_ARG{value1|this is a comment} 9 | value2 = 90 10 | # @nevergrad@ value2 = NG_ARG{value2} 11 | string = "plop" 12 | # @nevergrad@ string = NG_ARG{string} 13 | print( 14 | 12 if string == "blublu" else abs(value1 - 100) * value2 15 | ) # last print should provide the fitness value (minimization) 16 | -------------------------------------------------------------------------------- /nevergrad/parametrization/parameter.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | # pylint: disable=unused-import 7 | # import with "as" to explicitely allow reexport (mypy) 8 | 9 | # abstract types 10 | from .core import Parameter as Parameter 11 | from .container import Container as Container 12 | from .choice import BaseChoice as BaseChoice 13 | from .data import Data as Data 14 | 15 | # special types 16 | from .core import Constant as Constant # avoid using except for checks 17 | from .core import MultiobjectiveReference as MultiobjectiveReference # multiobjective optimization 18 | 19 | # containers 20 | from .container import Dict as Dict 21 | from .container import Tuple as Tuple 22 | from .container import Instrumentation as Instrumentation 23 | 24 | # data 25 | from .data import Array as Array 26 | from .data import Scalar as Scalar 27 | from .data import Log as Log 28 | from . import mutation 29 | from ._datalayers import Angles as Angles 30 | 31 | # choices 32 | from .choice import Choice as Choice 33 | from .choice import TransitionChoice as TransitionChoice 34 | 35 | # other 36 | from . import helpers as helpers 37 | -------------------------------------------------------------------------------- /nevergrad/parametrization/test_discretization.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import typing as tp 7 | import warnings 8 | import numpy as np 9 | from ..common import testing 10 | from . import discretization 11 | 12 | 13 | @testing.parametrized( 14 | arity2=(2, [0.1, -2, 0], [1, 0, 0]), 15 | arity100=(100, [-15, -2, -0.3, 0.3, 2, 15], [0, 2, 38, 61, 97, 99]), 16 | borderline_cases_100=(100, [-np.inf, np.inf, np.nan], [0, 99, 0]), 17 | borderline_cases_2=(2, [-np.inf, np.inf, np.nan], [0, 1, 0]), 18 | ) 19 | def test_thresholding_discretization(arity: int, data: tp.List[float], expected: tp.List[float]) -> None: 20 | with warnings.catch_warnings(): 21 | warnings.simplefilter("ignore") 22 | output = discretization.threshold_discretization(data, arity) 23 | np.testing.assert_array_equal(output, expected) 24 | 25 | 26 | def test_inverse_threshold_discretization() -> None: 27 | arity = 4 28 | indexes = np.arange(arity) # Test all possible indexes 29 | data = discretization.inverse_threshold_discretization(indexes, arity) # type: ignore 30 | np.testing.assert_array_equal(discretization.threshold_discretization(data, arity), indexes) 31 | 32 | 33 | def test_encoder_probabilities() -> None: 34 | weights = np.array( 35 | [ 36 | [0, 0, 0], 37 | [0, 0, 100], 38 | [np.nan, 0, 1], 39 | [np.inf, np.inf, np.inf], 40 | [np.inf, np.inf, 12], 41 | [0, -np.inf, 0], 42 | ] 43 | ) 44 | rng = np.random.RandomState(12) 45 | enc = discretization.Encoder(weights, rng=rng) 46 | proba = enc.probabilities() 47 | expected = [ 48 | [0.333, 0.333, 0.333], 49 | [0, 0, 1], 50 | [0, 0.269, 0.731], 51 | [0.333, 0.333, 0.333], 52 | [0.5, 0.5, 0], 53 | [0.5, 0, 0.5], 54 | ] 55 | np.testing.assert_array_almost_equal(proba, expected, decimal=3) # type: ignore 56 | 57 | 58 | def test_encoder() -> None: 59 | weights = np.array([[0, 0, 0], [0, 0, 100]]) 60 | rng = np.random.RandomState(14) 61 | enc = discretization.Encoder(weights, rng=rng) 62 | np.testing.assert_equal(enc.encode(), [1, 2]) 63 | np.testing.assert_equal(enc.encode(), [2, 2]) 64 | # 65 | for _ in range(10): 66 | np.testing.assert_equal(enc.encode(True), [0, 2]) 67 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.black] 2 | line-length = 110 3 | exclude = ''' 4 | ( 5 | /( 6 | .eggs # exclude a few common directories in the 7 | | .git # root of the project 8 | | .mypy_cache 9 | | dist 10 | | docs 11 | ) 12 | ) 13 | ''' 14 | -------------------------------------------------------------------------------- /requirements/bench.txt: -------------------------------------------------------------------------------- 1 | requests>=2.21.0 2 | #smac[all]>=0.13.1 3 | smac>=2.0.1 4 | scipy #=1.6 # 1.6 required for SMAC because deprecated usage of sobol_seq 5 | scikit-optimize 6 | #scikit-optimize._shgo_lib 7 | xlwt>=1.3.0 8 | xlrd>=1.2.0 9 | #lpips>=0.1.3 # removed because sometimes complicated. 10 | opencv-python>=4.1.2.30 11 | matplotlib==3.7.0 12 | #matplotlib>=2.2.3 13 | #matplotlib==3.0.3 14 | gym==0.24.1 15 | #gym-anm>=1.0.1 16 | pygame>=2.1.2 17 | torch>=1.7.0 18 | hiplot 19 | fcmaes #>=1.2.7 20 | pandas>=0.23.4 21 | openpyxl>=3.0.0 # mlda data (for pandas) 22 | #pyproj>=2.6.1 23 | pyproj 24 | Pillow>=10.3.0 25 | tqdm 26 | torchvision>=0.11.1 27 | #pyomo>=6.7.3 28 | pyomo==5.7.1 29 | mixsimulator>=0.3.3 30 | hyperopt>=0.2.5 31 | IOHexperimenter>=0.2.9.2 32 | # IOHexperimenter>=0.2.8.7 33 | tensorflow-estimator>=2.7.0 34 | tensorflow>=2.7.0 35 | keras>=2.4.3 36 | #koncept>=0.2.2 # removed because sometimes complicated 37 | #tensorflow-estimator>=2.7.0 38 | scikit-learn>=1.0.1 39 | scikit-image>=0.18.3 40 | image-quality>=1.2.7 41 | #keras>=2.4.3 42 | #tensorflow>=2.7.0 43 | pymoo==0.5.0 44 | olymp>=0.0.1b0 ; sys_platform == "linux" 45 | Keras-Preprocessing 46 | silence_tensorflow # for olymp 47 | tensorflow_probability # for olymp 48 | bayes-optim #==0.3.0 49 | nlopt 50 | pybullet>=3.2.2 51 | #box2d-py>=2.3.5 52 | glfw 53 | mujoco 54 | pySOT 55 | pytest-timeout 56 | pytest-xdist 57 | poap 58 | pytest-circleci-parallelized 59 | Py-BOBYQA>=1.2 60 | ax-platform 61 | loguru # for fcmaes 62 | #gomea 63 | directsearch>=1.0 64 | numpy>=1.16.2 65 | scipy>=1.2.1 66 | #matplotlib>=3.0.3 67 | autograd>=1.2 68 | #ceviche>=0.0.2 69 | scikit-image>=0.15.0 70 | -------------------------------------------------------------------------------- /requirements/dev.txt: -------------------------------------------------------------------------------- 1 | black==24.3.0 2 | mypy>=0.800 3 | pytest>=4.3.0 4 | pytest-cov>=2.6.1 5 | pylint>=2.4.4 6 | wheel>=0.33.6 7 | setuptools==70.0.0 8 | #setuptools>=41.2.0 9 | sphinx>=3.3.0 10 | sphinx_rtd_theme>=0.4.3 11 | recommonmark>=0.5.0 12 | twine>=3.1.1 # for upload to pypi 13 | autodocsumm>=0.1.11 14 | pandas>=0.23.4 15 | pyparsing>=2.2.1 # temporarily fixed to avoid incompatibilities (to be removed) 16 | docutils==0.17.1 # 0.18 is buggy 17 | -------------------------------------------------------------------------------- /requirements/main.txt: -------------------------------------------------------------------------------- 1 | numpy>=1.24.0 2 | cma>=2.6.0 3 | bayesian-optimization==1.4.0 4 | typing_extensions>=3.6.6 5 | pandas 6 | directsearch 7 | -------------------------------------------------------------------------------- /scripts/ceviche.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #SBATCH --job-name=ceviche 3 | #SBATCH --output=ceviche_%A_%a.out 4 | #SBATCH --error=ceviche_%A_%a.err 5 | #SBATCH --time=72:00:00 6 | #SBATCH --partition=scavenge 7 | #SBATCH --nodes=1 8 | #SBATCH --cpus-per-task=70 9 | #SBATCH -a 0-100%330 10 | 11 | 12 | #999%200 13 | 14 | 15 | 16 | #273 17 | 18 | 19 | 20 | if [ $SLURM_ARRAY_TASK_ID -eq 0 ]; then 21 | cp multi_ceviche_c0.csv multi_ceviche_c0_`date | sed 's/ /_/g'`.csv.back 22 | fi 23 | 24 | 25 | task=multi_ceviche_c0 26 | 27 | echo task attribution $SLURM_ARRAY_TASK_ID $task 28 | echo Keras/TF versions: 29 | pip show keras tensorflow tensorflow-estimator 30 | 31 | conda info 32 | 33 | echo Starting at 34 | date 35 | # num_workers is the number of processes. Maybe use a bit more than the number of cores at the line "cpus-per-task" 36 | # above. 37 | time python -m nevergrad.benchmark $task --num_workers=1 2>&1 | cut -c1-180 | egrep '[A-Zf-z]' 38 | #python -m nevergrad.benchmark $task --num_workers=1 2>&1 | tail -n 50 39 | #python -m nevergrad.benchmark $task --num_workers=1 2>&1 | tail -n 50 40 | #python -m nevergrad.benchmark $task --num_workers=1 2>&1 | tail -n 50 41 | #python -m nevergrad.benchmark $task --num_workers=1 2>&1 | tail -n 50 42 | #python -m nevergrad.benchmark $task --num_workers=1 2>&1 | tail -n 50 43 | #python -m nevergrad.benchmark $task --num_workers=1 2>&1 | tail -n 50 44 | #if ! (( $SLURM_ARRAY_TASK_ID % 30 )) then 45 | #cp multi_ceviche_c0.csv multi_ceviche_c0_`date | sed 's/ /_/g'`.csv.back 46 | #fi 47 | #python -m nevergrad.benchmark $task --num_workers=1 2>&1 | tail -n 50 48 | #python -m nevergrad.benchmark $task --num_workers=1 2>&1 | tail -n 50 49 | #python -m nevergrad.benchmark $task --num_workers=1 2>&1 | tail -n 50 50 | #python -m nevergrad.benchmark $task --num_workers=1 2>&1 | tail -n 50 51 | #python -m nevergrad.benchmark $task --num_workers=1 2>&1 | tail -n 50 52 | #python -m nevergrad.benchmark $task --num_workers=1 2>&1 | tail -n 50 53 | #if [ $SLURM_ARRAY_TASK_ID -eq 0 ]; then 54 | #cp multi_ceviche_c0.csv multi_ceviche_c0_`date | sed 's/ /_/g'`.csv.back 55 | #fi 56 | #python -m nevergrad.benchmark $task --num_workers=1 2>&1 | tail -n 50 57 | #python -m nevergrad.benchmark $task --num_workers=1 2>&1 | tail -n 50 58 | #python -m nevergrad.benchmark $task --num_workers=1 2>&1 | tail -n 50 59 | #python -m nevergrad.benchmark $task --num_workers=1 2>&1 | tail -n 50 60 | #python -m nevergrad.benchmark $task --num_workers=1 2>&1 | tail -n 50 61 | #if [ $SLURM_ARRAY_TASK_ID -eq 0 ]; then 62 | #cp multi_ceviche_c0.csv multi_ceviche_c0_`date | sed 's/ /_/g'`.csv.back 63 | #fi 64 | #python -m nevergrad.benchmark $task --num_workers=1 2>&1 | tail -n 50 65 | #python -m nevergrad.benchmark $task --num_workers=1 2>&1 | tail -n 50 66 | #python -m nevergrad.benchmark $task --num_workers=1 2>&1 | tail -n 50 67 | #python -m nevergrad.benchmark $task --num_workers=1 2>&1 | tail -n 50 68 | #python -m nevergrad.benchmark $task --num_workers=1 2>&1 | tail -n 50 69 | #python -m nevergrad.benchmark $task --num_workers=1 2>&1 | tail -n 50 70 | echo task over $SLURM_ARRAY_TASK_ID $task 71 | echo Finishing at 72 | date 73 | -------------------------------------------------------------------------------- /scripts/cevicheplots.sh: -------------------------------------------------------------------------------- 1 | cp multi_ceviche.csv multi_ceviche.`date | sed 's/ /_/g'`.csv 2 | sed -i.tmp '/Error/d' ceviche.csv 3 | python -m nevergrad.benchmark.plotting --max_combsize=1 multi_ceviche.csv 4 | python -m nevergrad.benchmark.plotting --max_combsize=1 multi_ceviche_c0.csv 5 | -------------------------------------------------------------------------------- /scripts/check_best_ceviche.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | for k in 0 1 2 3 5 | do 6 | echo " ============================ $k ========================== " 7 | echo -n $k basic: 8 | ls -ctr pb*.npy | grep -v fie | grep budg | sed 's/_/ /g' | sort -n -r -k 4,4 | sed 's/ /_/g' | grep pb$k | tail -n 1 9 | echo -n $k wstar: 10 | ls -ctr WSpb*.npy |grep -v fie | grep budg | sed 's/_/ /g' | sort -n -r -k 4,4 | sed 's/ /_/g' | grep pb$k | tail -n 1 11 | echo -n $k both : 12 | ls -ctr pb*.npy WSpb*.npy |grep -v fie | grep budg | sed 's/_/ /g' | sort -n -r -k 4,4 | sed 's/ /_/g' | grep pb$k | tail -n 1 13 | 14 | done 15 | 16 | -------------------------------------------------------------------------------- /scripts/compare.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | for f in rnk*.txt 5 | do 6 | number=` egrep -i " ${1:-NGOpt} | ${2:-LogNormalDiscreteOnePlusOne} | ${4:-dsvkjnvkfdsjnvs} | ${3:-dsvnskdjvnfknsd} " $f | wc -l` 7 | best=` egrep -i " ${1:-NGOpt} | ${2:-LognormalDiscreteOnePlusOne} | ${4:-dsvkjnvkfdsjnvs} | ${3:-dsvnskdjvnfknsd} " $f | head -n 1` 8 | if [ $number -eq "2" ] 9 | then 10 | echo $f : $best 11 | fi 12 | done 13 | -------------------------------------------------------------------------------- /scripts/create_overview.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | for v in *_plots/ 5 | do 6 | u=`echo $v | sed 's/_plots\///g'` 7 | echo "================= ${u}" 8 | 9 | if [ ! -f scripts/txt/${u}.txt ] 10 | then 11 | echo Creating scripts/txt/${u}.txt 12 | ( 13 | echo $u | sed 's/_plots.*//g' 14 | ls ${v}/fight_*.png | grep -v ',' | grep -v fight_all | grep pure | sed 's/.*fight_//g' | sed 's/.png_pure.png//g' 15 | ) > scripts/txt/${u}.txt 16 | else 17 | ls -ctrl scripts/txt/${u}.txt 18 | fi 19 | done 20 | -------------------------------------------------------------------------------- /scripts/createbestof.sh: -------------------------------------------------------------------------------- 1 | for u in *plots/*cp.txt 2 | do 3 | echo "$u" | sed 's/.*_plots/algos["&/g' | sed 's/_plots.*/"]=[/g' 4 | head -n 7 $u | sed 's/.*://g' | sed 's/(.*//g' | sed 's/ //g' | sort | uniq | sed 's/TransitionChoice$//g' | sed 's/Choice$//g' | sed 's/Softmax$//g' | grep '[A-Za-z]' | sed 's/.*/ "&",/g' 5 | echo " ]" 6 | done 7 | -------------------------------------------------------------------------------- /scripts/findbuggylineincsvfile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | bignum=`cat ${1:-multi_ceviche_c0.csv} | wc -l ` 5 | 6 | lownum=2 7 | 8 | while [ 2 -lt $(( $bignum - $lownum )) ] 9 | do 10 | echo LOG: now $lownum $bignum 11 | num=$(( ( $bignum + $lownum ) / 2 )) 12 | touch zorgluboid.csv 13 | rm zorgluboid.csv 14 | touch zorgluboid_plots 15 | rm -rf zorgluboid_plots 16 | head -n $num ${1:-multi_ceviche_c0.csv} > zorgluboid.csv 17 | 18 | python -m nevergrad.benchmark.plotting zorgluboid.csv 19 | 20 | if [ -f zorgluboid_plots/xpresults_all.png ]; then 21 | echo LOG: ok at length $num 22 | lownum=$(( ( $bignum + $lownum ) / 2 )) 23 | else 24 | echo LOG: fail at length $num 25 | bignum=$(( ( $bignum + $lownum ) / 2 )) 26 | fi 27 | done 28 | -------------------------------------------------------------------------------- /scripts/get_statistics.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pbs=`ls rnk*.txt | sed 's/rnk__//g' | sed 's/_plots.*//g'` 4 | 5 | ( 6 | echo '\begin{tabular}{|p{2cm}|c|c|c|}' 7 | echo '\hline' 8 | echo 'Best algorithm & Problem name & Dimension & Budget \\' 9 | echo '\hline' 10 | 11 | for pb in $pbs 12 | do 13 | 14 | dim=$( ls -ctr ${pb}_plots/fig*dim*.png | grep -v ',' | grep pure | grep -v block | grep -v usefu | sed 's/.*dimension//g' | sed 's/.png.*//g' | awk '{ sum += $1 } END {print sum/NR}' ) 15 | 16 | budget=$( ls -ctr ${pb}_plots/fig*budg*.png | grep -v ',' | sed 's/.*budget//g' | grep pure | sed 's/.png.*//g' | awk '{ sum += $1 } END { print(sum/NR) }' ) 17 | echo GO $pb $dim $budget $( grep algo rnk__${pb}_plots.cp.txt | grep ':' | head -n 1 | sed 's/.*: //g' | sed 's/ (.*//g' ) 18 | done 2>&1 | grep '^GO' | sed 's/^GO //g' | grep ' .* .* ' | sort -k 4,4 | awk ' { if ( $4 != last ) { print "\\hline " ; print $4, "&", $1, "&", $2, "&", $3, "\\\\"; last=$4 } else {print "&", $1, "&", $2, "&", $3, "\\\\" } }' | sed 's/_/ /g' 19 | echo '\hline' 20 | echo '\end{tabular}' 21 | ) > agtable.tex 22 | -------------------------------------------------------------------------------- /scripts/multirank.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo DEPRECATED 4 | 5 | exit 1 6 | 7 | ( 8 | echo 'import matplotlib' 9 | echo 'import matplotlib.pyplot as plt' 10 | 11 | #for k in rnk*.txt 12 | #do 13 | #echo -n "# $k :" 14 | #grep ':' $k | sed 's/.*://g' | sed 's/ (.*//g' | egrep '[a-zA-Z0-9]' | sort | uniq | wc -l 15 | # 16 | #done 17 | 18 | for ag in yes no 19 | do 20 | for num in 1 2 4 8 21 | do 22 | echo "num=$num" 23 | echo "numt=$( ls rnk* | wc -l )" 24 | echo "title=f'How many times in the {num} best ? out of {numt}'" 25 | echo 'plt.clf()' 26 | echo "labels = []" 27 | echo "numbers = []" 28 | echo "# $num best" 29 | for a in RandomSearch AXP Cobyla PCABO SMAC3 NgIohTuned PymooBIPOP CMA PSO SQOPSO DE DiscreteLenglerOnePlusOne DiscreteOnePlusOne OnePlusOne DSproba MetaModel LognormalDiscreteOnePlusOne 30 | 31 | do 32 | echo -n "# $a is in the $num best in this number of problems:" 33 | number=$( 34 | for k in rnk*.txt 35 | do 36 | if [ "$ag" == yes ]; then 37 | grep ':' $k | grep -v ' AX ' | sed 's/.*://g' | sed 's/ (.*//g' | egrep '[a-zA-Z0-9]' | egrep -v ' NgIohTuned | NGDSRW | AX | SMAC3 | LognormalDiscreteOnePlusOne | PCABO | PSO | PymooBIPOP | CMA ' | head -n $num | grep "^ $a$" 38 | else 39 | grep ':' $k | grep -v ' AX ' | grep -v ' NGDSRW ' | sed 's/.*://g' | sed 's/ (.*//g' | egrep '[a-zA-Z0-9]' | head -n $num | grep "^ $a$" 40 | fi 41 | done | wc -l ) 42 | echo $number 43 | if [ "$ag" == yes ]; then 44 | echo "labels += [\" $a \" + '(' + str( $number ) + ')' ];numbers += [ $number + .2 ]" | egrep -v ' NgIohTuned | NGDSRW | AX | SMAC3 | PCABO | PSO | PymooBIPOP | CMA | LognormalDiscreteOnePlusOne ' 45 | else 46 | echo "labels += [\" $a \" + '(' + str( $number ) + ')' ];numbers += [ $number + .2 ]" 47 | fi 48 | done 49 | echo "plt.pie(numbers, labels=labels)" 50 | echo "plt.title(title)" 51 | if [ "$ag" == yes ]; then 52 | echo "plt.savefig(f'agpie{num}.png')" 53 | else 54 | echo "plt.savefig(f'pie{num}.png')" 55 | fi 56 | done 57 | done 58 | ) > plotpie.py 59 | 60 | python plotpie.py 61 | #sed -i 's/label.* AX .*//g' plotpie.py 62 | #sed -i 's/label.* PSO .*//g' plotpie.py 63 | #sed -i 's/label.* PymooBIPOP .*//g' plotpie.py 64 | #sed -i 's/label.* CMA .*//g' plotpie.py 65 | #sed -i 's/pie{num}/agpie{num}/g' plotpie.py 66 | # 67 | #python plotpie.py 68 | -------------------------------------------------------------------------------- /scripts/multirank_robust.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo DEPRECATED 4 | 5 | exit 1 6 | ( 7 | echo 'import matplotlib' 8 | echo 'import matplotlib.pyplot as plt' 9 | 10 | #for k in rnk*.txt 11 | #do 12 | #echo -n "# $k :" 13 | #grep ':' $k | sed 's/.*://g' | sed 's/ (.*//g' | egrep '[a-zA-Z0-9]' | sort | uniq | wc -l 14 | # 15 | #done 16 | 17 | for ag in yes no 18 | do 19 | for num in 1 2 4 8 20 | do 21 | echo "num=$num" 22 | echo "numt=$( ls */*.cp.txt | wc -l )" 23 | echo "title=f'How many times in the {num} best ? out of {numt}'" 24 | echo 'plt.clf()' 25 | echo "labels = []" 26 | echo "numbers = []" 27 | echo "# $num best" 28 | for a in RandomSearch AXP Cobyla PCABO SMAC3 NgIohTuned PymooBIPOP CMA PSO SQOPSO DE DiscreteLenglerOnePlusOne DiscreteOnePlusOne OnePlusOne DSproba MetaModel LognormalDiscreteOnePlusOne 29 | do 30 | echo -n "# $a is in the $num best in this number of problems:" 31 | number=$( 32 | for k in */*.cp.txt 33 | do 34 | if [ "$ag" == yes ]; then 35 | grep ':' $k | grep -v ' AX ' | sed 's/.*://g' | sed 's/ (.*//g' | egrep '[a-zA-Z0-9]' | egrep -v ' NgIohTuned | NGDSRW | AX | SMAC3 | LognormalDiscreteOnePlusOne | PCABO | PSO | PymooBIPOP | CMA ' | head -n $num | grep "^ $a$" 36 | else 37 | grep ':' $k | grep -v ' AX ' | grep -v 'NGDSRW ' | sed 's/.*://g' | sed 's/ (.*//g' | egrep '[a-zA-Z0-9]' | head -n $num | grep "^ $a$" 38 | fi 39 | done | wc -l ) 40 | echo $number 41 | if [ "$ag" == yes ]; then 42 | echo "labels += [\" $a \" + '(' + str( $number ) + ')' ];numbers += [ $number + .2 ]" | egrep -v ' NgIohTuned | NGDSRW | AX | SMAC3 | PCABO | PSO | PymooBIPOP | CMA | LognormalDiscreteOnePlusOne ' 43 | else 44 | echo "labels += [\" $a \" + '(' + str( $number ) + ')' ];numbers += [ $number + .2 ]" 45 | fi 46 | done 47 | echo "plt.pie(numbers, labels=labels)" 48 | echo "plt.title(title)" 49 | if [ "$ag" == "yes" ]; then 50 | echo "plt.savefig(f'agpierob{num}.png')" 51 | else 52 | echo "plt.savefig(f'pierob{num}.png')" 53 | fi 54 | done 55 | done 56 | ) > plotpie.py 57 | 58 | python plotpie.py 59 | #sed -i 's/label.* AX .*//g' plotpie.py 60 | #sed -i 's/label.* PSO .*//g' plotpie.py 61 | #sed -i 's/label.* PymooBIPOP .*//g' plotpie.py 62 | #sed -i 's/label.* CMA .*//g' plotpie.py 63 | #sed -i 's/pie{num}/agpie{num}/g' plotpie.py 64 | # 65 | #python plotpie.py 66 | -------------------------------------------------------------------------------- /scripts/othercompare.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | for f in *plots/*.cp.txt 5 | do 6 | number=` egrep -i " ${1:-NGOpt} | ${2:-CSEC10} | ${4:-dsvkjnvkfdsjnvs} | ${3:-dsvnskdjvnfknsd} " $f | wc -l` 7 | best=` egrep -i " ${1:-NGOpt} | ${2:-CSEC10} | ${4:-dsvkjnvkfdsjnvs} | ${3:-dsvnskdjvnfknsd} " $f | head -n 1` 8 | if [ $number -eq "2" ] 9 | then 10 | echo $f : $best 11 | fi 12 | done 13 | -------------------------------------------------------------------------------- /scripts/overfit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #SBATCH --job-name=overfit 3 | #SBATCH --output=overfit_%A_%a.out 4 | #SBATCH --error=overfit_%A_%a.err 5 | #SBATCH --time=72:00:00 6 | #SBATCH --mem=64g 7 | #SBATCH --partition=scavenge 8 | #SBATCH --nodes=1 9 | #SBATCH --cpus-per-task=70 10 | #SBATCH -a 0-100 11 | 12 | 13 | 14 | python examples/overfit.py 2>&1 | tail -n 40 15 | -------------------------------------------------------------------------------- /scripts/plot_dagstuhloid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #SBATCH --job-name=dagplot 3 | #SBATCH --output=dagplot.out 4 | #SBATCH --error=dagplot.err 5 | #SBATCH --time=72:00:00 6 | #SBATCH --partition=devlab 7 | #SBATCH --nodes=1 8 | #SBATCH --cpus-per-task=67 9 | 10 | 11 | 12 | # This script works both as a standalone script or with slurm. 13 | # This is much slower than mini_plot_dagstuhloid, but outputs more data (in particular: competence maps and plots for 14 | # subcases). 15 | # This plots the results which are stored in the CSV files. 16 | 17 | # Do nothing if there is no CSV. 18 | if compgen -G "*.csv" > /dev/null; then 19 | 20 | # First we run all nevergrad plotting. 21 | for i in `ls *.csv ` 22 | do 23 | #python -m nevergrad.benchmark.plotting --nomanyxp=1 $i & 24 | (python -m nevergrad.benchmark.plotting --nomanyxp=1 $i ; python -m nevergrad.benchmark.plotting --max_combsize=2 --competencemaps=1 --nomanyxp=1 $i ) & 25 | 26 | done 27 | wait 28 | 29 | # ./scripts/multirank.sh 30 | # ./scripts/multirank_robust.sh 31 | ./scripts/pies_multirank.sh 32 | ./scripts/get_statistics.sh 33 | 34 | # Second we do pdflatex 35 | for i in *.csv 36 | do 37 | pushd `echo $i | sed 's/\.csv/_plots/g'` 38 | if compgen -G "comp*.tex" > /dev/null; then 39 | for t in comp*.tex 40 | do 41 | pdflatex $t & 42 | done 43 | fi # end of "there are competence map files" 44 | popd 45 | done 46 | wait 47 | 48 | fi # End of "there is something to do". 49 | 50 | # tar -zcvf ~/dag.tgz *_plots 51 | scripts/latexize.sh 52 | 53 | tar -zcvf dagstuhloid.tgz dagstuhloid.pdf *.csv *plots/xpresults_all.png rnk_*.txt *plots/fight_all.png.cp.txt *pie*.png 54 | 55 | 56 | -------------------------------------------------------------------------------- /scripts/plot_post_ceviche.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pbs="` cat cheat.txt | awk '{print $1}' | sort | uniq `" 4 | 5 | for pb in $pbs 6 | do 7 | ( 8 | echo 'import matplotlib' 9 | echo 'import matplotlib.pyplot as plt' 10 | echo 'data={}' 11 | echo 'datacheat={}' 12 | grep $pb nocheat.txt | sort -n -k 2,2 | awk '{ print "data[",$2,"]=",$3 }' 13 | grep $pb cheat.txt | sort -n -k 2,2 | awk '{ print "datacheat[",$2,"]=",$3 }' 14 | echo 'x = sorted(data.keys())' 15 | echo 'y = [data[x_] for x_ in x]' 16 | echo 'plt.semilogx(x, y, label="' $pb '")' | sed 's/ //g' 17 | echo 'x = sorted(datacheat.keys())' 18 | echo 'y = [datacheat[x_] for x_ in x]' 19 | echo 'plt.semilogx(x, y, label="' $pb '-cheat")' | sed 's/ //g' 20 | echo 'plt.legend()' 21 | echo 'plt.savefig("' $pb '"+".png")' | sed 's/ //g' 22 | echo 'plt.savefig("' $pb '"+".svg")' | sed 's/ //g' 23 | ) > plotter.py 24 | python plotter.py 25 | 26 | done 27 | 28 | ( 29 | echo "import matplotlib" 30 | echo "import matplotlib.pyplot as plt" ) > plothisto.py 31 | for pb in 0 1 2 3 32 | do 33 | ( 34 | echo "x=[]" 35 | echo "y=[]" ) >> plothisto.py 36 | ls -ctr pb${pb}*.png | grep -i c0c | sed 's/_/ /g' | awk '{print $5, $6}' | sed 's/fl//g' | sort -n -r | awk '{ print "x+=[", $1,"];y+=[",$2,"]" }' >> plothisto.py 37 | 38 | ( 39 | echo "plt.loglog(x,y,'*-',label=\"pb$pb\")" 40 | ) >> plothisto.py 41 | done 42 | ( 43 | echo "plt.legend()" 44 | echo "plt.savefig('histo.png')" 45 | ) >>plothisto.py 46 | python plothisto.py 47 | 48 | -------------------------------------------------------------------------------- /scripts/regularized_ceviche.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #SBATCH --job-name=regceviche 3 | #SBATCH --output=regceviche_%A_%a.out 4 | #SBATCH --error=regceviche_%A_%a.err 5 | #SBATCH --time=72:00:00 6 | #SBATCH --partition=scavenge 7 | #SBATCH --nodes=1 8 | #SBATCH --cpus-per-task=70 9 | #SBATCH -a 0-50%330 10 | 11 | #reg=reg0001 12 | reg=reg10000 13 | 14 | # All suffixes below are possibilities: 15 | # multi_ceviche_c0_reg0001 16 | # multi_ceviche_c0_reg001 17 | # multi_ceviche_c0_reg01 18 | # multi_ceviche_c0_reg10 19 | # multi_ceviche_c0_regm1000 20 | # multi_ceviche_c0_reg1000 21 | # multi_ceviche_c0_reg 22 | # multi_ceviche_c0_wsreg0001 23 | # multi_ceviche_c0_wsreg001 24 | # multi_ceviche_c0_wsreg01 25 | # multi_ceviche_c0_wsreg10 26 | # multi_ceviche_c0_wsreg1000 27 | # multi_ceviche_c0_wsregm1000 28 | # multi_ceviche_c0_wsreg 29 | 30 | if [ $SLURM_ARRAY_TASK_ID -eq 0 ]; then 31 | cp multi_ceviche_c0_$reg.csv multi_ceviche_c0_${reg}_`date | sed 's/ /_/g'`.csv.back 32 | fi 33 | 34 | 35 | task=multi_ceviche_c0_$reg 36 | task=multi_ceviche_c0p 37 | 38 | echo task attribution $SLURM_ARRAY_TASK_ID $task 39 | echo Keras/TF versions: 40 | pip show keras tensorflow tensorflow-estimator 41 | 42 | conda info 43 | 44 | echo Starting at 45 | date 46 | # num_workers is the number of processes. Maybe use a bit more than the number of cores at the line "cpus-per-task" 47 | # above. 48 | time python -m nevergrad.benchmark $task --num_workers=1 2>&1 | cut -c1-180 | egrep '[A-Zf-z]' 49 | echo task over $SLURM_ARRAY_TASK_ID $task 50 | echo Finishing at 51 | date 52 | -------------------------------------------------------------------------------- /scripts/tex/end.tex: -------------------------------------------------------------------------------- 1 | 2 | 3 | \section{Global pies} 4 | 5 | \subsection{Including all} 6 | \includegraphics[width=.48\textwidth]{pierob1.png} 7 | \includegraphics[width=.48\textwidth]{pierob3.png} 8 | \subsection{No NgIohTuned, no NGDSRW, only one per category} 9 | \includegraphics[width=.48\textwidth]{pierob1.png} 10 | \includegraphics[width=.48\textwidth]{pierob3.png} 11 | 12 | 13 | \section{Comparison with baseline} 14 | \subsection{Comparison for the normalized simple regret} 15 | \input{compa.tex} 16 | \subsection{Comparison for the frequency of outperforming other algorithms} 17 | \input{compa2.tex} 18 | 19 | \section*{Acknowledgements} 20 | We are very grateful to the Dagstuhl seminar 23251 (June 2023).%, and more specifically to 21 | 22 | % TODO done in discussions with with Diederick, Carola 23 | \bibliographystyle{abbrv} 24 | \bibliography{biblio.bib} 25 | \end{document} 26 | -------------------------------------------------------------------------------- /scripts/txt/aquacrop_fao.txt: -------------------------------------------------------------------------------- 1 | Optimization of crop management. 2 | 3 | 4 | 5 | budget100 6 | budget1600 7 | budget200 8 | budget25 9 | budget400 10 | budget50 11 | budget800 12 | dimension3 13 | dimension4 14 | dimension5 15 | dimension6 16 | seasonal151.5011255099332 17 | seasonal201.9534568704581 18 | seasonal201.95345687045815 19 | seasonal342.54932781948395 20 | seasonal444.02554299755485 21 | smts3 22 | smts4 23 | smts5 24 | smts6 25 | workers1 26 | workers30 27 | -------------------------------------------------------------------------------- /scripts/txt/bonnans.txt: -------------------------------------------------------------------------------- 1 | Function proposed by Frederic Bonnans. 2 | Discrete optimization. New in the field of black-box optimization. 3 | 4 | 5 | budget100 6 | budget20 7 | budget30 8 | budget40 9 | budget50 10 | budget60 11 | budget70 12 | budget80 13 | budget90 14 | index0 15 | index1 16 | index10 17 | index11 18 | index12 19 | index13 20 | index14 21 | index15 22 | index16 23 | index17 24 | index18 25 | index19 26 | index2 27 | index20 28 | index3 29 | index4 30 | index5 31 | index6 32 | index7 33 | index8 34 | index9 35 | -------------------------------------------------------------------------------- /scripts/txt/deceptive.txt: -------------------------------------------------------------------------------- 1 | Difficult functions with multimodalities, high conditionning, etc. 2 | 3 | 4 | aggregatormax 5 | aggregatorsum 6 | blocks1 7 | blocks16 8 | blocks2 9 | blocks8 10 | budget100 11 | budget1600 12 | budget200 13 | budget25 14 | budget37 15 | budget400 16 | budget50 17 | budget75 18 | budget800 19 | budget87 20 | dimension16 21 | dimension2 22 | dimension32 23 | dimension4 24 | dimensions16 25 | dimensions2 26 | dimensions32 27 | dimensions4 28 | namedeceptiveillcond 29 | namedeceptivemultimodal 30 | namedeceptivepath 31 | rotationFalse 32 | rotationTrue 33 | -------------------------------------------------------------------------------- /scripts/txt/double_o_seven.txt: -------------------------------------------------------------------------------- 1 | Game strategy optimization. Noisy. 2 | 3 | 4 | archiDenseNet 5 | archiPerceptron 6 | budget100 7 | budget1000 8 | budget10000 9 | budget200 10 | budget2000 11 | budget20000 12 | budget400 13 | budget4000 14 | budget40000 15 | budget50 16 | budget500 17 | budget5000 18 | dimension15 19 | dimension675 20 | repetitions1 21 | repetitions10 22 | repetitions100 23 | workers1 24 | workers10 25 | workers100 26 | -------------------------------------------------------------------------------- /scripts/txt/fishing.txt: -------------------------------------------------------------------------------- 1 | Optimization of a strategy in front of Lotka-Volterra equations. 2 | 3 | budget100 4 | budget1600 5 | budget200 6 | budget25 7 | budget400 8 | budget50 9 | budget800 10 | dimension105 11 | dimension17 12 | dimension35 13 | dimension52 14 | dimension70 15 | dimension88 16 | time105 17 | time17 18 | time35 19 | time52 20 | time70 21 | time88 22 | -------------------------------------------------------------------------------- /scripts/txt/instrum_discrete.txt: -------------------------------------------------------------------------------- 1 | instrum discrete 2 | arity2 3 | arity3 4 | arity30 5 | arity7 6 | budget50 7 | budget500 8 | budget5000 9 | num workers1 10 | num workers10 11 | nv10 12 | nv1000 13 | nv200 14 | nv50 15 | nv5000 16 | -------------------------------------------------------------------------------- /scripts/txt/keras_tuning.txt: -------------------------------------------------------------------------------- 1 | Tuning of machine learning models based on the Keras library. 2 | 3 | budget150 4 | budget500 5 | datasetauto-mpg 6 | datasetdiabetes 7 | datasetkerasBoston 8 | datasetred-wine 9 | datasetwhite-wine 10 | workers150 11 | workers500 12 | -------------------------------------------------------------------------------- /scripts/txt/lsgo.txt: -------------------------------------------------------------------------------- 1 | lsgo 2 | budget120000 3 | budget3000000 4 | budget600000 5 | dimension1000 6 | dimension905 7 | nameConflictingSchwefel 8 | nameOverlappingSchwefel 9 | namePartiallySeparableAckley 10 | namePartiallySeparableAckley2 11 | namePartiallySeparableElliptic 12 | namePartiallySeparableElliptic2 13 | namePartiallySeparableRastrigin 14 | namePartiallySeparableRastrigin2 15 | namePartiallySeparableSchwefel 16 | namePartiallySeparableSchwefel2 17 | nameShiftedAckley 18 | nameShiftedElliptic 19 | nameShiftedRastrigin 20 | nameShiftedRosenbrock 21 | nameShiftedSchwefel 22 | -------------------------------------------------------------------------------- /scripts/txt/mldakmeans.txt: -------------------------------------------------------------------------------- 1 | Kmeans, part of the MLDA benchmark. 2 | 3 | 4 | budget1000 5 | budget10000 6 | clusters10 7 | clusters100 8 | clusters5 9 | clusters50 10 | dimension10 11 | dimension100 12 | dimension30 13 | dimension300 14 | nameGerman towns 15 | nameRuspini 16 | rescaleFalse 17 | rescaleTrue 18 | workers1 19 | workers10 20 | workers100 21 | -------------------------------------------------------------------------------- /scripts/txt/mltuning.txt: -------------------------------------------------------------------------------- 1 | Tuning of scikit learn models. Hyperparameters. 2 | 3 | budget150 4 | budget500 5 | datasetartificial 6 | datasetartificialcos 7 | datasetartificialsquare 8 | datasetauto-mpg 9 | datasetboston 10 | datasetdiabetes 11 | datasetred-wine 12 | datasetwhite-wine 13 | depth 14 | dimension1 15 | dimension11 16 | dimension2 17 | dimension3 18 | dimension5 19 | dimensionnan 20 | regressormlp 21 | tree 22 | workers150 23 | workers500 24 | -------------------------------------------------------------------------------- /scripts/txt/mono_rocket.txt: -------------------------------------------------------------------------------- 1 | Rocket parametrization, optimized sequentially. 2 | 3 | budget100 4 | budget1600 5 | budget200 6 | budget25 7 | budget400 8 | budget50 9 | budget800 10 | symmetry0 11 | symmetry1 12 | symmetry10 13 | symmetry11 14 | symmetry12 15 | symmetry13 16 | symmetry14 17 | symmetry15 18 | symmetry16 19 | symmetry2 20 | symmetry3 21 | symmetry4 22 | symmetry5 23 | symmetry6 24 | symmetry7 25 | symmetry8 26 | symmetry9 27 | -------------------------------------------------------------------------------- /scripts/txt/ms_bbob.txt: -------------------------------------------------------------------------------- 1 | ms bbob 2 | block dimension10 3 | block dimension2 4 | block dimension20 5 | block dimension3 6 | block dimension5 7 | budget100 8 | budget1600 9 | budget200 10 | budget3200 11 | budget400 12 | budget800 13 | dimension10 14 | dimension2 15 | dimension20 16 | dimension3 17 | dimension5 18 | expo1 19 | expo5 20 | namecigar 21 | namerastrigin 22 | namesphere 23 | translation factor0.01 24 | translation factor0.1 25 | translation factor1.0 26 | translation factor10.0 27 | useful dimensions10 28 | useful dimensions2 29 | useful dimensions20 30 | useful dimensions3 31 | useful dimensions5 32 | zero penFalse 33 | zero pennan 34 | -------------------------------------------------------------------------------- /scripts/txt/multimodal.txt: -------------------------------------------------------------------------------- 1 | Multimodal artificial problems. 2 | 3 | budget10000 4 | budget100000 5 | budget3000 6 | budget30000 7 | dimension150 8 | dimension18 9 | dimension25 10 | dimension3 11 | dimensions25 12 | dimensions3 13 | nameackley 14 | namedeceptivemultimodal 15 | namegriewank 16 | namehm 17 | namelunacek 18 | namerastrigin 19 | namerosenbrock 20 | variables0 21 | variables125 22 | variables15 23 | -------------------------------------------------------------------------------- /scripts/txt/multiobjective_example.txt: -------------------------------------------------------------------------------- 1 | Multiobjective artificial benchmark. 2 | 3 | budget100 4 | budget1600 5 | budget200 6 | budget3200 7 | budget400 8 | budget800 9 | dimension6 10 | dimension7 11 | objectives2 12 | objectives3 13 | workers1 14 | workers100 15 | -------------------------------------------------------------------------------- /scripts/txt/multiobjective_example_hd.txt: -------------------------------------------------------------------------------- 1 | High-dimensional multiobjective problem. 2 | 3 | budget100 4 | budget1600 5 | budget200 6 | budget3200 7 | budget400 8 | budget800 9 | dimension1999 10 | dimension2000 11 | objectives2 12 | objectives3 13 | workers1 14 | workers100 15 | -------------------------------------------------------------------------------- /scripts/txt/multiobjective_example_many_hd.txt: -------------------------------------------------------------------------------- 1 | Many-Objective High-dimensional optimization. 2 | 3 | budget100 4 | budget1600 5 | budget200 6 | budget3200 7 | budget400 8 | budget800 9 | dimension1999 10 | dimension2000 11 | objectives4 12 | objectives6 13 | workers1 14 | workers100 15 | -------------------------------------------------------------------------------- /scripts/txt/naive_seq_keras_tuning.txt: -------------------------------------------------------------------------------- 1 | Keras tuning, but not very parallel and without overfitting. 2 | 3 | budget150 4 | budget500 5 | datasetauto-mpg 6 | datasetdiabetes 7 | datasetkerasBoston 8 | datasetred-wine 9 | datasetwhite-wine 10 | workers1 11 | workers125 12 | workers37 13 | -------------------------------------------------------------------------------- /scripts/txt/naive_seq_mltuning.txt: -------------------------------------------------------------------------------- 1 | Hyperparameter tuning but without overfitting the scikit learn models, hence the naming "naive". 2 | Corresponds to a case with sufficiently large datasets for not caring about overfitting. 3 | 4 | budget150 5 | budget500 6 | datasetartificial 7 | datasetartificialcos 8 | datasetartificialsquare 9 | datasetauto-mpg 10 | datasetboston 11 | datasetdiabetes 12 | datasetred-wine 13 | datasetwhite-wine 14 | depth 15 | dimension1 16 | dimension11 17 | dimension2 18 | dimension3 19 | dimension5 20 | dimensionnan 21 | regressormlp 22 | tree 23 | workers1 24 | workers125 25 | workers37 26 | -------------------------------------------------------------------------------- /scripts/txt/naive_veryseq_keras_tuning.txt: -------------------------------------------------------------------------------- 1 | Completely sequential hyperparameter optimization of Keras model without overfitting. 2 | 3 | budget150 4 | budget500 5 | datasetauto-mpg 6 | datasetdiabetes 7 | datasetkerasBoston 8 | datasetred-wine 9 | datasetwhite-wine 10 | -------------------------------------------------------------------------------- /scripts/txt/naivemltuning.txt: -------------------------------------------------------------------------------- 1 | Tuning of scikit learn models, without overfitting. 2 | 3 | budget150 4 | budget500 5 | datasetartificial 6 | datasetartificialcos 7 | datasetartificialsquare 8 | datasetauto-mpg 9 | datasetboston 10 | datasetdiabetes 11 | datasetred-wine 12 | datasetwhite-wine 13 | depth 14 | dimension1 15 | dimension11 16 | dimension2 17 | dimension3 18 | dimension5 19 | dimensionnan 20 | regressormlp 21 | tree 22 | workers150 23 | workers500 24 | -------------------------------------------------------------------------------- /scripts/txt/nano_naive_seq_mltuning.txt: -------------------------------------------------------------------------------- 1 | Small budget, not very parallel, hyperparameter of scikit learn models without overfitting. 2 | 3 | budget160 4 | budget80 5 | datasetartificial 6 | datasetartificialcos 7 | datasetartificialsquare 8 | datasetauto-mpg 9 | datasetboston 10 | datasetdiabetes 11 | datasetred-wine 12 | datasetwhite-wine 13 | depth 14 | dimension1 15 | dimension11 16 | dimension2 17 | dimension3 18 | dimension5 19 | dimensionnan 20 | regressormlp 21 | tree 22 | workers1 23 | workers20 24 | workers40 25 | -------------------------------------------------------------------------------- /scripts/txt/nano_naive_veryseq_mltuning.txt: -------------------------------------------------------------------------------- 1 | Completely sequential hyperparameter optimization of scikit learn models without overfitting (naive). Low budget (nano). 2 | 3 | budget160 4 | budget80 5 | datasetartificial 6 | datasetartificialcos 7 | datasetartificialsquare 8 | datasetauto-mpg 9 | datasetboston 10 | datasetdiabetes 11 | datasetred-wine 12 | datasetwhite-wine 13 | depth 14 | dimension1 15 | dimension11 16 | dimension2 17 | dimension3 18 | dimension5 19 | dimensionnan 20 | regressormlp 21 | tree 22 | -------------------------------------------------------------------------------- /scripts/txt/nano_seq_mltuning.txt: -------------------------------------------------------------------------------- 1 | Low budget, not very parallel, hyperparameter optimization for scikit learn models. 2 | 3 | budget160 4 | budget80 5 | datasetartificial 6 | datasetartificialcos 7 | datasetartificialsquare 8 | datasetauto-mpg 9 | datasetboston 10 | datasetdiabetes 11 | datasetred-wine 12 | datasetwhite-wine 13 | depth 14 | dimension1 15 | dimension11 16 | dimension2 17 | dimension3 18 | dimension5 19 | dimensionnan 20 | regressormlp 21 | tree 22 | workers1 23 | workers20 24 | workers40 25 | -------------------------------------------------------------------------------- /scripts/txt/nano_veryseq_mltuning.txt: -------------------------------------------------------------------------------- 1 | Completely sequential (veryseq) hyperparameter of scikit learn models. Low budget (hence the name nano). 2 | 3 | budget160 4 | budget80 5 | datasetartificial 6 | datasetartificialcos 7 | datasetartificialsquare 8 | datasetauto-mpg 9 | datasetboston 10 | datasetdiabetes 11 | datasetred-wine 12 | datasetwhite-wine 13 | depth 14 | dimension1 15 | dimension11 16 | dimension2 17 | dimension3 18 | dimension5 19 | dimensionnan 20 | regressormlp 21 | tree 22 | -------------------------------------------------------------------------------- /scripts/txt/oneshot_mltuning.txt: -------------------------------------------------------------------------------- 1 | Tuning in a single pass (one-shot) of scikit learn models. 2 | 3 | budget150 4 | budget500 5 | datasetartificial 6 | datasetartificialcos 7 | datasetartificialsquare 8 | datasetauto-mpg 9 | datasetboston 10 | datasetdiabetes 11 | datasetred-wine 12 | datasetwhite-wine 13 | depth 14 | dimension1 15 | dimension11 16 | dimension2 17 | dimension3 18 | dimension5 19 | dimensionnan 20 | regressormlp 21 | tree 22 | workers150 23 | workers500 24 | -------------------------------------------------------------------------------- /scripts/txt/pbbob.txt: -------------------------------------------------------------------------------- 1 | PBBOB, i.e. parametric bbob. 2 | 3 | budget100 4 | budget200 5 | budget300 6 | budget400 7 | budget500 8 | budget600 9 | budget700 10 | budget800 11 | dimension20 12 | dimension40 13 | dimensions20 14 | dimensions40 15 | expo1 16 | expo3 17 | expo5 18 | expo7 19 | expo9 20 | namecigar 21 | namedeceptivemultimodal 22 | namehm 23 | namerastrigin 24 | namesphere 25 | workers1 26 | workers10 27 | workers50 28 | -------------------------------------------------------------------------------- /scripts/txt/pbo_reduced_suite.txt: -------------------------------------------------------------------------------- 1 | PBO, a subset. This comes from IOH. The functions are defined on various domains and the variables have two possible 2 | values. 3 | 4 | budget100 5 | budget1000 6 | budget10000 7 | dim100 8 | dim16 9 | dim64 10 | fid10 11 | fid13 12 | fid16 13 | fid17 14 | fid19 15 | fid20 16 | fid23 17 | fid3 18 | fid4 19 | fid6 20 | fid7 21 | iid1 22 | iid2 23 | iid3 24 | iid4 25 | instrumentationOrdered 26 | instrumentationSoftmax 27 | instrumentationUnordered 28 | workers1 29 | workers10 30 | -------------------------------------------------------------------------------- /scripts/txt/powersystems.txt: -------------------------------------------------------------------------------- 1 | powersystems 2 | budget12800 3 | budget3200 4 | budget6400 5 | dimension1806 6 | dimension3150 7 | dimension6174 8 | dimension9646 9 | num dams13 10 | num dams3 11 | num dams5 12 | num dams9 13 | num workers1 14 | num workers10 15 | num workers100 16 | -------------------------------------------------------------------------------- /scripts/txt/ranknoisy.txt: -------------------------------------------------------------------------------- 1 | ranknoisy 2 | block dimension200 3 | block dimension2000 4 | block dimension20000 5 | budget100000 6 | budget25000 7 | budget50000 8 | dimension200 9 | dimension2000 10 | dimension20000 11 | namealtcigar 12 | namealtellipsoid 13 | namecigar 14 | nameellipsoid 15 | noise dissymmetryFalse 16 | noise dissymmetryTrue 17 | useful dimensions200 18 | useful dimensions2000 19 | useful dimensions20000 20 | -------------------------------------------------------------------------------- /scripts/txt/reduced_yahdlbbbob.txt: -------------------------------------------------------------------------------- 1 | High-dimensional variant of YABBOB, reduced set of problems. 2 | 3 | budget10 4 | budget20 5 | budget40 6 | dimension100 7 | dimension1000 8 | dimension3000 9 | dimensions100 10 | dimensions1000 11 | dimensions3000 12 | namedeceptiveillcond 13 | namediscus 14 | nameellipsoid 15 | namegriewank 16 | namehm 17 | namelunacek 18 | namemultipeak 19 | namestepdoublelinearslope 20 | rotationFalse 21 | rotationTrue 22 | -------------------------------------------------------------------------------- /scripts/txt/rocket.txt: -------------------------------------------------------------------------------- 1 | Optimization of the design of a rocket. 2 | 3 | budget100 4 | budget1600 5 | budget200 6 | budget25 7 | budget400 8 | budget50 9 | budget800 10 | symmetry0 11 | symmetry1 12 | symmetry10 13 | symmetry11 14 | symmetry12 15 | symmetry13 16 | symmetry14 17 | symmetry15 18 | symmetry16 19 | symmetry2 20 | symmetry3 21 | symmetry4 22 | symmetry5 23 | symmetry6 24 | symmetry7 25 | symmetry8 26 | symmetry9 27 | -------------------------------------------------------------------------------- /scripts/txt/seq_keras_tuning.txt: -------------------------------------------------------------------------------- 1 | Not very parallel hyperparameter optimization of the hyperparameters of Keras models. 2 | 3 | budget150 4 | budget500 5 | datasetauto-mpg 6 | datasetdiabetes 7 | datasetkerasBoston 8 | datasetred-wine 9 | datasetwhite-wine 10 | workers1 11 | workers125 12 | workers37 13 | -------------------------------------------------------------------------------- /scripts/txt/seq_mltuning.txt: -------------------------------------------------------------------------------- 1 | Not very parallel (seq) optimization of scikit learn models. 2 | 3 | budget150 4 | budget500 5 | datasetartificial 6 | datasetartificialcos 7 | datasetartificialsquare 8 | datasetauto-mpg 9 | datasetboston 10 | datasetdiabetes 11 | datasetred-wine 12 | datasetwhite-wine 13 | depth 14 | dimension1 15 | dimension11 16 | dimension2 17 | dimension3 18 | dimension5 19 | dimensionnan 20 | regressormlp 21 | tree 22 | workers1 23 | workers125 24 | workers37 25 | -------------------------------------------------------------------------------- /scripts/txt/sequential_instrum_discrete.txt: -------------------------------------------------------------------------------- 1 | sequential instrum discrete 2 | arity2 3 | arity3 4 | arity30 5 | arity7 6 | budget50 7 | budget500 8 | budget5000 9 | budget50000 10 | nv10 11 | nv1000 12 | nv200 13 | nv50 14 | nv5000 15 | -------------------------------------------------------------------------------- /scripts/txt/sequential_topology_optimization.txt: -------------------------------------------------------------------------------- 1 | Topology optimization, sequential. 2 | 3 | budget10 4 | budget10240 5 | budget1280 6 | budget160 7 | budget20 8 | budget20480 9 | budget2560 10 | budget320 11 | budget40 12 | budget40960 13 | budget5120 14 | budget640 15 | budget80 16 | dimension100 17 | dimension1600 18 | dimension400 19 | dimension900 20 | n10 21 | n20 22 | n30 23 | n40 24 | parametrizationarray10x10 25 | parametrizationarray20x20 26 | parametrizationarray30x30 27 | parametrizationarray40x40 28 | workers1 29 | workers30 30 | -------------------------------------------------------------------------------- /scripts/txt/spsa_benchmark.txt: -------------------------------------------------------------------------------- 1 | Noisy optimization benchmark originally used for testing SPSA. 2 | 3 | budget1000 4 | budget128000 5 | budget16000 6 | budget2000 7 | budget32000 8 | budget4000 9 | budget500 10 | budget64000 11 | budget8000 12 | namecigar 13 | namesphere 14 | namesphere4 15 | rotationFalse 16 | rotationTrue 17 | -------------------------------------------------------------------------------- /scripts/txt/topology_optimization.txt: -------------------------------------------------------------------------------- 1 | Topology optimization. 2 | 3 | budget10 4 | budget10240 5 | budget1280 6 | budget160 7 | budget20 8 | budget20480 9 | budget2560 10 | budget320 11 | budget40 12 | budget40960 13 | budget5120 14 | budget640 15 | budget80 16 | dimension100 17 | dimension1600 18 | dimension400 19 | dimension900 20 | n10 21 | n20 22 | n30 23 | n40 24 | parametrizationarray10x10 25 | parametrizationarray20x20 26 | parametrizationarray30x30 27 | parametrizationarray40x40 28 | workers1 29 | workers30 30 | -------------------------------------------------------------------------------- /scripts/txt/ultrasmall_photonics.txt: -------------------------------------------------------------------------------- 1 | Ultrasmall optimization of photonics. Shape optimization, nanometric scale. 2 | 3 | budget10 4 | budget100 5 | budget1000 6 | methodclipping 7 | methodtanh 8 | -------------------------------------------------------------------------------- /scripts/txt/ultrasmall_photonics2.txt: -------------------------------------------------------------------------------- 1 | Very small benchmark for photonics, 2nd category of parametrizations. 2 | 3 | budget10 4 | budget100 5 | budget1000 6 | methodclipping 7 | methodtanh 8 | -------------------------------------------------------------------------------- /scripts/txt/veryseq_keras_tuning.txt: -------------------------------------------------------------------------------- 1 | Completely sequential optimization of the hyperparameters of Keras models. 2 | 3 | budget150 4 | budget500 5 | datasetauto-mpg 6 | datasetdiabetes 7 | datasetkerasBoston 8 | datasetred-wine 9 | datasetwhite-wine 10 | -------------------------------------------------------------------------------- /scripts/txt/verysmall_photonics.txt: -------------------------------------------------------------------------------- 1 | verysmall photonics 2 | bounding methodclipping 3 | bounding methodtanh 4 | budget10 5 | budget100 6 | budget1000 7 | namecf photosic realistic 8 | namecf photosic reference 9 | -------------------------------------------------------------------------------- /scripts/txt/verysmall_photonics2.txt: -------------------------------------------------------------------------------- 1 | verysmall photonics2 2 | -------------------------------------------------------------------------------- /scripts/txt/yabbob.txt: -------------------------------------------------------------------------------- 1 | YABBOB: a small-dimensional benchmark with large budget, similar to BBOB/COCO, 2 | 3 | budget12800 4 | budget200 5 | budget3200 6 | budget50 7 | budget800 8 | dimension10 9 | dimension2 10 | dimension50 11 | dimensions10 12 | dimensions2 13 | dimensions50 14 | nameackley 15 | namealtcigar 16 | namealtellipsoid 17 | namebentcigar 18 | namebucherastrigin 19 | namecigar 20 | namedeceptiveillcond 21 | namedeceptivemultimodal 22 | namedeceptivepath 23 | namediscus 24 | namedoublelinearslope 25 | nameellipsoid 26 | namegriewank 27 | namehm 28 | namelunacek 29 | namemultipeak 30 | namerastrigin 31 | namerosenbrock 32 | namesphere 33 | namestepdoublelinearslope 34 | namestepellipsoid 35 | rotationFalse 36 | rotationTrue 37 | -------------------------------------------------------------------------------- /scripts/txt/yabigbbob.txt: -------------------------------------------------------------------------------- 1 | Counterpart of YABBOB with big budget. 2 | 3 | budget160000 4 | budget320000 5 | budget40000 6 | budget80000 7 | dimension10 8 | dimension2 9 | dimension50 10 | dimensions10 11 | dimensions2 12 | dimensions50 13 | nameackley 14 | namealtcigar 15 | namealtellipsoid 16 | namebentcigar 17 | namebucherastrigin 18 | namecigar 19 | namedeceptiveillcond 20 | namedeceptivemultimodal 21 | namedeceptivepath 22 | namediscus 23 | namedoublelinearslope 24 | nameellipsoid 25 | namegriewank 26 | namehm 27 | namelunacek 28 | namemultipeak 29 | namerastrigin 30 | namerosenbrock 31 | namesphere 32 | namestepdoublelinearslope 33 | namestepellipsoid 34 | rotationFalse 35 | rotationTrue 36 | -------------------------------------------------------------------------------- /scripts/txt/yaboundedbbob.txt: -------------------------------------------------------------------------------- 1 | Counterpart of BBOB with a bounded domain. 2 | 3 | budget10 4 | budget100 5 | budget20 6 | budget300 7 | budget40 8 | nameackley 9 | namealtcigar 10 | namealtellipsoid 11 | namebentcigar 12 | namebucherastrigin 13 | namecigar 14 | namedeceptiveillcond 15 | namedeceptivemultimodal 16 | namedeceptivepath 17 | namediscus 18 | namedoublelinearslope 19 | nameellipsoid 20 | namegriewank 21 | namehm 22 | namelunacek 23 | namemultipeak 24 | namerastrigin 25 | namerosenbrock 26 | namesphere 27 | namestepdoublelinearslope 28 | namestepellipsoid 29 | rotationFalse 30 | rotationTrue 31 | -------------------------------------------------------------------------------- /scripts/txt/yaboxbbob.txt: -------------------------------------------------------------------------------- 1 | Counterpart of BBOB with a bounded domain (bounds are different from those of YABOXBBOB). 2 | 3 | budget12800 4 | budget200 5 | budget3200 6 | budget50 7 | budget800 8 | dimension10 9 | dimension2 10 | dimension50 11 | dimensions10 12 | dimensions2 13 | dimensions50 14 | nameackley 15 | namealtcigar 16 | namealtellipsoid 17 | namebentcigar 18 | namebucherastrigin 19 | namecigar 20 | namedeceptiveillcond 21 | namedeceptivemultimodal 22 | namedeceptivepath 23 | namediscus 24 | namedoublelinearslope 25 | nameellipsoid 26 | namegriewank 27 | namehm 28 | namelunacek 29 | namemultipeak 30 | namerastrigin 31 | namerosenbrock 32 | namesphere 33 | namestepdoublelinearslope 34 | namestepellipsoid 35 | rotationFalse 36 | rotationTrue 37 | -------------------------------------------------------------------------------- /scripts/txt/yahdbbob.txt: -------------------------------------------------------------------------------- 1 | HD counterpart of YABBOB. 2 | 3 | budget12800 4 | budget200 5 | budget3200 6 | budget50 7 | budget800 8 | dimension100 9 | dimension1000 10 | dimension3000 11 | dimensions100 12 | dimensions1000 13 | dimensions3000 14 | nameackley 15 | namealtcigar 16 | namealtellipsoid 17 | namebentcigar 18 | namebucherastrigin 19 | namecigar 20 | namedeceptiveillcond 21 | namedeceptivemultimodal 22 | namedeceptivepath 23 | namediscus 24 | namedoublelinearslope 25 | nameellipsoid 26 | namegriewank 27 | namehm 28 | namelunacek 29 | namemultipeak 30 | namerastrigin 31 | namerosenbrock 32 | namesphere 33 | namestepdoublelinearslope 34 | namestepellipsoid 35 | rotationFalse 36 | rotationTrue 37 | -------------------------------------------------------------------------------- /scripts/txt/yamegapenbbob.txt: -------------------------------------------------------------------------------- 1 | Counterpart of YABBOB with a lot of constraints. 2 | 3 | budget12800 4 | budget200 5 | budget3200 6 | budget50 7 | budget800 8 | dimension10 9 | dimension2 10 | dimension50 11 | dimensions10 12 | dimensions2 13 | dimensions50 14 | nameackley 15 | namealtcigar 16 | namealtellipsoid 17 | namebentcigar 18 | namebucherastrigin 19 | namecigar 20 | namedeceptiveillcond 21 | namedeceptivemultimodal 22 | namedeceptivepath 23 | namediscus 24 | namedoublelinearslope 25 | nameellipsoid 26 | namegriewank 27 | namehm 28 | namelunacek 29 | namemultipeak 30 | namerastrigin 31 | namerosenbrock 32 | namesphere 33 | namestepdoublelinearslope 34 | namestepellipsoid 35 | rotationFalse 36 | rotationTrue 37 | -------------------------------------------------------------------------------- /scripts/txt/yamegapenbigbbob.txt: -------------------------------------------------------------------------------- 1 | yamegapenbigbbob 2 | block dimension10 3 | block dimension2 4 | block dimension50 5 | budget160000 6 | budget320000 7 | budget40000 8 | budget80000 9 | dimension10 10 | dimension2 11 | dimension50 12 | nameackley 13 | namealtcigar 14 | namealtellipsoid 15 | namebentcigar 16 | namebucherastrigin 17 | namecigar 18 | namedeceptiveillcond 19 | namedeceptivemultimodal 20 | namedeceptivepath 21 | namediscus 22 | namedoublelinearslope 23 | nameellipsoid 24 | namegriewank 25 | namehm 26 | namelunacek 27 | namemultipeak 28 | namerastrigin 29 | namerosenbrock 30 | namesphere 31 | namestepdoublelinearslope 32 | namestepellipsoid 33 | rotationFalse 34 | rotationTrue 35 | useful dimensions10 36 | useful dimensions2 37 | useful dimensions50 38 | -------------------------------------------------------------------------------- /scripts/txt/yamegapenboundedbbob.txt: -------------------------------------------------------------------------------- 1 | Counterpart of YABOUNDEDBBOB (bounded, therefore) with a lot of constraints. 2 | 3 | budget10 4 | budget100 5 | budget20 6 | budget300 7 | budget40 8 | nameackley 9 | namealtcigar 10 | namealtellipsoid 11 | namebentcigar 12 | namebucherastrigin 13 | namecigar 14 | namedeceptiveillcond 15 | namedeceptivemultimodal 16 | namedeceptivepath 17 | namediscus 18 | namedoublelinearslope 19 | nameellipsoid 20 | namegriewank 21 | namehm 22 | namelunacek 23 | namemultipeak 24 | namerastrigin 25 | namerosenbrock 26 | namesphere 27 | namestepdoublelinearslope 28 | namestepellipsoid 29 | rotationFalse 30 | rotationTrue 31 | -------------------------------------------------------------------------------- /scripts/txt/yamegapenboxbbob.txt: -------------------------------------------------------------------------------- 1 | Counterpart of YABOXBBOB (bounded, therefore) with a lot of constraints. 2 | 3 | budget12800 4 | budget200 5 | budget3200 6 | budget50 7 | budget800 8 | dimension10 9 | dimension2 10 | dimension50 11 | dimensions10 12 | dimensions2 13 | dimensions50 14 | nameackley 15 | namealtcigar 16 | namealtellipsoid 17 | namebentcigar 18 | namebucherastrigin 19 | namecigar 20 | namedeceptiveillcond 21 | namedeceptivemultimodal 22 | namedeceptivepath 23 | namediscus 24 | namedoublelinearslope 25 | nameellipsoid 26 | namegriewank 27 | namehm 28 | namelunacek 29 | namemultipeak 30 | namerastrigin 31 | namerosenbrock 32 | namesphere 33 | namestepdoublelinearslope 34 | namestepellipsoid 35 | rotationFalse 36 | rotationTrue 37 | -------------------------------------------------------------------------------- /scripts/txt/yamegapenhdbbob.txt: -------------------------------------------------------------------------------- 1 | yamegapenhdbbob 2 | block dimension100 3 | block dimension1000 4 | block dimension3000 5 | budget12800 6 | budget200 7 | budget3200 8 | budget50 9 | budget800 10 | dimension100 11 | dimension1000 12 | dimension3000 13 | nameackley 14 | namealtcigar 15 | namealtellipsoid 16 | namebentcigar 17 | namebucherastrigin 18 | namecigar 19 | namedeceptiveillcond 20 | namedeceptivemultimodal 21 | namedeceptivepath 22 | namediscus 23 | namedoublelinearslope 24 | nameellipsoid 25 | namegriewank 26 | namehm 27 | namelunacek 28 | namemultipeak 29 | namerastrigin 30 | namerosenbrock 31 | namesphere 32 | namestepdoublelinearslope 33 | namestepellipsoid 34 | rotationFalse 35 | rotationTrue 36 | useful dimensions100 37 | useful dimensions1000 38 | useful dimensions3000 39 | -------------------------------------------------------------------------------- /scripts/txt/yanoisybbob.txt: -------------------------------------------------------------------------------- 1 | Noisy optimization counterpart of YABBOB. 2 | The implementation with ask/tell/recommend is supposed to be correct, which is not the case in all noisy optimization 3 | benchmarks. 4 | 5 | budget12800 6 | budget3200 7 | budget51200 8 | dimension10 9 | dimension2 10 | dimension50 11 | dimensions10 12 | dimensions2 13 | dimensions50 14 | nameackley 15 | namealtcigar 16 | namealtellipsoid 17 | namebentcigar 18 | namebucherastrigin 19 | namecigar 20 | namedeceptiveillcond 21 | namedeceptivemultimodal 22 | namedeceptivepath 23 | namediscus 24 | namedoublelinearslope 25 | nameellipsoid 26 | namegriewank 27 | namehm 28 | namelunacek 29 | namemultipeak 30 | namerastrigin 31 | namerosenbrock 32 | namesphere 33 | namestepdoublelinearslope 34 | namestepellipsoid 35 | rotationFalse 36 | rotationTrue 37 | -------------------------------------------------------------------------------- /scripts/txt/yaonepenbbob.txt: -------------------------------------------------------------------------------- 1 | Counterpart of YABBOB with a single constraint. 2 | 3 | budget12800 4 | budget200 5 | budget3200 6 | budget50 7 | budget800 8 | dimension10 9 | dimension2 10 | dimension50 11 | dimensions10 12 | dimensions2 13 | dimensions50 14 | nameackley 15 | namealtcigar 16 | namealtellipsoid 17 | namebentcigar 18 | namebucherastrigin 19 | namecigar 20 | namedeceptiveillcond 21 | namedeceptivemultimodal 22 | namedeceptivepath 23 | namediscus 24 | namedoublelinearslope 25 | nameellipsoid 26 | namegriewank 27 | namehm 28 | namelunacek 29 | namemultipeak 30 | namerastrigin 31 | namerosenbrock 32 | namesphere 33 | namestepdoublelinearslope 34 | namestepellipsoid 35 | rotationFalse 36 | rotationTrue 37 | -------------------------------------------------------------------------------- /scripts/txt/yaonepenbigbbob.txt: -------------------------------------------------------------------------------- 1 | yaonepenbigbbob 2 | block dimension10 3 | block dimension2 4 | block dimension50 5 | budget160000 6 | budget320000 7 | budget40000 8 | budget80000 9 | dimension10 10 | dimension2 11 | dimension50 12 | nameackley 13 | namealtcigar 14 | namealtellipsoid 15 | namebentcigar 16 | namebucherastrigin 17 | namecigar 18 | namedeceptiveillcond 19 | namedeceptivemultimodal 20 | namedeceptivepath 21 | namediscus 22 | namedoublelinearslope 23 | nameellipsoid 24 | namegriewank 25 | namehm 26 | namelunacek 27 | namemultipeak 28 | namerastrigin 29 | namerosenbrock 30 | namesphere 31 | namestepdoublelinearslope 32 | namestepellipsoid 33 | rotationFalse 34 | rotationTrue 35 | useful dimensions10 36 | useful dimensions2 37 | useful dimensions50 38 | -------------------------------------------------------------------------------- /scripts/txt/yaonepenboundedbbob.txt: -------------------------------------------------------------------------------- 1 | Counterpart of YABOUNDEDBBOB with a single constraint. 2 | 3 | budget10 4 | budget100 5 | budget20 6 | budget300 7 | budget40 8 | nameackley 9 | namealtcigar 10 | namealtellipsoid 11 | namebentcigar 12 | namebucherastrigin 13 | namecigar 14 | namedeceptiveillcond 15 | namedeceptivemultimodal 16 | namedeceptivepath 17 | namediscus 18 | namedoublelinearslope 19 | nameellipsoid 20 | namegriewank 21 | namehm 22 | namelunacek 23 | namemultipeak 24 | namerastrigin 25 | namerosenbrock 26 | namesphere 27 | namestepdoublelinearslope 28 | namestepellipsoid 29 | rotationFalse 30 | rotationTrue 31 | -------------------------------------------------------------------------------- /scripts/txt/yaonepenboxbbob.txt: -------------------------------------------------------------------------------- 1 | Counterpart of YABOXBBOB with a single constraint. 2 | 3 | budget12800 4 | budget200 5 | budget3200 6 | budget50 7 | budget800 8 | dimension10 9 | dimension2 10 | dimension50 11 | dimensions10 12 | dimensions2 13 | dimensions50 14 | nameackley 15 | namealtcigar 16 | namealtellipsoid 17 | namebentcigar 18 | namebucherastrigin 19 | namecigar 20 | namedeceptiveillcond 21 | namedeceptivemultimodal 22 | namedeceptivepath 23 | namediscus 24 | namedoublelinearslope 25 | nameellipsoid 26 | namegriewank 27 | namehm 28 | namelunacek 29 | namemultipeak 30 | namerastrigin 31 | namerosenbrock 32 | namesphere 33 | namestepdoublelinearslope 34 | namestepellipsoid 35 | rotationFalse 36 | rotationTrue 37 | -------------------------------------------------------------------------------- /scripts/txt/yaonepennoisybbob.txt: -------------------------------------------------------------------------------- 1 | Counterpart of YANOISYBBOB with one constraint. 2 | 3 | budget12800 4 | budget3200 5 | dimension10 6 | dimension2 7 | dimension50 8 | dimensions10 9 | dimensions2 10 | dimensions50 11 | nameackley 12 | namealtcigar 13 | namealtellipsoid 14 | namebentcigar 15 | namebucherastrigin 16 | namecigar 17 | namedeceptiveillcond 18 | namedeceptivemultimodal 19 | namedeceptivepath 20 | namediscus 21 | namedoublelinearslope 22 | nameellipsoid 23 | namegriewank 24 | namehm 25 | namelunacek 26 | namemultipeak 27 | namerastrigin 28 | namerosenbrock 29 | namesphere 30 | namestepdoublelinearslope 31 | namestepellipsoid 32 | rotationFalse 33 | rotationTrue 34 | -------------------------------------------------------------------------------- /scripts/txt/yaonepenparabbob.txt: -------------------------------------------------------------------------------- 1 | Counterpart of YAPARABBOB (parallel optimization for YABBOB) with a single constraint. 2 | 3 | budget12800 4 | budget200 5 | budget3200 6 | budget50 7 | budget800 8 | dimension10 9 | dimension2 10 | dimension50 11 | dimensions10 12 | dimensions2 13 | dimensions50 14 | nameackley 15 | namealtcigar 16 | namealtellipsoid 17 | namebentcigar 18 | namebucherastrigin 19 | namecigar 20 | namedeceptiveillcond 21 | namedeceptivemultimodal 22 | namedeceptivepath 23 | namediscus 24 | namedoublelinearslope 25 | nameellipsoid 26 | namegriewank 27 | namehm 28 | namelunacek 29 | namemultipeak 30 | namerastrigin 31 | namerosenbrock 32 | namesphere 33 | namestepdoublelinearslope 34 | namestepellipsoid 35 | rotationFalse 36 | rotationTrue 37 | -------------------------------------------------------------------------------- /scripts/txt/yaonepensmallbbob.txt: -------------------------------------------------------------------------------- 1 | Single constraint on YASMALLBBOB. 2 | 3 | budget10 4 | budget20 5 | budget40 6 | dimension10 7 | dimension2 8 | dimension50 9 | dimensions10 10 | dimensions2 11 | dimensions50 12 | nameackley 13 | namealtcigar 14 | namealtellipsoid 15 | namebentcigar 16 | namebucherastrigin 17 | namecigar 18 | namedeceptiveillcond 19 | namedeceptivemultimodal 20 | namedeceptivepath 21 | namediscus 22 | namedoublelinearslope 23 | nameellipsoid 24 | namegriewank 25 | namehm 26 | namelunacek 27 | namemultipeak 28 | namerastrigin 29 | namerosenbrock 30 | namesphere 31 | namestepdoublelinearslope 32 | namestepellipsoid 33 | rotationFalse 34 | rotationTrue 35 | -------------------------------------------------------------------------------- /scripts/txt/yaparabbob.txt: -------------------------------------------------------------------------------- 1 | Counterpart of YABBOB with parallel optimization. 2 | 3 | budget12800 4 | budget200 5 | budget3200 6 | budget50 7 | budget800 8 | dimension10 9 | dimension2 10 | dimension50 11 | dimensions10 12 | dimensions2 13 | dimensions50 14 | nameackley 15 | namealtcigar 16 | namealtellipsoid 17 | namebentcigar 18 | namebucherastrigin 19 | namecigar 20 | namedeceptiveillcond 21 | namedeceptivemultimodal 22 | namedeceptivepath 23 | namediscus 24 | namedoublelinearslope 25 | nameellipsoid 26 | namegriewank 27 | namehm 28 | namelunacek 29 | namemultipeak 30 | namerastrigin 31 | namerosenbrock 32 | namesphere 33 | namestepdoublelinearslope 34 | namestepellipsoid 35 | rotationFalse 36 | rotationTrue 37 | -------------------------------------------------------------------------------- /scripts/txt/yapenbbob.txt: -------------------------------------------------------------------------------- 1 | Counterpart of YABBOB with some constraints. 2 | 3 | budget12800 4 | budget200 5 | budget3200 6 | budget50 7 | budget800 8 | dimension10 9 | dimension2 10 | dimension50 11 | dimensions10 12 | dimensions2 13 | dimensions50 14 | nameackley 15 | namealtcigar 16 | namealtellipsoid 17 | namebentcigar 18 | namebucherastrigin 19 | namecigar 20 | namedeceptiveillcond 21 | namedeceptivemultimodal 22 | namedeceptivepath 23 | namediscus 24 | namedoublelinearslope 25 | nameellipsoid 26 | namegriewank 27 | namehm 28 | namelunacek 29 | namemultipeak 30 | namerastrigin 31 | namerosenbrock 32 | namesphere 33 | namestepdoublelinearslope 34 | namestepellipsoid 35 | rotationFalse 36 | rotationTrue 37 | -------------------------------------------------------------------------------- /scripts/txt/yapenboundedbbob.txt: -------------------------------------------------------------------------------- 1 | Counterpart of YABOUNDEDBBOB with some constraints. 2 | 3 | budget10 4 | budget100 5 | budget20 6 | budget300 7 | budget40 8 | nameackley 9 | namealtcigar 10 | namealtellipsoid 11 | namebentcigar 12 | namebucherastrigin 13 | namecigar 14 | namedeceptiveillcond 15 | namedeceptivemultimodal 16 | namedeceptivepath 17 | namediscus 18 | namedoublelinearslope 19 | nameellipsoid 20 | namegriewank 21 | namehm 22 | namelunacek 23 | namemultipeak 24 | namerastrigin 25 | namerosenbrock 26 | namesphere 27 | namestepdoublelinearslope 28 | namestepellipsoid 29 | rotationFalse 30 | rotationTrue 31 | -------------------------------------------------------------------------------- /scripts/txt/yapenboxbbob.txt: -------------------------------------------------------------------------------- 1 | Counterpart of YABOXBBOB with some constraints. 2 | 3 | budget12800 4 | budget200 5 | budget3200 6 | budget50 7 | budget800 8 | dimension10 9 | dimension2 10 | dimension50 11 | dimensions10 12 | dimensions2 13 | dimensions50 14 | nameackley 15 | namealtcigar 16 | namealtellipsoid 17 | namebentcigar 18 | namebucherastrigin 19 | namecigar 20 | namedeceptiveillcond 21 | namedeceptivemultimodal 22 | namedeceptivepath 23 | namediscus 24 | namedoublelinearslope 25 | nameellipsoid 26 | namegriewank 27 | namehm 28 | namelunacek 29 | namemultipeak 30 | namerastrigin 31 | namerosenbrock 32 | namesphere 33 | namestepdoublelinearslope 34 | namestepellipsoid 35 | rotationFalse 36 | rotationTrue 37 | -------------------------------------------------------------------------------- /scripts/txt/yapennoisybbob.txt: -------------------------------------------------------------------------------- 1 | Constraints of YANOISYBBOB with some constraints. 2 | 3 | budget12800 4 | budget3200 5 | dimension10 6 | dimension2 7 | dimension50 8 | dimensions10 9 | dimensions2 10 | dimensions50 11 | nameackley 12 | namealtcigar 13 | namealtellipsoid 14 | namebentcigar 15 | namebucherastrigin 16 | namecigar 17 | namedeceptiveillcond 18 | namedeceptivemultimodal 19 | namedeceptivepath 20 | namediscus 21 | namedoublelinearslope 22 | nameellipsoid 23 | namegriewank 24 | namehm 25 | namelunacek 26 | namemultipeak 27 | namerastrigin 28 | namerosenbrock 29 | namesphere 30 | namestepdoublelinearslope 31 | namestepellipsoid 32 | rotationFalse 33 | rotationTrue 34 | -------------------------------------------------------------------------------- /scripts/txt/yapenparabbob.txt: -------------------------------------------------------------------------------- 1 | Counterpart of YAPARABBOB with some constraints. 2 | 3 | budget12800 4 | budget200 5 | budget3200 6 | budget50 7 | budget800 8 | dimension10 9 | dimension2 10 | dimension50 11 | dimensions10 12 | dimensions2 13 | dimensions50 14 | nameackley 15 | namealtcigar 16 | namealtellipsoid 17 | namebentcigar 18 | namebucherastrigin 19 | namecigar 20 | namedeceptiveillcond 21 | namedeceptivemultimodal 22 | namedeceptivepath 23 | namediscus 24 | namedoublelinearslope 25 | nameellipsoid 26 | namegriewank 27 | namehm 28 | namelunacek 29 | namemultipeak 30 | namerastrigin 31 | namerosenbrock 32 | namesphere 33 | namestepdoublelinearslope 34 | namestepellipsoid 35 | rotationFalse 36 | rotationTrue 37 | -------------------------------------------------------------------------------- /scripts/txt/yapensmallbbob.txt: -------------------------------------------------------------------------------- 1 | Penalized counterpart of YASMALLBBOB (i.e. low budget). 2 | 3 | budget10 4 | budget20 5 | budget40 6 | dimension10 7 | dimension2 8 | dimension50 9 | dimensions10 10 | dimensions2 11 | dimensions50 12 | nameackley 13 | namealtcigar 14 | namealtellipsoid 15 | namebentcigar 16 | namebucherastrigin 17 | namecigar 18 | namedeceptiveillcond 19 | namedeceptivemultimodal 20 | namedeceptivepath 21 | namediscus 22 | namedoublelinearslope 23 | nameellipsoid 24 | namegriewank 25 | namehm 26 | namelunacek 27 | namemultipeak 28 | namerastrigin 29 | namerosenbrock 30 | namesphere 31 | namestepdoublelinearslope 32 | namestepellipsoid 33 | rotationFalse 34 | rotationTrue 35 | -------------------------------------------------------------------------------- /scripts/txt/yasmallbbob.txt: -------------------------------------------------------------------------------- 1 | Low budget counterpart of YABBOB. 2 | 3 | budget10 4 | budget20 5 | budget40 6 | dimension10 7 | dimension2 8 | dimension50 9 | dimensions10 10 | dimensions2 11 | dimensions50 12 | nameackley 13 | namealtcigar 14 | namealtellipsoid 15 | namebentcigar 16 | namebucherastrigin 17 | namecigar 18 | namedeceptiveillcond 19 | namedeceptivemultimodal 20 | namedeceptivepath 21 | namediscus 22 | namedoublelinearslope 23 | nameellipsoid 24 | namegriewank 25 | namehm 26 | namelunacek 27 | namemultipeak 28 | namerastrigin 29 | namerosenbrock 30 | namesphere 31 | namestepdoublelinearslope 32 | namestepellipsoid 33 | rotationFalse 34 | rotationTrue 35 | -------------------------------------------------------------------------------- /scripts/txt/yatinybbob.txt: -------------------------------------------------------------------------------- 1 | Counterpart of YABBOB with very low budget. 2 | 3 | budget10 4 | budget20 5 | budget40 6 | dimension10 7 | dimension2 8 | dimension50 9 | dimensions10 10 | dimensions2 11 | dimensions50 12 | nameackley 13 | namealtcigar 14 | namealtellipsoid 15 | namedeceptiveillcond 16 | namedeceptivemultimodal 17 | namedeceptivepath 18 | namediscus 19 | namedoublelinearslope 20 | namegriewank 21 | namehm 22 | namemultipeak 23 | rotationFalse 24 | rotationTrue 25 | -------------------------------------------------------------------------------- /scripts/txt/yatuningbbob.txt: -------------------------------------------------------------------------------- 1 | Counterpart of YABBOB scaled for slightly looking like hyperparameter tuning problems. Only continuous though. 2 | 3 | budget10 4 | budget20 5 | budget40 6 | dimension10 7 | dimension15 8 | dimension2 9 | dimension5 10 | dimensions10 11 | dimensions15 12 | dimensions2 13 | dimensions5 14 | nameackley 15 | namealtcigar 16 | namedeceptiveillcond 17 | namedeceptivemultimodal 18 | namedeceptivepath 19 | namediscus 20 | nameellipsoid 21 | namehm 22 | namemultipeak 23 | namerastrigin 24 | namerosenbrock 25 | namesphere 26 | namestepdoublelinearslope 27 | namestepellipsoid 28 | rotationFalse 29 | rotationTrue 30 | -------------------------------------------------------------------------------- /scripts/txt/zp_ms_bbob.txt: -------------------------------------------------------------------------------- 1 | zp ms bbob 2 | block dimension10 3 | block dimension2 4 | block dimension20 5 | block dimension3 6 | block dimension5 7 | budget100 8 | budget1600 9 | budget200 10 | budget3200 11 | budget400 12 | budget800 13 | dimension10 14 | dimension2 15 | dimension20 16 | dimension3 17 | dimension5 18 | expo1 19 | expo5 20 | namecigar 21 | namerastrigin 22 | namesphere 23 | translation factor0.01 24 | translation factor0.1 25 | translation factor1.0 26 | translation factor10.0 27 | useful dimensions10 28 | useful dimensions2 29 | useful dimensions20 30 | useful dimensions3 31 | useful dimensions5 32 | -------------------------------------------------------------------------------- /scripts/txt/zp_pbbob.txt: -------------------------------------------------------------------------------- 1 | zp pbbob 2 | block dimension20 3 | block dimension40 4 | budget100 5 | budget200 6 | budget300 7 | budget400 8 | budget500 9 | budget600 10 | budget700 11 | budget800 12 | dimension20 13 | dimension40 14 | expo1 15 | expo3 16 | expo5 17 | expo7 18 | expo9 19 | namecigar 20 | namedeceptivemultimodal 21 | namehm 22 | namerastrigin 23 | namesphere 24 | num workers1 25 | num workers10 26 | num workers50 27 | useful dimensions20 28 | useful dimensions40 29 | --------------------------------------------------------------------------------