Compare commits

...

74 commits

Author SHA1 Message Date
Johann Dreo
3259d1b452 doc: bump version + clean authors list 2025-04-16 13:42:29 +02:00
Alessandro Sidero
c660489eaf
Optimize eoRanking: Add caching and index vector (#80)
* Adds eoRankingCached with better documentation
* Optimize eoRanking with caching and index vector
* Adds t-eoRankingCached.cpp
2025-04-15 18:04:35 +02:00
Johann Dreo
400c69c49a doc: mention Apptainer in INSTALL 2025-04-08 19:45:59 +02:00
Johann Dreo
bee47592af doc: adds howto_build_paradiseo script for apptainer 2025-04-07 23:06:52 +02:00
Johann Dreo
e14220ff69 fix(checkpoint): initialize a pointer 2025-04-07 22:57:21 +02:00
Johann Dreo
c218a19de6 fix(doc): disable doc-mpi 2025-04-07 22:56:58 +02:00
Johann Dreo
4b4344664b update(README): link to cmake-gui, citation ref 2025-04-07 14:50:03 +02:00
Johann Dreo
b8efdda6a2 Merge branch 'setup-ccache' of github.com:Jxtopher/nojhan_paradiseo 2025-04-07 14:18:58 +02:00
Johann Dreo
22275e434b fix several warnings
Probably fixes a bug in es/CMA, which has been deprecated for a long time in favor of the EDO module anyway.
2025-04-07 14:16:37 +02:00
Jxtopher
cfcd6e22bb Ccache setup
The goal is to speed up recompilation using ccache.

Ccache is a tool that speeds up recompilation of C/C++ code. It does this by caching the results of previous compilations.
When you recompile code, ccache checks if it has already compiled the same code with the same compiler flags. If so, it uses the cached result instead of recompiling.
2025-04-04 21:59:27 +02:00
48ca0fa5b8 Merge branch 'master' of github.jdreo:jdreo/paradiseo 2025-04-04 21:46:33 +02:00
172798a637 revert 399b22266 (virtual fitness interface temptative)
Incompatible with MOEO's change of interface.
2025-04-04 21:46:04 +02:00
7c88ec4fa7 feat(EO): allow overriding fitness accessors
May be useful for debugging, by tracing when fitness assignement occurs.
2025-04-04 21:45:56 +02:00
aa242bd4d6 Merge tag 'v3.0.0' 2025-04-04 21:23:53 +02:00
3dc2058400
Merge pull request #78 from Alessandro624/fix-mpi-ale
fix(MPI): resolved cyclic inclusion and MPI issue
2025-03-21 09:05:54 +01:00
Alessandro Sidero
77148b5a97 fix(MPI): resolved cyclic inclusion and MPI issue 2025-02-24 19:07:10 +01:00
Johann Dreo
d3a2ab5e84 fix(EDO): constructor declarations without templates 2024-10-03 10:08:00 +02:00
Johann Dreo
190a30495e fix(EO): allow readFrom to work on std::cin + invalidTag
- std::cin does not allow seekg/tellg, so instead one wrap the read string
  in a istringstream, and then read from it.
  This allows to read from any istream, with or without seekg.
- Adds an EO::invalidTag member, in case someone would need to use it
  (for instance as a regexp to sanitize inputs).
2024-09-30 20:42:20 +02:00
Johann Dreo
8ea6e2b680 feat(eo): adds eoRealToIntInit 2024-09-27 12:20:10 +02:00
Johann Dreo
19ec4c4ff7 feat(eo): wrap ops on float vecs into ops on int vecs
Adds wrapper classes to make any MonOp or QuadOp that operates on eoReal embbedable in any operator needing an eoInt.
2024-09-26 13:24:10 +02:00
Johann Dreo
846006c613 feat(moSA): adds a constructor without cool but with cont 2024-09-21 13:53:38 +02:00
Johann Dreo
db24e611b7 refactor(tests): reduce runtime for foundry tests 2024-09-11 11:04:29 +02:00
cf086ea9b9 fix(moBinaryPartition): finalize integration in <mo> 2024-09-10 20:26:36 +02:00
Johann Dreo
e23151d666 feat: prepare the use of binary partitions for signatures 2022-09-12 15:20:05 +02:00
Johann Dreo
b96b537ed1 fix(nbhood): make accessors const 2024-09-10 16:47:28 +02:00
Johann Dreo
a376921f07 add save-sol to output all solutions to a file 2023-03-28 18:58:51 +02:00
Johann Dreo
d64f2b38ed refactor: put cache in lib + clean doc 2023-02-06 23:12:36 +01:00
Johann Dreo
e57b504cd6 refactor(app): usable output 2023-02-03 11:46:17 +01:00
Johann Dreo
79e2c01ca8 refactor(app): separate main exe and datatester
better log
2023-02-03 10:35:10 +01:00
Johann Dreo
df723331be refactor(fitness): store cache with the fitness
to allow rollback with minimal mem footprint
2023-02-02 14:48:02 +01:00
Johann Dreo
237426a6b4 refactor while hunting a bug 2023-01-26 11:48:44 +01:00
Johann Dreo
36fe6e6f7d fix a warning 2023-01-18 11:28:50 +01:00
Johann Dreo
86c750618f more doc 2023-01-18 11:14:13 +01:00
Johann Dreo
bfce997ce8 first part of partial signature evaluation 2022-10-18 11:12:38 +02:00
Johann Dreo
1d640b3251 feat: adds partial eval and tests 2022-10-03 16:11:37 +02:00
Johann Dreo
2accb17599 document everything and remove dead code 2022-09-13 15:25:33 +02:00
Johann Dreo
11f49e58d7 feat: prepare the use of binary partitions for signatures 2022-09-12 15:20:05 +02:00
Johann Dreo
a6a3f799e7 fix(eoParallel): declutch _t_start under _OPENMP 2024-09-10 10:57:50 +02:00
Johann Dreo
df8c457f75 fix(moeoSPEA2Archive): correct members init order 2024-09-10 10:45:18 +02:00
Johann Dreo
867b1c289b fix(eoEvalUserTimeThrowException): preprocessor test for POSIX and UNIX 2024-09-10 10:44:42 +02:00
Johann Dreo
32195a480b fix(selectors): comment out unused variable 2024-09-10 09:26:00 +02:00
Johann Dreo
c23b9c160a fix(selectors): correctly initialize rawTotal 2024-09-10 09:22:16 +02:00
Johann Dreo
1a61cd1f1c fix(eoGnuplot): get rid of warnings about unused variables 2024-09-10 09:21:51 +02:00
Johann Dreo
8dd4f529f2 fix(eoExceptions): do not return a ref from a temp 2024-09-10 09:21:15 +02:00
Johann Dreo
51be7e324b fix(moRndVectorVNSelection): use shuffle for modern compilers 2024-09-05 14:42:40 +02:00
Johann Dreo
732fe097cb fix(doc): use current source dir and not the root one.
Allow Paradiseo to be built as a Git submodule of another project.
2024-09-04 08:55:48 +02:00
Johann Dreo
84148824e0 fix: remove a lot of trivial warnings 2024-08-23 18:00:31 +02:00
Johann Dreo
a16298c58b Merge branch 'master' of https://gitlab.inria.fr/paradiseo/paradiseo 2024-08-23 16:25:23 +02:00
Johann Dreo
332d078902 feat(doc): recent articles first 2024-08-23 16:21:05 +02:00
Johann Dreo
dde057b12b feat(doc): mention partial evaluation for combinatorics 2024-08-23 15:22:17 +02:00
Eremey Valetov
a5d3bf8601 docs: add accelerator physics paper to publications list 2024-08-23 14:55:58 +02:00
Johann Dreo
22b74e9c07 fix(eoEvalFoundryEA): reorder members to avoid warning 2024-08-23 14:53:01 +02:00
Johann Dreo
fefb2af4dd REFACTOR!eoForge*): separate raw pointres from shared ones
- Move the instantiate(double) interfaces of eoForgeVector as instantiate_from.
- Adds two separated sets members for instantiation.

BREAKING CHANGE
2024-08-23 14:53:01 +02:00
Johann Dreo
3cc374ce5c fix(warnings): do not ignore return from system 2024-08-23 14:53:01 +02:00
Johann Dreo
b4e89d8f51 fix(deprecated): guard from bind and *_function
Deprecated since C++11, removed in C++17.
2024-08-23 14:53:01 +02:00
Johann Dreo
09a26fdc62 fix(eoForge): missing header 2024-08-23 14:53:01 +02:00
Johann Dreo
4bbb4a595e fix(mpi): fix some namespaces issues with mpi 2024-08-23 14:53:01 +02:00
Johann Dreo
c442d8a0a2 Revert "fix!(eoBit): defaults to char for scalar type"
This reverts commit 06e0cc0162b6f753d92076c510d7124d82a3def1.
2024-08-23 14:53:01 +02:00
Jxtopher
93e89828b8 Fix CI: random class issue, t-eoRoulette and update the workflow 2024-08-23 14:52:58 +02:00
Johann Dreo
ec1a0f0c62 fix(eoForgeVector): use shared_ptr insteadof raw ones + adds instantiate_ptr interface 2024-08-22 22:21:57 +02:00
Johann Dreo
6f7d505a2a fix(rnd): use STL's rand gen for shuffles
Previous implementation used Paradiseo's own random generator system,
now superseeded by the STL's one.
2024-08-19 11:14:21 +02:00
Johann Dreo
55b2f57d19 fix!(eoBit): defaults to char for scalar type
Since STL's vector of bool is not a vector of bool, `swap`ing bool elements in an eoBit can lead to errors.
Using `char` is a saner default.

Potential BREAKING CHANGE.
2024-08-19 11:13:53 +02:00
e643468de8 revert 399b22266 (virtual fitness interface temptative)
Incompatible with MOEO's change of interface.
2024-04-08 22:20:00 +02:00
f30240cb44 fix(mo): missing include 2024-04-08 22:20:00 +02:00
ff744aea7c fix(eoStandardBitMutation):
- Fix all operators in eoStandardBitMutation.h
- Bitflip componennt was not bound, use explicit assignement of rates.
- Fix normal and fast operators algorithms.

Co-authored-by: Potalas <potalas@free.fr>
2024-04-08 22:20:00 +02:00
9cb60e4b10 refactor(mo): use clog instead of cout & use at accessors in Debug builds
Should really use eo::log, but waiting for logger refactoring.
2024-04-08 22:20:00 +02:00
5a7fdf7ed3 feat(EO): allow overriding fitness accessors
May be useful for debugging, by tracing when fitness assignement occurs.
2024-04-08 22:20:00 +02:00
BertheasLeo
bad5d6cbb8 Update edoEstimatorNormalAdaptive.h
Correction aliasing errror on Eigen
2024-04-08 22:20:00 +02:00
BertheasLeo
5e0e6fcd79 Update eoSIGContinue.h
Correction sighandler is not defined on Windows
2024-04-08 22:20:00 +02:00
843aa6fc37 fix(mo): comment out unused parameters
Removes -Wunused-parameters warnings.
2022-09-10 06:27:46 +02:00
1a980c442d feat: add an eoForgeMap
Same features than an eoForgeVector,
but allowing to bind a string name to the instance.
2022-09-10 06:02:15 +02:00
ff09b4bcc7 fix logo display in readme 2022-09-10 06:02:15 +02:00
AI Xin
1f1f598314 add mo tutorial doc in Markdown format
The original tutorial link[http://paradiseo.gforge.inria.fr/index.php?n=Doc.Tutorials] is broken. I found the archive from here: https://web.archive.org/web/20210119160107/http://paradiseo.gforge.inria.fr/index.php?n=Doc.Tutorials
2022-09-10 06:02:15 +02:00
3b7ffbbfae fix Ubuntu-related memory allocation bug 2022-01-31 20:14:38 +01:00
158 changed files with 2336 additions and 685 deletions

View file

@ -1,10 +1,5 @@
name: Build Debug (Ubuntu)
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
on: [push, pull_request]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
@ -21,8 +16,15 @@ jobs:
compiler: [g++-10, g++-9, g++-8, g++-7, clang-6, clang-7, clang-8, clang-9, clang-10, clang-11, clang-12]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Caching objects
id: cache-objects
uses: actions/cache@v4
with:
path: ~/.cache/ccache
key: ${{ runner.os }}-${{env.BUILD_TYPE}}-${{ matrix.compiler }}-objects
- name: Install Dependencies
shell: bash
run: |

35
AUTHORS
View file

@ -1,41 +1,52 @@
Current maintainers
===================
Arnaud Liefooghe <arnaud.liefooghe@univ-lille1.fr>
Clive Canape <clive.canape@inria.fr>
Johann Dreo <johann@dreo.fr>
Sébastien Verel <sebastien.verel@inria.fr>
Active developpers
==================
Alexandre Quemy <alexandre.quemy@inria.fr>
Benjamin Bouvier <bnjbouv@gmail.com>
Caner Candan <caner@candan.fr>
Pierre Savéant <pierre.saveant@thalesgroup.com>
Johann Dreo <johann@dreo.fr>
Past contributors
=================
atantar
Alesandro Sidero
Alexandre Quemy
Alix Zheng
Amine Aziz-Alaoui
Arnaud Liefooghe
Benjamin Bouvier
Bahri
Caner Candan
Clive Canape
fatene
Gustavo Romero Lopez
jboisson
Jeroen Eggermont
Jochen Küpper
Joost <joost@dsj.nl>
Joost
Juan Julian Merelo Guervos
Jérémie Humeau
Jxtopher
Karima Boufaras
legillon
legillono
Leo Bertheas
Louis Da Costa
Loïc Jean David Arjanen
Maarten Keijzer
Mammar Amara
Manu
Marc Schoenauer
Marie-Éleonore
Mostepha Khouadjia
Olivier König
Pierre Savéant
Pedro Angel Castillo Valdivieso
Potalas
Ronald Pinho
Steve Madere
Sébastien Cahon
Sébastien Verel
Thomas Legrand
Thibault Lasnier
Victor Manuel Rivas Santos
wcancino
xohm

View file

@ -13,13 +13,24 @@ cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
## Name
project("ParadisEO"
VERSION 3.0.0
VERSION 3.1.3
DESCRIPTION "Evolutionary optimization framework"
LANGUAGES C CXX)
## Language
set(CMAKE_CXX_STANDARD 17)
## ccache
find_program(CCACHE_PROGRAM ccache)
if (CCACHE_PROGRAM)
message(NOTICE "-- ccache is enabled (found here: ${CCACHE_PROGRAM})")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "\"${CCACHE_PROGRAM}\"")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "\"${CCACHE_PROGRAM}\"")
else ()
message(NOTICE "-- ccache has not been found")
endif ()
######################################################################################
### 2) Check dependencies
@ -82,7 +93,7 @@ set(MPI "false" CACHE BOOL "Build the MPI module")
## EO Module
set(MODULE_NAME "Paradiseo")
set(DOXYGEN_CONFIG_DIR ${CMAKE_SOURCE_DIR}/doxygen)
set(DOXYGEN_CONFIG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/doxygen)
# set(EO_MODULE_NAME "Evolving Objects")
set(CMAKE_SOURCE_DIR ${EO_SRC_DIR})
add_subdirectory(${EO_SRC_DIR})

View file

@ -2,7 +2,8 @@
Summary
=======
As Paradiseo is a development framework, you do not really need to install it on all your systems. Just put it somewhere on your development computer, compile it from here and indicate where to find it to your favorite build system.
As Paradiseo is a development framework, you do not really need to install it on all your systems.
Just put it somewhere on your development computer, compile it from here and indicate where to find it to your favorite build system.
Build
@ -18,6 +19,11 @@ Paradiseo use the CMake build system, so building it should be as simple as:
mkdir build ; cd build ; cmake -DEDO=ON .. && make -j
```
The file `howto_build_paradiseo.apptainer.def` shows you how to install and build from scratch.
It is a definition file for the [Apptainer](https://apptainer.org/) container system,
which is often used on HPC clusters.
Develop
-------
@ -187,13 +193,13 @@ Examples and lessons are generated when `ENABLE_CMAKE_EXAMPLE` is set.
If you want to build a specific lesson or example, you can check the list of available targets with `make help`.
All lessons are build on the same pattern: `<module>Lesson<number>`.
For instance, make `moLesson4` will build the Lesson 4 from the MO module.
For instance, make `moLesson4` will build the Lesson 4 from the MO module.
Easy, isn't it ?
Tests
-----
By performing tests, you can check your installation.
By performing tests, you can check your installation.
Testing is disable by default, except if you build with the full install type.
To enable testing, define `ENABLE_CMAKE_TESTING` when you run cmake.

View file

@ -168,7 +168,7 @@ It is, for instance, easy to start with a simple local search, then add multi-ob
Paradiseo is mainly developed under Linux operating systems, where its dependencies and the C++ toolchain are easy to install. Recent versions have been tested with gcc and clang compilers.
Stable versions should however work on Windows and any Unix-like operating system with a standard-conforming C++ development system.
Stable versions should however work on Windows and any Unix-like operating system with a standard-conforming C++ development system.
# Code
@ -195,7 +195,7 @@ The build chain uses the classical workflow of CMake. The recommended method is
Under Linux, the default is make, and a build command is straitghtforward: `mkdir build ; cd build ; cmake .. && make -j`.
There is, however, several build options which you may want to switch. To see them, we recommend the use of a CMake gui, like ccmake or cmake-gui . On the command line, you can see the available options with: `cmake -LH ..` . Those options can be set with the `-D<option>=<value>` argument to cmake.
There is, however, several build options which you may want to switch. To see them, we recommend the use of a CMake gui, like ccmake or cmake-gui. On the command line, you can see the available options with: `cmake -LH ..` . Those options can be set with the `-D<option>=<value>` argument to cmake.
**The first option to consider is `CMAKE_BUILD_TYPE`, which you most probably want to set to `Debug` (during development/tests) or `Release` (for production/validation).**
@ -211,6 +211,9 @@ If you `ENABLE_CMAKE_EXAMPLE`, it will also build the examples.
If may want to make build scripts more verbose (especially when building the
doc) by enabling `CMAKE_VERBOSE_MAKEFILE`.
If `ccache` installed in your environment, it will try its best to re-use other compilations,
which may speed-up your builds if you manage several compatible builds at the same time.
To clear all cached objects, execute `ccache -C`.
## Licenses
@ -236,11 +239,35 @@ For academic articles, books, more tutorials, presentations slides,
real life example of solvers and contact information,
please see the web site (available in `paradiseo/website/index.html`).
There is also an [online wiki](https://gitlab.inria.fr/paradiseo/paradiseo/-/wikis/home)
# Citing Paradiseo
If you use Paradiseo, please cite the following publication:
Johann Dreo, Arnaud Liefooghe, Sébastien Verel, Marc Schoenauer, Juan J. Merelo, Alexandre Quemy, Benjamin Bouvier, and Jan Gmys, [Paradiseo: from a modular framework for evolutionary computation to the automated design of metaheuristics —22 years of Paradiseo—](https://doi.org/10.1145/3449726.3463276), GECCO'21: Proceedings of the Genetic and Evolutionary Computation Conference Companion, 15221530 (2021).
BiBTeX entry:
```
@inproceedings{Dreo-al_2021_Paradiseo,
author = {Dreo, Johann and Liefooghe, Arnaud and Verel, S\'{e}bastien and Schoenauer, Marc and Merelo, Juan J. and Quemy, Alexandre and Bouvier, Benjamin and Gmys, Jan},
title = {Paradiseo: From a Modular Framework for Evolutionary Computation to the Automated Design of Metaheuristics: 22 Years of Paradiseo},
year = {2021},
isbn = {9781450383516},
publisher = {Association for Computing Machinery},
address = {Online conference},
url = {https://doi.org/10.1145/3449726.3463276},
booktitle = {Proceedings of the Genetic and Evolutionary Computation Conference Companion},
pages = {15221530},
numpages = {9}
}
```
# Contact
For further information about ParadisEO, help or to report any
problem, you can send an e-mail to: `paradiseo-help@lists.gforge.inria.fr`
problem, you can either:
- Chat with us on our Matrix chatroom: https://app.element.io/#/room/#paradiseo:matrix.org
- Post an issue: https://github.com/nojhan/paradiseo/issues

View file

@ -27,7 +27,7 @@ if(DOXYGEN_FOUND AND DOXYGEN_EXECUTABLE)
# set(DOC_SMP "")
# endif()
# if(MPI)
# set(DOC_MPI "make doc-mpi")
# set(DOC_MPI "make doc-mpi")
# else()
# set(DOC_MPI "")
# endif()
@ -78,7 +78,7 @@ if(DOXYGEN_FOUND AND DOXYGEN_EXECUTABLE)
COMMAND make doc-eo
COMMAND make doc-mo
COMMAND make doc-moeo
COMMAND make doc-mpi
# COMMAND make doc-mpi
)
endif()
@ -89,7 +89,7 @@ if(DOXYGEN_FOUND AND DOXYGEN_EXECUTABLE)
COMMAND make doc-mo
COMMAND make doc-moeo
COMMAND make doc-smp
COMMAND make doc-mpi
# COMMAND make doc-mpi
)
endif()
if(EDO AND NOT SMP AND MPI)
@ -98,7 +98,7 @@ if(DOXYGEN_FOUND AND DOXYGEN_EXECUTABLE)
COMMAND make doc-mo
COMMAND make doc-moeo
COMMAND make doc-edo
COMMAND make doc-mpi
# COMMAND make doc-mpi
)
endif()
if(EDO AND SMP AND NOT MPI)
@ -119,7 +119,7 @@ if(DOXYGEN_FOUND AND DOXYGEN_EXECUTABLE)
COMMAND make doc-moeo
COMMAND make doc-edo
COMMAND make doc-smp
COMMAND make doc-mpi
# COMMAND make doc-mpi
)
endif()
@ -131,7 +131,7 @@ endif(DOXYGEN_FOUND AND DOXYGEN_EXECUTABLE)
######################################################################################
if(PROFILING)
find_program(LCOV
find_program(LCOV
NAMES lcov
PATHS
"/usr/local/bin /usr/bin [HKEY_LOCAL_MACHINE\\SOFTWARE\\Rational Software\\Purify\\Setup;InstallFolder] [HKEY_CURRENT_USER\\Software]"

View file

@ -302,7 +302,7 @@
<div id="Why_efficiency">
<h3>Efficient</h3>
<p class="excerpt"><em class="logo">Paradis<span class="logo_eo">eo</span></em> is <em>the fastest</em> framework on the market, which is a crucial feature for modern and robust approach to solver <em>design and validation</em>.</p>
<p class="excerpt"><em class="logo">Paradis<span class="logo_eo">eo</span></em> is <em>the fastest</em> framework on the market, which is a crucial feature for modern and robust approach to solver <em>design and validation</em> (especially on combinatorial problems).</p>
</div>
<div id="Why_efficiency_details">
@ -311,6 +311,7 @@
<p>Another classical criticism against <em class="logo">Paradis<span class="logo_eo">eo</span></em> is that C++ is hard and that a fast language is useless because speed is not a concern when your objective function is dominating all the runtime.</p>
<p>However, we argue that:
<ul>
<li>The numerical optimization community often sees objective functions as monolithic “black-box”, but in combinatorial opimization, it is very often the case that the objective function can be only partially evaluated on neighbor solutions, which allows for (tremendous) speed gains. The Paradiseo-mo module is architectured around that idea, a feature that is not so often found in other frameworks.</li>
<li>During the design phase of your solver, you will need to estimate its performance against synthetic benchmarks that are fast to compute. In that case, fast computation means fast design iterations. And it's even more true if you plan to use automated design to find the best solver for your problem.</li>
<li>Modern C++ makes use of the very same high-level abstractions you would find in more accepted languages like Python. Sure, the syntax is cumbersome, but you will not see it after a while, given that you will work at the algorithm level.</li>
<li>C++ provides full type checking and the largest set of tooling for any modern language, which are your first line of defense against long-term bugs. Sure, it sometimes gives you the impression that you fight against the compiler, but chasing subtle interface bugs across a complex Python code is even harder.</li>
@ -827,7 +828,7 @@
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#da4939"><b>year</b></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;{2021},<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#da4939"><b>isbn</b></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;{9781450383516},<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#da4939"><b>publisher</b></font>&nbsp;=&nbsp;{Association for Computing Machinery},<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#da4939"><b>address</b></font>&nbsp;&nbsp; =&nbsp;{New York, NY, USA},<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#da4939"><b>address</b></font>&nbsp;&nbsp; =&nbsp;{Online conference},<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#da4939"><b>url</b></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =&nbsp;{<a href="https://doi.org/10.1145/3449726.3463276},">https://doi.org/10.1145/3449726.3463276},</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#da4939"><b>booktitle</b></font>&nbsp;=&nbsp;{Proceedings of the Genetic and Evolutionary Computation Conference Companion},<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#da4939"><b>pages</b></font>&nbsp;&nbsp;&nbsp;&nbsp; =&nbsp;{15221530},<br>
@ -926,10 +927,31 @@ ISBN: 978-0-470-27858-1</blockquote>
<ul class="publications">
</ul>
<h3>Accelerator Physics</h3>
<ul>
<li>E. Valetov, G. Dal Maso, P-R. Kettle, A. Knecht, A. Papa, on behalf of the HIMB Project. <a href="https://doi.org/10.3390/particles7030039">Beamline Optimisation for High-Intensity Muon Beams at PSI Using the Heterogeneous Island Model</a>. <i>Particles</i> (2024), <i>7</i>, 683-691.</li>
</ul>
<h3>Bioinformatics</h3>
<ul>
<li> Emile Zakiev, Johann Dreo, Mara Santarelli, Benno Schwikowski, <a href="https://hal.science/hal-04110700">Statistical Discovery of Transcriptomic Cancer Signatures using Multimodal Local Search</a>, <i>PGMO Days</i> (2022).</li>
</ul>
<h3>Metaheuristics Design</h3>
<ul>
<li>Johann Dreo, Carola Doerr, Amine Aziz-Alaoui, Alix Zheng, <a href="https://hal.science/hal-04110704/document">Using irace, paradiseo and iohprofiler for large-scale algorithm configuration</a>, <i>8th COnfiguration and SElection of ALgorithms (COSEAL) workshop</i> (2021).</li>
<li>Amine Aziz-Alaoui, Carola Doerr, Johann Dreo, <a href="https://arxiv.org/abs/2102.06435">Towards large scale automated algorithm design by integrating modular benchmarking frameworks</a>, <i>Proceedings of the Genetic and Evolutionary Computation Conference Companion</i> (2021).</li>
<li>Johann Dréo, Carola Doerr, Yann Semet, <a href="https://hal.sorbonne-universite.fr/hal-02179604/document">Coupling the design of benchmark with algorithm in landscape-aware solver design</a>, <i>Proceedings of the Genetic and Evolutionary Computation Conference Companion</i> (2019).</li>
<li>Johann Dreo, <a href="https://dl.acm.org/doi/10.1145/1570256.1570301">Using Performance Fronts for Parameter Setting of Stochastic Metaheuristics</a>, <i>Genetic and Evolutionary Computation Conference</i>, (2009).</li>
</ul>
<h3>Automated Planning</h3>
<ul>
<li>Mostepha Redouane Khouadjia, Marc Schoenauer, Vincent Vidal, Johann Dreo, Pierre Savéant, <a href="https://arxiv.org/abs/1305.2265v1">Quality measures of parameter tuning for aggregated multi-objective temporal planning</a>, <i>7th International Conference on Learning and Intelligent Optimization (LION 7)</i> (2013).</li>
<li>Mostepha Redouane Khouadjia, Marc Schoenauer, Vincent Vidal, Johann Dreo, Pierre Savéant, <a href="https://arxiv.org/abs/1305.1169v1">Multi-Objective AI Planning: Comparing Aggregation and Pareto Approaches</a>, <i>Conference on Evolutionary Computation in Combinatorial Optimization (EvoCOP)</i> (2013).</li>
<li>Mostepha Redouane Khouadjia, Marc Schoenauer, Vincent Vidal, Johann Dreo, Pierre Savéant, <a href="https://arxiv.org/abs/1212.5276">Multi-Objective AI Planning: Evaluating DAE-YAHSP on a Tunable Benchmark</a>, <i>7th International Conference on Evolutionary Multi-Criterion Optimization</i> (2013).</li>
<li>Jacques Bibaï, Pierre Savéant, Marc Schoenauer, Vincent Vidal, <a href="http://www.aaai.org/ocs/index.php/ICAPS/ICAPS10/paper/view/1414">An Evolutionary Metaheuristic Based on State Decomposition for Domain-Independent Satisficing Planning</a>, <i>Twentieth International Conference on Automated Planning and Scheduling </i> (2010). <strong>Winner of the International Planning Competition</strong></li>
<li>Jacques Bibaï, Pierre Savéant, Marc Schoenauer, Vincent Vidal, <a href="">An Evolutionary Metaheuristic for Domain-Independent Satisficing Planning</a>, <i>Genetic and Evolutionary Computation Conference</i> (2010). <strong>Silver Medal at the Human-Competitive Competition</strong></li>
<li>Jacques Bibaï, Pierre Savéant, Marc Schoenauer, Vincent Vidal, <a href="">An Evolutionary Metaheuristic for Domain-Independent Satisficing Planning</a>, <i>Genetic and Evolutionary Computation Conference</i> (2010). <strong>Silver Medal at the Human-Competitive Competition</strong></li>
</ul>
@ -993,11 +1015,6 @@ undiscovered knowledge.
physics/0603108 (2006)</a>.</li>
</ul>
<h3>Metaheuristics Design</h3>
<ul>
<li>Johann Dreo, <a href="https://dl.acm.org/doi/10.1145/1570256.1570301">Using Performance Fronts for Parameter Setting of Stochastic Metaheuristics</a>, <i>Genetic and Evolutionary Computation Conference</i>, (2009).</li>
</ul>
</div>
</div>
@ -1152,7 +1169,7 @@ undiscovered knowledge.
<div id="Downloads">
<h2><a name="Downloads"></a>Downloads</h2>
<p>The current stable release is version: <a href="https://github.com/nojhan/paradiseo/releases">Paradiseo 3.0.0-beta</a>. Some other releases (older or newer) can be found on <a href="https://github.com/nojhan/paradiseo/tags">GitHub/paradiseo/releases</a>.</p>
<p>The current stable release is version: <a href="https://github.com/nojhan/paradiseo/releases">Paradiseo 3.1.3</a>. Some other releases (older or newer) can be found on <a href="https://github.com/nojhan/paradiseo/tags">GitHub/paradiseo/releases</a>.</p>
<p> You can obtain the latest stable and beta version directly via the Git repository:
<code class="command">git clone https://github.com/jdreo/paradiseo.git</code>.
@ -1204,7 +1221,7 @@ undiscovered knowledge.
</p>
<p>There is, however, several build options which you may want to switch.
To see them, we recommend the use of a CMake gui, like <code>ccmake</code> or <code>cmake-gui</code>.
To see them, we recommend the use of a CMake gui, like <code>ccmake</code> (available through the <code>cmake-curses-gui</code> package in Debian/Ubuntu) or <a href="https://cmake.org/cmake/help/latest/guide/user-interaction/index.html#cmake-gui-tool">cmake-gui</a>.
On the command line, you can see the available options with: <code class="command">cmake -LH ..</code>.
Those options can be set with the <code>-D&lt;option&gt;=&lt;value&gt;</code> argument to cmake.
</p>

View file

@ -45,7 +45,7 @@ class edoEstimatorAdaptive : public edoEstimator<D>
public:
typedef typename D::EOType EOType;
edoEstimatorAdaptive<D>( D& distrib ) : _distrib(distrib) {}
edoEstimatorAdaptive( D& distrib ) : _distrib(distrib) {}
// virtual D operator() ( eoPop< EOT >& )=0 (provided by eoUF< A1, R >)

View file

@ -41,12 +41,12 @@ class edoEstimatorAdaptiveReset : public edoEstimatorAdaptive<D>
public:
typedef typename D::EOType EOType;
edoEstimatorAdaptiveReset<D>( D& distrib ) :
edoEstimatorAdaptiveReset( D& distrib ) :
edoEstimatorAdaptive<D>(distrib),
_dim(0)
{ }
edoEstimatorAdaptiveReset<D>( D& distrib, size_t dim ) :
edoEstimatorAdaptiveReset( D& distrib, size_t dim ) :
edoEstimatorAdaptive<D>(distrib),
_dim(dim)
{ }

View file

@ -43,12 +43,12 @@ class edoEstimatorCombinedAdaptive : public edoEstimatorAdaptive<D>, public std:
public:
typedef typename D::EOType EOType;
edoEstimatorCombinedAdaptive<D>( D& distrib, edoEstimator<D>& estim) :
edoEstimatorCombinedAdaptive( D& distrib, edoEstimator<D>& estim) :
edoEstimatorAdaptive<D>(distrib),
std::vector<edoEstimator<D>*>(1,&estim)
{}
edoEstimatorCombinedAdaptive<D>( D& distrib, std::vector<edoEstimator<D>*> estims) :
edoEstimatorCombinedAdaptive( D& distrib, std::vector<edoEstimator<D>*> estims) :
edoEstimatorAdaptive<D>(distrib),
std::vector<edoEstimator<D>*>(estims)
{}
@ -78,11 +78,11 @@ class edoEstimatorCombinedStateless : public edoEstimatorCombinedAdaptive<D>
public:
typedef typename D::EOType EOType;
edoEstimatorCombinedStateless<D>( edoEstimator<D>& estim ) :
edoEstimatorCombinedStateless( edoEstimator<D>& estim ) :
edoEstimatorCombinedAdaptive<D>(*(new D), estim)
{}
edoEstimatorCombinedStateless<D>( std::vector<edoEstimator<D>*> estims) :
edoEstimatorCombinedStateless( std::vector<edoEstimator<D>*> estims) :
edoEstimatorCombinedAdaptive<D>(*(new D), estims)
{}

View file

@ -39,7 +39,7 @@ template < typename EOT >
class edoRepairerModulo: public edoRepairerApplyBinary<EOT>
{
public:
edoRepairerModulo<EOT>( double denominator ) : edoRepairerApplyBinary<EOT>( std::fmod, denominator ) {}
edoRepairerModulo( double denominator ) : edoRepairerApplyBinary<EOT>( std::fmod, denominator ) {}
};

View file

@ -76,8 +76,7 @@ edoFileSnapshot::edoFileSnapshot(std::string dirname,
s = " ";
}
int dummy;
dummy = system(s.c_str());
(void)/*ignore returned*/ system(s.c_str());
// all done
_descOfFiles = new std::ofstream( std::string(dirname + "/list_of_files.txt").c_str() );

View file

@ -108,7 +108,12 @@ public:
if (is) {
virus.resize(bits.size());
std::transform(bits.begin(), bits.end(), virus.begin(),
#if __cplusplus >= 201103L
std::bind(std::equal_to<char>(), std::placeholders::_1, '1'));
#else
// Deprecated since C++11.
std::bind2nd(std::equal_to<char>(), '1'));
#endif
}
}

View file

@ -64,6 +64,8 @@ template<class F = double> class EO: public eoObject, public eoPersistent
public:
typedef F Fitness;
static constexpr const char* invalidTag = "INVALID";
/** Default constructor.
*/
EO(): repFitness(Fitness()), invalidFitness(true) { }
@ -124,25 +126,21 @@ public:
* The read and print methods should be compatible and have the same format.
* In principle, format is "plain": they just print a number
* @param _is a std::istream.
* @throw eoInvalidFitnessError If a valid object can't be read.
*/
virtual void readFrom(std::istream& _is) {
// the new version of the reafFrom function.
// It can distinguish between valid and invalid fitness values.
virtual void readFrom(std::istream& _is)
{
std::string fitness_str;
int pos = _is.tellg();
_is >> fitness_str;
if (fitness_str == "INVALID")
if (fitness_str == invalidTag)
{
invalidFitness = true;
}
else
{
invalidFitness = false;
_is.seekg(pos); // rewind
_is >> repFitness;
std::istringstream iss(fitness_str);
iss >> repFitness;
}
}
@ -150,12 +148,11 @@ public:
* Write object. Called printOn since it prints the object _on_ a stream.
* @param _os A std::ostream.
*/
virtual void printOn(std::ostream& _os) const {
// the latest version of the code. Very similar to the old code
if (invalid()) {
_os << "INVALID ";
virtual void printOn(std::ostream& _os) const
{
if (invalid())
{
_os << invalidTag << ' ';
}
else
{

View file

@ -65,7 +65,7 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoValu
#ifndef _MSC_VER
// the CtrlC monitoring interception
eoSignal<EOT> *mon_ctrlCCont;
eoSignal<EOT> *mon_ctrlCCont = nullptr;
eoValueParam<bool>& mon_ctrlCParam = _parser.createParam(false, "monitor-with-CtrlC", "Monitor current generation upon Ctrl C",0, "Stopping criterion");
if (mon_ctrlCParam.value())
{

View file

@ -224,6 +224,11 @@
#include "utils/eoLogger.h"
#include "utils/eoParallel.h"
#include "eoInt.h"
#include "eoRealToIntMonOp.h"
#include "eoRealToIntQuadOp.h"
#include "eoRealToIntInit.h"
#endif
// Local Variables:

View file

@ -174,18 +174,18 @@ protected:
// if the flight does not need to be used, use the dummy flight instance
class eoDummyFlight:public eoFlight < POT >
{
public:
eoDummyFlight () {}
void operator () (POT &) {}
}dummyFlight;
public:
eoDummyFlight () {}
void operator() (POT &) override {}
} dummyFlight;
// if the initializer does not need to be used, use the dummy one instead
class eoDummyInitializer:public eoInitializerBase < POT >
{
public:
eoDummyInitializer () {}
void operator () (POT &) {}
}dummyInit;
public:
eoDummyInitializer () {}
void operator() () override {}
} dummyInit;
};
/**

View file

@ -71,13 +71,6 @@ public:
i_repl(foundry.replacements.index())
{ }
protected:
const size_t i_cont;
const size_t i_cros;
const size_t i_muta;
const size_t i_sele;
const size_t i_repl;
public:
/** Decode the high-level problem encoding as an array of indices.
@ -156,6 +149,13 @@ protected:
eoAlgoFoundryEA<SUB>& _foundry;
const typename EOT::Fitness _penalization;
const size_t _pop_size;
const size_t i_cont;
const size_t i_cros;
const size_t i_muta;
const size_t i_sele;
const size_t i_repl;
};
/** Helper function to instanciate an eoEvalFoundryEA without having to indicate the template for the sub-problem encoding.

View file

@ -21,9 +21,9 @@ Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
*/
#if !defined(__unix__) && !defined(_WINDOWS)
#if !defined(_POSIX_VERSION) && !defined(__unix__) && !defined(_WINDOWS)
#warning "Warning: class 'eoEvalUserTimeThrowException' is only available under UNIX (defining 'rusage' in 'sys/resource.h') or Win32 (defining 'GetProcessTimes' in 'WinBase.h') systems, contributions for other systems are welcomed."
#else //!defined(__unix__) && !defined(_WINDOWS)
#else // defined(_POSIX_VERSION) || defined(__unix__) || defined(_WINDOWS)
#ifndef __EOEVALUSERTIMETHROWEXCEPTION_H__
#define __EOEVALUSERTIMETHROWEXCEPTION_H__
@ -40,7 +40,7 @@ Johann Dréo <johann.dreo@thalesgroup.com>
#include "eoExceptions.h"
#ifdef __unix__
#if defined(_POSIX_VERSION) || defined(__unix__)
#include <sys/time.h>
#include <sys/resource.h>
@ -106,6 +106,6 @@ protected:
};
#endif // _WINDOWS
#endif //__unix__
#endif // defined(_POSIX_VERSION) || defined(__unix__)
#endif // __EOEVALUSERTIMETHROWEXCEPTION_H__
#endif //!defined(__unix__) && !defined(_WINDOWS)
#endif //!defined(_POSIX_VERSION) && !defined(__unix__) && !defined(_WINDOWS)

View file

@ -45,7 +45,7 @@ public:
const char* what() const throw()
{
return message().c_str();
return _msg.c_str();
}
~eoException() throw() {}

View file

@ -27,6 +27,7 @@
#include <string>
#include <tuple>
#include <utility>
#include <memory>
// In case you want to debug arguments captured in tuples:
// template<typename Type, unsigned N, unsigned Last>
@ -74,6 +75,7 @@ class eoForgeInterface
{
public:
virtual Itf& instantiate(bool no_cache = true) = 0;
virtual std::shared_ptr<Itf> instantiate_ptr(bool no_cache = true) = 0;
virtual ~eoForgeInterface() {}
};
@ -112,6 +114,7 @@ class eoForgeOperator : public eoForgeInterface<Itf>
template<class ...Args2>
eoForgeOperator(Args2... args) :
_args(std::forward<Args2>(args)...),
_instantiated_ptr(nullptr),
_instantiated(nullptr)
{ }
@ -123,9 +126,9 @@ class eoForgeOperator : public eoForgeInterface<Itf>
*
* @param no_cache If false, will enable caching previous instances.
*/
Itf& instantiate(bool no_cache = true)
Itf& instantiate(bool no_cache = true) override
{
if(no_cache or not _instantiated) {
if(no_cache or _instantiated == nullptr) {
if(_instantiated) {
delete _instantiated;
}
@ -134,7 +137,19 @@ class eoForgeOperator : public eoForgeInterface<Itf>
return *_instantiated;
}
virtual ~eoForgeOperator()
std::shared_ptr<Itf> instantiate_ptr(bool no_cache = true) override
{
if(no_cache or _instantiated == nullptr) {
// if(_instantiated) {
// delete _instantiated;
// }
_instantiated_ptr = op_constructor_ptr(_args);
// _instantiated = op_constructor(_args);
}
return _instantiated_ptr;
}
virtual ~eoForgeOperator() override
{
delete _instantiated;
}
@ -150,9 +165,16 @@ class eoForgeOperator : public eoForgeInterface<Itf>
// FIXME double-check that the copy-constructor is a good idea to make_from_tuple with dynamic storage duration.
return new Op(std::make_from_tuple<Op>(args));
}
template<class T>
std::shared_ptr<Op> op_constructor_ptr(T& args)
{
return std::make_shared<Op>( std::make_from_tuple<Op>(args) );
}
/** @} */
protected:
std::shared_ptr<Itf> _instantiated_ptr;
Itf* _instantiated;
};
@ -163,12 +185,13 @@ class eoForgeOperator<Itf,Op> : public eoForgeInterface<Itf>
{
public:
eoForgeOperator() :
_instantiated_ptr(nullptr),
_instantiated(nullptr)
{ }
Itf& instantiate( bool no_cache = true )
Itf& instantiate( bool no_cache = true ) override
{
if(no_cache or not _instantiated) {
if(no_cache or _instantiated == nullptr) {
if(_instantiated) {
delete _instantiated;
}
@ -177,12 +200,21 @@ class eoForgeOperator<Itf,Op> : public eoForgeInterface<Itf>
return *_instantiated;
}
virtual ~eoForgeOperator()
std::shared_ptr<Itf> instantiate_ptr( bool no_cache = true ) override
{
if(no_cache or _instantiated == nullptr) {
_instantiated_ptr = std::shared_ptr<Op>();
}
return _instantiated_ptr;
}
virtual ~eoForgeOperator() override
{
delete _instantiated;
}
protected:
std::shared_ptr<Itf> _instantiated_ptr;
Itf* _instantiated;
};
@ -241,7 +273,7 @@ class eoForgeVector : public std::vector<eoForgeInterface<Itf>*>
/** instantiate the operator managed at the given index.
*/
Itf& instantiate(double index)
Itf& instantiate_from(double index)
{
double frac_part, int_part;
frac_part = std::modf(index, &int_part);
@ -249,9 +281,33 @@ class eoForgeVector : public std::vector<eoForgeInterface<Itf>*>
eo::log << eo::errors << "there is a fractional part in the given index (" << index << ")" << std::endl;
assert(frac_part != 0);
}
return instantiate(index);
}
std::shared_ptr<Itf> instantiate_ptr_from(double index)
{
double frac_part, int_part;
frac_part = std::modf(index, &int_part);
if(frac_part != 0) {
eo::log << eo::errors << "there is a fractional part in the given index (" << index << ")" << std::endl;
assert(frac_part != 0);
}
return instantiate_ptr(index);
}
/** instantiate the operator managed at the given index.
*/
Itf& instantiate(size_t index)
{
return this->at(static_cast<size_t>(index))->instantiate(_no_cache);
}
std::shared_ptr<Itf> instantiate_ptr(size_t index)
{
return this->at(static_cast<size_t>(index))->instantiate_ptr(_no_cache);
}
/** Add an operator to the list.
*
* @warning When passing a reference (as it is often the case within ParadisEO),

View file

@ -114,7 +114,12 @@ eoFunctorBase::procedure_tag functor_category(const eoF<R>&)
result_type
**/
template <class A1, class R>
#if __cplusplus >= 201103L
class eoUF : public eoFunctorBase, public std::function<R(A1)>
#else
// Deprecated in C++11
class eoUF : public eoFunctorBase, public std::unary_function<A1, R>
#endif
{
public :
@ -151,7 +156,12 @@ eoFunctorBase::unary_function_tag functor_category(const eoUF<A1, R>&)
result_type
**/
template <class A1, class A2, class R>
#if __cplusplus >= 201103L
class eoBF : public eoFunctorBase, public std::function<R(A1, A2)>
#else
// Deprecated in C++11
class eoBF : public eoFunctorBase, public std::binary_function<A1, A2, R>
#endif
{
public :
/// virtual dtor here so there is no need to define it in derived classes

View file

@ -29,11 +29,12 @@
#include <algorithm>
#include <cassert>
#include <random>
#include "eoOp.h"
#include "eoSTLFunctor.h"
#include "utils/eoRndGenerators.h"
#include "utils/rnd_generators.h" // for shuffle method
// #include "utils/rnd_generators.h" // for shuffle method
#include "eoExceptions.h"
@ -197,7 +198,8 @@ class eoInitPermutation: public eoInit<EOT> // FIXME inherit from eoInitWithDim
chrom[idx] = idx+startFrom;
}
UF_random_generator<unsigned int> gen(chrom.size());
std::random_device rd;
std::mt19937 gen(rd());
std::shuffle(chrom.begin(), chrom.end(), gen);
chrom.invalidate();
}

View file

@ -36,9 +36,12 @@
*
* @ingroup Representations
*/
template <class FitT, class T = size_t> class eoInt: public eoVector<FitT, T>
template <class FitT, class T = size_t>
class eoInt: public eoVector<FitT, T>
{
public:
using AtomType = size_t;
using FitnessType = FitT;
/**
* (Default) Constructor.

View file

@ -82,9 +82,9 @@ public:
// replace if necessary
for(i = 0; i < i1; i++) {
while (p1[ _solution1[i] ] != -1)
while (p1[ _solution1[i] ] != -1) // FIXME as an unsigned int, p1 cannot hold negative values!
_solution1[i] = p1[_solution1[i]];
while (p2[ _solution2[i] ] != -1)
while (p2[ _solution2[i] ] != -1) // FIXME as an unsigned int, p2 cannot hold negative values!
_solution2[i] = p2[_solution2[i]];
}
@ -96,9 +96,9 @@ public:
// replace if necessary
for(i = i2 + 1; i < _solution1.size(); i++) {
while (p1[ _solution1[i] ] != -1)
while (p1[ _solution1[i] ] != -1) // FIXME as an unsigned int, p1 cannot hold negative values!
_solution1[i] = p1[_solution1[i]];
while (p2[ _solution2[i] ] != -1)
while (p2[ _solution2[i] ] != -1) // FIXME as an unsigned int, p2 cannot hold negative values!
_solution2[i] = p2[_solution2[i]];
}

View file

@ -45,7 +45,7 @@ Authors:
#include "eoOp.h" // for eoInit
#include "eoPersistent.h"
#include "eoInit.h"
#include "utils/rnd_generators.h" // for shuffle method
// #include "utils/rnd_generators.h" // for shuffle method
#include "eoExceptions.h"
/** A std::vector of EO object, to be used in all algorithms

View file

@ -68,16 +68,12 @@ public:
}
assert(not _pop[0].invalid());
const typename EOT::Fitness min_fit
= std::min_element( std::begin(_pop), std::end(_pop) )
->fitness();
cumulative.clear();
cumulative.push_back(_pop[0].fitness() - min_fit);
cumulative.push_back(_pop[0].fitness() );
for (unsigned i = 1; i < _pop.size(); ++i) {
assert(not _pop[i].invalid());
cumulative.push_back(cumulative.back() + _pop[i].fitness() - min_fit);
cumulative.push_back(cumulative.back() + _pop[i].fitness());
}
assert(cumulative.size() == _pop.size());
}

View file

@ -40,73 +40,73 @@ template <class EOT>
class eoRanking : public eoPerf2Worth<EOT> // false: do not cache fitness
{
public:
using eoPerf2Worth<EOT>::value;
/* Ctor:
@param _p selective pressure (in (1,2]
@param _e exponent (1 == linear)
*/
eoRanking(double _p=2.0, double _e=1.0):
pressure(_p), exponent(_e) {}
/* helper function: finds index in _pop of _eo, an EOT * */
int lookfor(const EOT *_eo, const eoPop<EOT>& _pop)
/* Ctor:
@param _p selective pressure (in (1,2]
@param _e exponent (1 == linear)
*/
eoRanking(double _p = 2.0, double _e = 1.0) : pressure(_p), exponent(_e)
{
typename eoPop<EOT>::const_iterator it;
for (it=_pop.begin(); it<_pop.end(); it++)
{
if (_eo == &(*it))
return it-_pop.begin();
}
throw eoException("Not found in eoLinearRanking");
assert(1 < pressure and pressure <= 2);
}
/* COmputes the ranked fitness: fitnesses range in [m,M]
with m=2-pressure/popSize and M=pressure/popSize.
in between, the progression depstd::ends on exponent (linear if 1).
*/
virtual void operator()(const eoPop<EOT>& _pop)
/* helper function: finds index in _pop of _eo, an EOT * */
int lookfor(const EOT *_eo, const eoPop<EOT> &_pop)
{
std::vector<const EOT *> rank;
_pop.sort(rank);
unsigned pSize =_pop.size();
unsigned int pSizeMinusOne = pSize-1;
if (pSize <= 1)
throw eoPopSizeException(pSize,"cannot do ranking with population of size <= 1");
// value() refers to the std::vector of worthes (we're in an eoParamvalue)
value().resize(pSize);
double beta = (2-pressure)/pSize;
if (exponent == 1.0) // no need for exponetial then
typename eoPop<EOT>::const_iterator it;
for (it = _pop.begin(); it < _pop.end(); it++)
{
double alpha = (2*pressure-2)/(pSize*pSizeMinusOne);
for (unsigned i=0; i<pSize; i++)
if (_eo == &(*it))
return it - _pop.begin();
}
throw eoException("Not found in eoLinearRanking");
}
/* COmputes the ranked fitness: fitnesses range in [m,M]
with m=2-pressure/popSize and M=pressure/popSize.
in between, the progression depstd::ends on exponent (linear if 1).
*/
virtual void operator()(const eoPop<EOT> &_pop)
{
std::vector<const EOT *> rank;
_pop.sort(rank);
unsigned pSize = _pop.size();
unsigned int pSizeMinusOne = pSize - 1;
if (pSize <= 1)
throw eoPopSizeException(pSize, "cannot do ranking with population of size <= 1");
// value() refers to the std::vector of worthes (we're in an eoParamvalue)
value().resize(pSize);
double beta = (2 - pressure) / pSize;
if (exponent == 1.0) // no need for exponential then
{
double alpha = (2 * pressure - 2) / (pSize * pSizeMinusOne);
for (unsigned i = 0; i < pSize; i++)
{
int which = lookfor(rank[i], _pop);
value()[which] = alpha*(pSize-i)+beta; // worst -> 1/[P(P-1)/2]
int which = lookfor(rank[i], _pop);
value()[which] = alpha * (pSize - i) + beta; // worst -> 1/[P(P-1)/2]
}
}
else // exponent != 1
else // exponent != 1
{
double gamma = (2*pressure-2)/pSize;
for (unsigned i=0; i<pSize; i++)
double gamma = (2 * pressure - 2) / pSize;
for (unsigned i = 0; i < pSize; i++)
{
int which = lookfor(rank[i], _pop);
// value in in [0,1]
double tmp = ((double)(pSize-i))/pSize;
// to the exponent, and back to [m,M]
value()[which] = gamma*pow(tmp, exponent)+beta;
int which = lookfor(rank[i], _pop);
// value is in [0,1]
double tmp = ((double)(pSize - i)) / pSize;
// to the exponent, and back to [m,M]
value()[which] = gamma * pow(tmp, exponent) + beta;
}
}
}
private:
double pressure; // selective pressure
double exponent;
private:
double pressure; // selective pressure
double exponent;
};
#endif

139
eo/src/eoRankingCached.h Normal file
View file

@ -0,0 +1,139 @@
/** -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
-----------------------------------------------------------------------------
eoRankingCached.h
(c) Maarten Keijzer, Marc Schoenauer, 2001
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifndef eoRankingCached_h
#define eoRankingCached_h
#include "eoPerf2Worth.h"
/**
* @class eoRankingCached
* @brief Cached version of eoRanking that stores precomputed values for better performance
*
* This class implements the same ranking algorithm as eoRanking but adds a caching layer
* that stores frequently used values when the population size remains constant between
* calls. This optimization is particularly useful in steady-state evolution where the
* population size typically doesn't change between selection operations.
*
* The caching mechanism stores:
* - Population size related values (pSize, pSizeMinusOne)
* - Precomputed coefficients (alpha, beta, gamma)
*
* @warning This optimization should only be used when the population size remains constant
* between calls to the operator. For dynamic population sizes, use the standard eoRanking.
*
* @ingroup Selectors
*/
template <class EOT>
class eoRankingCached : public eoPerf2Worth<EOT>
{
public:
using eoPerf2Worth<EOT>::value;
/* Ctor:
@param _p selective pressure (in (1,2]
@param _e exponent (1 == linear)
*/
eoRankingCached(double _p = 2.0, double _e = 1.0) : pressure(_p), exponent(_e), cached_pSize(0)
{
assert(1 < pressure and pressure <= 2);
}
/*
Computes the ranked fitness with caching optimization
Fitnesses range in [m,M] where:
- m = 2-pressure/popSize
- M = pressure/popSize
The progression between m and M depends on the exponent (linear when exponent=1)
@param _pop The population to rank
*/
virtual void operator()(const eoPop<EOT> &_pop)
{
unsigned pSize = _pop.size();
if (pSize <= 1)
throw eoPopSizeException(pSize, "cannot do ranking with population of size <= 1");
// value() refers to the std::vector of worthes (we're in an eoParamvalue)
value().resize(pSize);
// Cache population-size dependent values only when population size changes
if (pSize != cached_pSize)
{
cached_pSize = pSize;
cached_pSizeMinusOne = pSize - 1;
cached_beta = (2 - pressure) / pSize;
cached_gamma = (2 * pressure - 2) / pSize;
cached_alpha = (2 * pressure - 2) / (pSize * cached_pSizeMinusOne);
}
std::vector<const EOT *> rank;
_pop.sort(rank);
// map of indices for the population
std::unordered_map<const EOT *, unsigned> indexMap;
for (unsigned i = 0; i < pSize; ++i)
{
indexMap[&_pop[i]] = i;
}
if (exponent == 1.0) // no need for exponential then (linear case)
{
for (unsigned i = 0; i < pSize; i++)
{
const EOT *indiv = rank[i];
int which = indexMap[indiv];
value()[which] = cached_alpha * (pSize - i) + cached_beta;
}
}
else // non-linear case (exponent != 1)
{
for (unsigned i = 0; i < pSize; i++)
{
const EOT *indiv = rank[i];
int which = indexMap[indiv];
// value is in [0,1]
double tmp = ((double)(pSize - i)) / pSize;
// to the exponent, and back to [m,M]
value()[which] = cached_gamma * pow(tmp, exponent) + cached_beta;
}
}
}
private:
double pressure; // selective pressure (1 < pressure <= 2)
double exponent; // exponent (1 = linear)
// Cached values (recomputed only when population size changes)
unsigned cached_pSize; // last seen population size
unsigned cached_pSizeMinusOne; // pSize - 1
double cached_alpha; // linear scaling coefficient
double cached_beta; // base value coefficient
double cached_gamma; // non-linear scaling coefficient
};
#endif

74
eo/src/eoRealToIntInit.h Normal file
View file

@ -0,0 +1,74 @@
#ifndef eoRealToIntInit_h_INCLUDED
#define eoRealToIntInit_h_INCLUDED
#include "es/eoReal.h"
#include "utils/eoIntBounds.h"
template<class EOTINT, class EOTREAL = eoReal<typename EOTINT::FitnessType>>
class eoRealToIntInit : public eoInit<EOTINT>
{
public:
using EOTreal = EOTREAL;
enum Repair {
folds,
truncate
};
eoRealToIntInit( eoInit<EOTreal>& init ) :
_whenout(Repair::truncate),
_nobounds(),
_bounds(_nobounds),
_init(init)
{ }
eoRealToIntInit( eoInit<EOTreal>& init, eoIntBounds& bounds, Repair whenout = Repair::truncate ) :
_whenout(whenout),
_nobounds(),
_bounds(bounds),
_init(init)
{ }
virtual void operator()(EOTINT& intsol) override
{
#ifndef NDEBUG
for(size_t i=0; i < intsol.size(); ++i) {
assert(_bounds.isInBounds(intsol[i]));
}
#endif
EOTreal floatsol;
std::copy( std::begin(intsol), std::end(intsol), std::back_inserter(floatsol) );
_init(floatsol);
intsol.resize(floatsol.size());
for(size_t i=0; i < floatsol.size(); ++i) {
typename EOTreal::AtomType rounded = std::round(floatsol[i]);
if( not _bounds.isInBounds(rounded) ) {
switch(_whenout) {
case Repair::truncate:
_bounds.truncate(rounded);
break;
case Repair::folds:
_bounds.foldsInBounds(rounded);
break;
}
}
intsol[i] = static_cast<typename EOTINT::AtomType>(rounded);
}
}
protected:
Repair _whenout;
eoIntNoBounds _nobounds;
eoIntBounds& _bounds;
eoInit<EOTreal>& _init;
};
#endif // eoRealToIntInit_h_INCLUDED

73
eo/src/eoRealToIntMonOp.h Normal file
View file

@ -0,0 +1,73 @@
#ifndef eoRealToIntMonOp_h_INCLUDED
#define eoRealToIntMonOp_h_INCLUDED
#include "es/eoReal.h"
#include "utils/eoIntBounds.h"
template<class EOTINT, class EOTREAL = eoReal<typename EOTINT::FitnessType>>
class eoRealToIntMonOp : public eoMonOp<EOTINT>
{
public:
using EOTreal = EOTREAL;
enum Repair {
folds,
truncate
};
eoRealToIntMonOp( eoMonOp<EOTreal>& monop ) :
_whenout(Repair::truncate),
_nobounds(),
_bounds(_nobounds),
_monop(monop)
{ }
eoRealToIntMonOp( eoMonOp<EOTreal>& monop, eoIntBounds& bounds, Repair whenout = Repair::truncate ) :
_whenout(whenout),
_nobounds(),
_bounds(bounds),
_monop(monop)
{ }
bool operator()(EOTINT& intsol)
{
#ifndef NDEBUG
for(size_t i=0; i < intsol.size(); ++i) {
assert(_bounds.isInBounds(intsol[i]));
}
#endif
EOTreal floatsol;
std::copy( std::begin(intsol), std::end(intsol), std::back_inserter(floatsol) );
bool changed = _monop(floatsol);
if(changed) {
for(size_t i=0; i < floatsol.size(); ++i) {
typename EOTreal::AtomType rounded = std::round(floatsol[i]);
if( not _bounds.isInBounds(rounded) ) {
switch(_whenout) {
case Repair::truncate:
_bounds.truncate(rounded);
break;
case Repair::folds:
_bounds.foldsInBounds(rounded);
break;
}
}
intsol[i] = static_cast<typename EOTINT::AtomType>(rounded);
}
}
return changed;
}
protected:
Repair _whenout;
eoIntNoBounds _nobounds;
eoIntBounds& _bounds;
eoMonOp<EOTreal>& _monop;
};
#endif // eoRealToIntMonOp_h_INCLUDED

View file

@ -0,0 +1,94 @@
#ifndef eoRealToIntQuadOp_h_INCLUDED
#define eoRealToIntQuadOp_h_INCLUDED
#include "es/eoReal.h"
#include "utils/eoIntBounds.h"
template<class EOTINT, class EOTREAL = eoReal<typename EOTINT::FitnessType>>
class eoRealToIntQuadOp : public eoQuadOp<EOTINT>
{
public:
using EOTreal = EOTREAL;
enum Repair {
folds,
truncate
};
eoRealToIntQuadOp( eoQuadOp<EOTreal>& quadop ) :
_whenout(Repair::truncate),
_nobounds(),
_bounds(_nobounds),
_quadop(quadop)
{ }
eoRealToIntQuadOp( eoQuadOp<EOTreal>& quadop, eoIntBounds& bounds, Repair whenout = Repair::truncate ) :
_whenout(whenout),
_nobounds(),
_bounds(bounds),
_quadop(quadop)
{ }
bool operator()(EOTINT& intsol1, EOTINT& intsol2)
{
#ifndef NDEBUG
for(size_t i=0; i < intsol1.size(); ++i) {
assert(_bounds.isInBounds(intsol1[i]));
}
for(size_t i=0; i < intsol2.size(); ++i) {
assert(_bounds.isInBounds(intsol2[i]));
}
#endif
EOTreal floatsol1;
std::copy( std::begin(intsol1), std::end(intsol1), std::back_inserter(floatsol1) );
EOTreal floatsol2;
std::copy( std::begin(intsol2), std::end(intsol2), std::back_inserter(floatsol2) );
bool changed = _quadop(floatsol1, floatsol2);
if(changed) {
for(size_t i=0; i < floatsol1.size(); ++i) {
typename EOTreal::AtomType rounded = std::round(floatsol1[i]);
if( not _bounds.isInBounds(rounded) ) {
switch(_whenout) {
case Repair::truncate:
_bounds.truncate(rounded);
break;
case Repair::folds:
_bounds.foldsInBounds(rounded);
break;
}
}
intsol1[i] = static_cast<typename EOTINT::AtomType>(rounded);
}
for(size_t i=0; i < floatsol2.size(); ++i) {
typename EOTreal::AtomType rounded = std::round(floatsol2[i]);
if( not _bounds.isInBounds(rounded) ) {
switch(_whenout) {
case Repair::truncate:
_bounds.truncate(rounded);
break;
case Repair::folds:
_bounds.foldsInBounds(rounded);
break;
}
}
intsol2[i] = static_cast<typename EOTINT::AtomType>(rounded);
}
}
return changed;
}
protected:
Repair _whenout;
eoIntNoBounds _nobounds;
eoIntBounds& _bounds;
eoQuadOp<EOTreal>& _quadop;
};
#endif // eoRealToIntQuadOp_h_INCLUDED

View file

@ -79,7 +79,12 @@ void eoSTLF<void>::operator()(void)
respectively
*/
template <class A1, class R>
#if __cplusplus >= 201103L
class eoSTLUF : public std::function<R(A1)>
#else
// Deprecated since C++11
class eoSTLUF : public std::unary_function<A1, R>
#endif
{
public:
eoSTLUF(eoUF<A1,R>& _f) : f(_f) {}
@ -102,7 +107,12 @@ class eoSTLUF : public std::unary_function<A1, R>
respectively
*/
template <class A1, class A2, class R>
#if __cplusplus >= 201103L
class eoSTLBF : public std::function<R(A1, A2)>
#else
// Deprecated since C++11
class eoSTLBF : public std::binary_function<A1, A2, R>
#endif
{
public:
eoSTLBF(eoUF<A1,R>& _f) : f(_f) {}

View file

@ -230,27 +230,25 @@ protected:
// if the eval does not need to be used, use the dummy eval instance
class eoDummyEval : public eoEvalFunc<POT>
{
public:
void operator()(POT &)
{}
}
dummyEval;
class eoDummyFlight:public eoFlight < POT >
{
public:
eoDummyFlight () {}
void operator () (POT &) {}
}dummyFlight;
public:
void operator()(POT &) override {}
} dummyEval;
class eoDummyFlight:public eoFlight < POT >
{
public:
eoDummyFlight () {}
void operator() (POT &) override {}
} dummyFlight;
// if the initializer does not need to be used, use the dummy one instead
class eoDummyInitializer:public eoInitializerBase < POT >
{
public:
eoDummyInitializer () {}
void operator () (POT &) {}
}dummyInit;
public:
eoDummyInitializer () {}
void operator() () override {}
} dummyInit;
};
/** @example t-eoSyncEasyPSO.cpp

View file

@ -113,16 +113,19 @@ CMAParams::CMAParams(eoParser& parser, unsigned dimensionality) {
for (unsigned i = 0; i < weights.size(); ++i) {
weights[i] = mu - i;
}
break;
}
case 2:
{
weights = 1.;
break;
}
default :
{
for (unsigned i = 0; i < weights.size(); ++i) {
weights[i] = log(mu+1.)-log(i+1.);
}
break;
}
}

View file

@ -39,6 +39,7 @@
template <class FitT> class eoReal: public eoVector<FitT, double>
{
public:
using AtomType = double;
using FitnessType = FitT;
/**

View file

@ -361,10 +361,10 @@ template<class Chrom> class eoUBitXover: public eoQuadOp<Chrom>
{
if (chrom1[i] != chrom2[i] && eo::rng.flip(preference))
{
// bool tmp = chrom1[i];
// chrom1[i]=chrom2[i];
// chrom2[i] = tmp;
std::swap(chrom1[i], chrom2[i]);
bool tmp = chrom1[i];
chrom1[i]=chrom2[i];
chrom2[i] = tmp;
// std::swap(chrom1[i], chrom2[i]);
changed = true;
}
}

View file

@ -50,7 +50,11 @@ class eoParseTreeDepthInit : public eoInit< eoParseTree<FType, Node> >
protected:
// a binary predicate for sorting
// hopefully this will work with M$VC++ 6.0
#if __cplusplus >= 201103L
struct lt_arity:public std::function<bool(Node,Node)>
#else
struct lt_arity:public std::binary_function<Node,Node,bool>
#endif
{
bool operator()(const Node &_node1, const Node &_node2) { return (_node1.arity() < _node2.arity());};
};

View file

@ -468,8 +468,11 @@ private :
switch(new_arity)
{
case 3 : args[2].copy(s.args[2]); args[2].parent = this; // no break!
[[fallthrough]];
case 2 : args[1].copy(s.args[1]); args[1].parent = this;
[[fallthrough]];
case 1 : args[0].copy(s.args[0]); args[0].parent = this;
[[fallthrough]];
case 0 : break;
default :
{
@ -523,7 +526,9 @@ private :
switch(arity())
{
case 3 : args[2].parent = 0; // no break!
[[fallthrough]];
case 2 : args[1].parent = 0;
[[fallthrough]];
case 1 : args[0].parent = 0; break;
case 0 : break;
default :
@ -542,7 +547,9 @@ private :
switch(arity())
{
case 3 : args[2].parent = this; // no break!
[[fallthrough]];
case 2 : args[1].parent = this;
[[fallthrough]];
case 1 : args[0].parent = this; break;
case 0 : break;
default :

View file

@ -29,6 +29,7 @@ Authors:
# include "../eoFunctor.h"
# include "../eoExceptions.h"
# include "mpi/implMpi.h"
# include "eoMpiNode.h"
# include "eoMpiAssignmentAlgorithm.h"
@ -669,7 +670,7 @@ namespace eo
timerStat.start("master_wait_for_all_responses");
while( assignmentAlgo.availableWorkers() != totalWorkers )
{
bmpi::status status = comm.probe( bmpi::any_source, eo::mpi::Channel::Messages );
eo::mpi::status status = comm.probe( eo::mpi::any_source, eo::mpi::Channel::Messages );
int wrkRank = status.source();
that.handleResponse( wrkRank );
comm.send( wrkRank, Channel::Commands, Message::Finish );
@ -686,7 +687,7 @@ namespace eo
AssignmentAlgorithm& assignmentAlgo;
Job< JobData > & that;
bmpi::communicator & comm;
eo::mpi::communicator & comm;
};
/**
@ -713,7 +714,7 @@ namespace eo
{
eo::log << eo::debug << "[M" << comm.rank() << "] Waitin' for node..." << std::endl;
bmpi::status status = comm.probe( bmpi::any_source, eo::mpi::Channel::Messages );
eo::mpi::status status = comm.probe( eo::mpi::any_source, eo::mpi::Channel::Messages );
int wrkRank = status.source();
eo::log << eo::debug << "[M" << comm.rank() << "] Node " << wrkRank << " just terminated." << std::endl;
@ -797,7 +798,7 @@ namespace eo
AssignmentAlgorithm& assignmentAlgo;
int masterRank;
const int workerStopCondition;
bmpi::communicator& comm;
eo::mpi::communicator& comm;
JobStore<JobData>& store;
SendTaskFunction<JobData> & sendTask;

View file

@ -27,14 +27,14 @@ namespace eo
{
void Node::init( int argc, char** argv )
{
static bmpi::environment env( argc, argv );
static eo::mpi::environment env( argc, argv );
}
bmpi::communicator& Node::comm()
eo::mpi::communicator& Node::comm()
{
return _comm;
}
bmpi::communicator Node::_comm;
eo::mpi::communicator Node::_comm;
}
}

View file

@ -23,7 +23,7 @@ Authors:
# define __MPI_NODE_H__
# include "implMpi.h"
namespace bmpi = mpi;
// namespace bmpi = mpi;
namespace eo
{
@ -54,10 +54,10 @@ namespace eo
/**
* @brief Returns the global mpi::communicator
*/
static bmpi::communicator& comm();
static eo::mpi::communicator& comm();
protected:
static bmpi::communicator _comm;
static eo::mpi::communicator _comm;
};
}
}

View file

@ -54,7 +54,7 @@ namespace eo
typedef eoUF< eoPop<EOT>&, void> ResetAlgo;
MultiStartData(
bmpi::communicator& _comm,
eo::mpi::communicator& _comm,
eoAlgo<EOT>& _algo,
int _masterRank,
ResetAlgo & _resetAlgo )
@ -87,7 +87,7 @@ namespace eo
/**
* @brief Communicator, used to send and retrieve messages.
*/
bmpi::communicator& comm;
eo::mpi::communicator& comm;
/**
* @brief Algorithm which will be performed by the worker.

View file

@ -137,7 +137,7 @@ namespace eo
std::vector<EOT> tempArray;
int masterRank;
bmpi::communicator& comm;
eo::mpi::communicator& comm;
};
/**

View file

@ -21,6 +21,8 @@ Authors:
*/
#include "implMpi.h"
namespace eo
{
namespace mpi
{
const int any_source = MPI_ANY_SOURCE;
@ -159,8 +161,9 @@ namespace mpi
MPI_Barrier( MPI_COMM_WORLD );
}
void broadcast( communicator & comm, int value, int root )
void broadcast( communicator & /*comm*/, int value, int root )
{
MPI_Bcast( &value, 1, MPI_INT, root, MPI_COMM_WORLD );
}
}
} // namespace mpi
} // namespace eo

View file

@ -22,7 +22,7 @@ Authors:
#ifndef __EO_IMPL_MPI_HPP__
#define __EO_IMPL_MPI_HPP__
#include "eoMpi.h"
#include <mpi.h>
#include "../serial/eoSerial.h"
/**
@ -41,282 +41,290 @@ Authors:
* The entities are here shortly described, if you need further details, don't hesitate
* to visit the boost URL.
*/
namespace mpi
namespace eo
{
/**
* @ingroup Parallel
* @{
*/
/**
* @brief Constant indicating that a message can come from any process.
*/
extern const int any_source;
/**
* @brief Constant indicating that a message can come from any tag (channel).
*/
extern const int any_tag;
/**
* @brief Wrapper class to have a MPI environment.
*
* Instead of calling MPI_Init and MPI_Finalize, it is only necessary to instantiate
* this class once, in the global context.
*/
class environment
namespace mpi
{
public:
/**
* @ingroup Parallel
* @{
*/
/**
* @brief Inits MPI context.
* @brief Constant indicating that a message can come from any process.
*/
extern const int any_source;
/**
* @brief Constant indicating that a message can come from any tag (channel).
*/
extern const int any_tag;
/**
* @brief Wrapper class to have a MPI environment.
*
* @param argc Number of params in command line (same as one in main)
* @param argv Strings containing params (same as one in main)
* Instead of calling MPI_Init and MPI_Finalize, it is only necessary to instantiate
* this class once, in the global context.
*/
environment(int argc, char**argv);
/**
* @brief Closes MPI context.
*/
~environment();
};
/**
* @brief Wrapper class for MPI_Status
*
* Consists only in a C++ wrapper class, giving getters on status attributes.
*/
class status
{
class environment
{
public:
/**
* @brief Inits MPI context.
*
* @param argc Number of params in command line (same as one in main)
* @param argv Strings containing params (same as one in main)
*/
environment(int argc, char **argv);
/**
* @brief Closes MPI context.
*/
~environment();
};
/* struct MPI_Status
{
int count;
int cancelled;
int MPI_SOURCE;
int MPI_TAG;
int MPI_ERROR;
}; */
/**
* @brief Converts a MPI_Status into a status.
* @brief Wrapper class for MPI_Status
*
* Consists only in a C++ wrapper class, giving getters on status attributes.
*/
status( const MPI_Status & s );
class status
{
public:
/**
* @brief Converts a MPI_Status into a status.
*/
status(const MPI_Status &s);
/**
* @brief Returns the tag of the associated communication.
*/
int tag() { return _tag; }
/**
* @brief Returns the tag of the associated communication.
*/
int tag() { return _tag; }
/**
* @brief Indicates which error number we obtained in the associated communication.
*/
int error() { return _error; }
/**
* @brief Indicates which error number we obtained in the associated communication.
*/
int error() { return _error; }
/**
* @brief Returns the MPI rank of the source of the associated communication.
*/
int source() { return _source; }
/**
* @brief Returns the MPI rank of the source of the associated communication.
*/
int source() { return _source; }
private:
int _source;
int _tag;
int _error;
};
};
/**
* @brief Main object, used to send / receive messages, get informations about the rank and the size of the world,
* etc.
*/
class communicator
{
/**
* @brief Main object, used to send / receive messages, get informations about the rank and the size of the world,
* etc.
*/
class communicator
{
public:
/**
* Creates the communicator, using the whole world as a MPI_Comm.
*
* @todo Allow the user to precise which MPI_Comm to use
*/
communicator();
/**
* Creates the communicator, using the whole world as a MPI_Comm.
*
* @todo Allow the user to precise which MPI_Comm to use
*/
communicator( );
~communicator();
~communicator();
/**
* @brief Returns the MPI rank of the current process.
*/
int rank();
/**
* @brief Returns the MPI rank of the current process.
*/
int rank();
/**
* @brief Returns the size of the MPI cluster.
*/
int size();
/**
* @brief Returns the size of the MPI cluster.
*/
int size();
/*
* SEND / RECV INT
*/
/*
* SEND / RECV INT
*/
/**
* @brief Sends an integer to dest on channel "tag".
*
* @param dest MPI rank of the receiver
* @param tag MPI tag of message
* @param n The integer to send
*/
void send(int dest, int tag, int n);
/**
* @brief Sends an integer to dest on channel "tag".
*
* @param dest MPI rank of the receiver
* @param tag MPI tag of message
* @param n The integer to send
*/
void send( int dest, int tag, int n );
/*
* @brief Receives an integer from src on channel "tag".
*
* @param src MPI rank of the sender
* @param tag MPI tag of message
* @param n Where to save the received integer
*/
void recv(int src, int tag, int &n);
/*
* @brief Receives an integer from src on channel "tag".
*
* @param src MPI rank of the sender
* @param tag MPI tag of message
* @param n Where to save the received integer
*/
void recv( int src, int tag, int& n );
/*
* SEND / RECV STRING
*/
/*
* SEND / RECV STRING
*/
/**
* @brief Sends a string to dest on channel "tag".
*
* @param dest MPI rank of the receiver
* @param tag MPI tag of message
* @param str The std::string to send
*/
void send(int dest, int tag, const std::string &str);
/**
* @brief Sends a string to dest on channel "tag".
*
* @param dest MPI rank of the receiver
* @param tag MPI tag of message
* @param str The std::string to send
*/
void send( int dest, int tag, const std::string& str );
/*
* @brief Receives a string from src on channel "tag".
*
* @param src MPI rank of the sender
* @param tag MPI tag of message
* @param std::string Where to save the received string
*/
void recv(int src, int tag, std::string &str);
/*
* @brief Receives a string from src on channel "tag".
*
* @param src MPI rank of the sender
* @param tag MPI tag of message
* @param std::string Where to save the received string
*/
void recv( int src, int tag, std::string& str );
/*
* SEND / RECV Objects
*/
/*
* SEND / RECV Objects
*/
/**
* @brief Sends an eoserial::Persistent to dest on channel "tag".
*
* @param dest MPI rank of the receiver
* @param tag MPI tag of message
* @param persistent The object to send (it must absolutely implement eoserial::Persistent)
*/
void send(int dest, int tag, const eoserial::Persistent &persistent);
/**
* @brief Sends an eoserial::Persistent to dest on channel "tag".
*
* @param dest MPI rank of the receiver
* @param tag MPI tag of message
* @param persistent The object to send (it must absolutely implement eoserial::Persistent)
*/
void send( int dest, int tag, const eoserial::Persistent & persistent );
/**
* @brief Sends an array of eoserial::Persistent to dest on channel "tag".
*
* @param dest MPI rank of the receiver
* @param tag MPI tag of message
* @param table The array of eoserial::Persistent objects
* @param size The number of elements to send (no check is done, the user has to be sure that the size won't
* overflow!)
*/
template< class T >
void send( int dest, int tag, T* table, int size )
{
// Puts all the values into an array
eoserial::Array* array = new eoserial::Array;
for( int i = 0; i < size; ++i )
/**
* @brief Sends an array of eoserial::Persistent to dest on channel "tag".
*
* @param dest MPI rank of the receiver
* @param tag MPI tag of message
* @param table The array of eoserial::Persistent objects
* @param size The number of elements to send (no check is done, the user has to be sure that the size won't
* overflow!)
*/
template <class T>
void send(int dest, int tag, T *table, int size)
{
array->push_back( table[i].pack() );
// Puts all the values into an array
eoserial::Array *array = new eoserial::Array;
for (int i = 0; i < size; ++i)
{
array->push_back(table[i].pack());
}
// Encapsulates the array into an object
eoserial::Object *obj = new eoserial::Object;
obj->add("array", array);
std::stringstream ss;
obj->print(ss);
delete obj;
// Sends the object as a string
send(dest, tag, ss.str());
}
// Encapsulates the array into an object
eoserial::Object* obj = new eoserial::Object;
obj->add( "array", array );
std::stringstream ss;
obj->print( ss );
delete obj;
/*
* @brief Receives an eoserial::Persistent object from src on channel "tag".
*
* @param src MPI rank of the sender
* @param tag MPI tag of message
* @param persistent Where to unpack the serialized object?
*/
void recv(int src, int tag, eoserial::Persistent &persistent);
// Sends the object as a string
send( dest, tag, ss.str() );
}
/*
* @brief Receives an eoserial::Persistent object from src on channel "tag".
*
* @param src MPI rank of the sender
* @param tag MPI tag of message
* @param persistent Where to unpack the serialized object?
*/
void recv( int src, int tag, eoserial::Persistent & persistent );
/*
* @brief Receives an array of eoserial::Persistent from src on channel "tag".
*
* @param src MPI rank of the sender
* @param tag MPI tag of message
* @param table The table in which we're saving the received objects. It must have been allocated by the user,
* as no allocation is performed here.
* @param size The number of elements to receive (no check is done, the user has to be sure that the size won't
* overflow!)
*/
template< class T >
void recv( int src, int tag, T* table, int size )
{
// Receives the string which contains the object
std::string asText;
recv( src, tag, asText );
// Parses the object and retrieves the table
eoserial::Object* obj = eoserial::Parser::parse( asText );
eoserial::Array* array = static_cast<eoserial::Array*>( (*obj)["array"] );
// Retrieves all the values from the array
for( int i = 0; i < size; ++i )
/*
* @brief Receives an array of eoserial::Persistent from src on channel "tag".
*
* @param src MPI rank of the sender
* @param tag MPI tag of message
* @param table The table in which we're saving the received objects. It must have been allocated by the user,
* as no allocation is performed here.
* @param size The number of elements to receive (no check is done, the user has to be sure that the size won't
* overflow!)
*/
template <class T>
void recv(int src, int tag, T *table, int size)
{
eoserial::unpackObject( *array, i, table[i] );
// Receives the string which contains the object
std::string asText;
recv(src, tag, asText);
// Parses the object and retrieves the table
eoserial::Object *obj = eoserial::Parser::parse(asText);
eoserial::Array *array = static_cast<eoserial::Array *>((*obj)["array"]);
// Retrieves all the values from the array
for (int i = 0; i < size; ++i)
{
eoserial::unpackObject(*array, i, table[i]);
}
delete obj;
}
delete obj;
}
/*
* Other methods
*/
/*
* Other methods
*/
/**
* @brief Wrapper for MPI_Probe
*
* Waits for a message to come from process having rank src, on the channel
* tag.
*
* @param src MPI rank of the sender (any_source if it can be any sender)
* @param tag MPI tag of the expected message (any_tag if it can be any tag)
*/
status probe( int src = any_source, int tag = any_tag );
/**
* @brief Wrapper for MPI_Probe
*
* Waits for a message to come from process having rank src, on the channel
* tag.
*
* @param src MPI rank of the sender (any_source if it can be any sender)
* @param tag MPI tag of the expected message (any_tag if it can be any tag)
*/
status probe(int src = any_source, int tag = any_tag);
/**
* @brief Wrapper for MPI_Barrier
*
*
*/
void barrier();
/**
* @brief Wrapper for MPI_Barrier
*
*
*/
void barrier();
private:
int _rank;
int _size;
char* _buf; // temporary buffer for sending and receiving strings. Avoids reallocations
char *_buf; // temporary buffer for sending and receiving strings. Avoids reallocations
int _bufsize; // size of the above temporary buffer
};
};
/**
* @brief Wrapper for MPI_Bcast
*
* Broadcasts an integer value on the communicator comm, from the process having the MPI rank root.
*
* @param comm The communicator on which to broadcast
* @param value The integer value to send
* @param root The MPI rank of the broadcaster
*
* @todo Actually comm isn't used and broadcast is performed on the whole MPI_COMM_WORLD. TODO: Use comm instead
*/
void broadcast( communicator & comm, int value, int root );
/**
* @brief Wrapper for MPI_Bcast
*
* Broadcasts an integer value on the communicator comm, from the process having the MPI rank root.
*
* @param comm The communicator on which to broadcast
* @param value The integer value to send
* @param root The MPI rank of the broadcaster
*
* @todo Actually comm isn't used and broadcast is performed on the whole MPI_COMM_WORLD. TODO: Use comm instead
*/
void broadcast(communicator &comm, int value, int root);
/**
* @}
*/
} // namespace mpi
/**
* @}
*/
} // namespace mpi
} // namespace eo
# endif //__EO_IMPL_MPI_HPP__
#endif //__EO_IMPL_MPI_HPP__

View file

@ -56,22 +56,24 @@ eoGnuplot::~eoGnuplot()
}
#ifdef HAVE_GNUPLOT
void eoGnuplot::gnuplotCommand(const char *_command)
{
#ifdef HAVE_GNUPLOT
if(gpCom) {
PipeComSend( gpCom, _command );
PipeComSend( gpCom, "\n" );
}
#endif
}
#else
void eoGnuplot::gnuplotCommand(const char *)
{ }
#endif
#ifdef HAVE_GNUPLOT
void eoGnuplot::initGnuPlot(std::string _title, std::string _extra)
{
#ifdef HAVE_GNUPLOT
std::ostringstream os;
os << "250x150-0+" << 170 * numWindow++;
char *args[6];
@ -89,8 +91,12 @@ void eoGnuplot::initGnuPlot(std::string _title, std::string _extra)
PipeComSend( gpCom, _extra.c_str() );
PipeComSend( gpCom, "\n" );
}
#endif
}
#else
void eoGnuplot::initGnuPlot(std::string, std::string)
{ }
#endif

View file

@ -39,8 +39,10 @@ eoParallel::eoParallel() :
_nthreads( 0, "parallelize-nthreads", "Define the number of threads you want to use, nthreads = 0 means you want to use all threads available", '\0' ),
_enableResults( false, "parallelize-enable-results", "Enable the generation of results", '\0' ),
_doMeasure( false, "parallelize-do-measure", "Do some measures during execution", '\0' ),
_packetSize( 1U, "parallelize-packet-size", "Number of elements which should be sent in a single message during a parallel evaluation based on message passing.", '\0'),
_t_start(0)
_packetSize( 1U, "parallelize-packet-size", "Number of elements which should be sent in a single message during a parallel evaluation based on message passing.", '\0')
#ifdef _OPENMP
, _t_start(0)
#endif
{
}

View file

@ -71,7 +71,9 @@ private:
eoValueParam<bool> _enableResults;
eoValueParam<bool> _doMeasure;
eoValueParam<unsigned int> _packetSize;
#ifdef _OPENMP
double _t_start;
#endif
};
void make_parallel(eoParser&);

View file

@ -42,16 +42,16 @@ int Check( PCom *com )
}
PCom * PipeComOpen( char *prog )
PCom * PipeComOpen( const char *prog )
{
char *args[2];
args[0] = prog;
args[0] = strdup( prog );
args[1] = NULL;
return PipeComOpenArgv( prog, args );
}
PCom * PipeComOpenArgv( char *prog, char *argv[] )
PCom * PipeComOpenArgv( const char *prog, char *argv[] )
{
int toFils[2];
int toPere[2];

View file

@ -23,8 +23,8 @@ typedef struct PipeCommunication {
} PCom;
extern PCom *PipeComOpen( char *prog );
extern PCom *PipeComOpenArgv( char *prog, char *argv[] );
extern PCom *PipeComOpen( const char *prog );
extern PCom *PipeComOpenArgv( const char *prog, char *argv[] );
extern int PipeComSend( PCom *to, const char *line );
extern int PipeComSendn( PCom *to, const char *data, int n );

View file

@ -124,6 +124,7 @@ inline bool random_generator<bool>::operator()(void)
function (see eoPop::shuffle): its operator() takes an unsigned argument m
and must return an unsigned uniformly distributed in [0,m}
*/
// FIXME this is probably deprecated by the new STL way of managing random generators.
template <class T = uint32_t>
class UF_random_generator
{
@ -134,11 +135,11 @@ class UF_random_generator
: _max(max), _random(_rng)
{}
T operator()() { return _random.random(_max); }
T operator()(T m) { return _random.random(m); }
T operator()() const { return _random.random(_max); }
T operator()(T m) const { return _random.random(m); }
T min() { return 0; }
T max() { return _max; }
T min() const { return 0; }
T max() const { return _max; }
private :
T _max;

View file

@ -179,7 +179,8 @@ double sum_fitness(const eoPop<EOT>& _pop)
template <class EOT>
double sum_fitness(const eoPop<EOT>& _pop, std::pair<double, double>& _minmax)
{
double rawTotal, scaledTotal;
// double rawTotal = 0;
double scaledTotal;
typename eoPop<EOT>::const_iterator it = _pop.begin();
@ -193,7 +194,7 @@ double sum_fitness(const eoPop<EOT>& _pop, std::pair<double, double>& _minmax)
_minmax.first = std::min(_minmax.first, v);
_minmax.second = std::max(_minmax.second, v);
rawTotal += v;
// rawTotal += v;
}
if (minimizing_fitness<EOT>())

View file

@ -80,6 +80,9 @@ set (TEST_LIST
t-forge-FastGA
t-eoFoundryFastGA
t-eoAlgoFoundryFastGA
t-eoRealToIntMonOp
t-eoRealToIntQuadOp
t-eoRankingCached
)

View file

@ -382,7 +382,7 @@ class Experiment : public eoserial::Persistent
void run()
{
mpi::communicator& comm = eo::mpi::Node::comm();
communicator& comm = eo::mpi::Node::comm();
// reinits every objects
eo::rng.reseed( _seed );
eo::rng.clearCache(); // trick for repeatable sequences of normal numbers, cf eo::rng

View file

@ -25,7 +25,7 @@ int main(int /*argc*/, char** /*argv*/)
/***** Crossovers ****/
foundry.crossovers.add< eo1PtBitXover<EOT> >();
foundry.crossovers.add< eoUBitXover<EOT> >(0.5); // preference over 1
// foundry.crossovers.add< eoUBitXover<EOT> >(0.5); // preference over 1
for(size_t i=1; i < 11; i+=4) {
foundry.crossovers.add< eoNPtsBitXover<EOT> >(i); // nb of points
}
@ -43,9 +43,9 @@ int main(int /*argc*/, char** /*argv*/)
std::ref(foundry.mutation_selectors) }) {
ops.add< eoRandomSelect<EOT> >();
ops.add< eoStochTournamentSelect<EOT> >(0.5);
ops.add< eoSequentialSelect<EOT> >();
ops.add< eoProportionalSelect<EOT> >();
// ops.add< eoStochTournamentSelect<EOT> >(0.5);
// ops.add< eoSequentialSelect<EOT> >();
// ops.add< eoProportionalSelect<EOT> >();
for(size_t i=2; i < 10; i+=4) {
ops.add< eoDetTournamentSelect<EOT> >(i);
}
@ -53,16 +53,16 @@ int main(int /*argc*/, char** /*argv*/)
/***** Replacements ****/
foundry.replacements.add< eoCommaReplacement<EOT> >();
foundry.replacements.add< eoPlusReplacement<EOT> >();
foundry.replacements.add< eoSSGAWorseReplacement<EOT> >();
foundry.replacements.add< eoSSGAStochTournamentReplacement<EOT> >(0.51);
// foundry.replacements.add< eoPlusReplacement<EOT> >();
// foundry.replacements.add< eoSSGAWorseReplacement<EOT> >();
// foundry.replacements.add< eoSSGAStochTournamentReplacement<EOT> >(0.51);
for(size_t i=2; i < 10; i+=4) {
foundry.replacements.add< eoSSGADetTournamentReplacement<EOT> >(i);
}
/***** Continuators ****/
for(size_t i=10; i < 30; i+=10 ) {
foundry.continuators.add< eoSteadyFitContinue<EOT> >(10,i);
for(size_t i=3; i < 5; i+=1 ) {
foundry.continuators.add< eoGenContinue<EOT> >(i);
}

View file

@ -31,8 +31,6 @@ public :
int the_main(int argc, char **argv)
{ // ok, we have a command line parser and a state
typedef eoBit<float> Chrom;
eoParser parser(argc, argv);
// Define Parameters

View file

@ -0,0 +1,219 @@
#include <apply.h>
#include <eo>
#include <eoRanking.h>
#include <eoRankingCached.h>
#include <es/eoReal.h>
#include <utils/eoRNG.h>
#include "real_value.h"
class RankingTest
{
public:
RankingTest(eoParser &parser, eoEvalFuncCounter<eoReal<double>> &_eval, unsigned size = 100)
: rng(0),
popSize(size),
seedParam(parser.createParam(uint32_t(time(0)), "seed", "Random seed", 'S')),
pressureParam(parser.createParam(1.5, "pressure", "Selective pressure", 'p')),
exponentParam(parser.createParam(1.0, "exponent", "Ranking exponent", 'e')),
eval(_eval)
{
rng.reseed(seedParam.value());
initPopulation();
}
void initPopulation()
{
pop.clear();
for (unsigned i = 0; i < popSize; ++i)
{
eoReal<double> ind;
ind.resize(1);
ind[0] = rng.uniform();
pop.push_back(ind);
}
apply<eoReal<double>>(eval, pop);
}
const unsigned popSize;
eoPop<eoReal<double>> pop;
eoRng rng;
double pressure() const { return pressureParam.value(); }
double exponent() const { return exponentParam.value(); }
private:
eoValueParam<uint32_t> &seedParam;
eoValueParam<double> &pressureParam;
eoValueParam<double> &exponentParam;
eoEvalFuncCounter<eoReal<double>> eval;
};
// Test case 1: Verify both implementations produce identical results
void test_Consistency(eoParser &parser)
{
eoEvalFuncPtr<eoReal<double>, double, const std::vector<double> &> mainEval(real_value);
eoEvalFuncCounter<eoReal<double>> eval(mainEval);
RankingTest fixture(parser, eval);
eoRanking<eoReal<double>> ranking(fixture.pressure(), fixture.exponent());
eoRankingCached<eoReal<double>> rankingCached(fixture.pressure(), fixture.exponent());
ranking(fixture.pop);
rankingCached(fixture.pop);
const std::vector<double> &values = ranking.value();
const std::vector<double> &cachedValues = rankingCached.value();
for (unsigned i = 0; i < fixture.pop.size(); ++i)
{
if (abs(values[i] - cachedValues[i]) > 1e-9)
{
throw std::runtime_error("Inconsistent ranking values between implementations");
}
}
std::clog << "Test 1 passed: Both implementations produce identical results" << std::endl;
}
// Test case 2: Test edge case with minimum population size
void test_MinPopulationSize(eoParser &parser)
{
eoPop<eoReal<double>> smallPop;
eoReal<double> ind1, ind2;
ind1.resize(1);
ind1[0] = 0.5;
ind2.resize(1);
ind2[0] = 1.0;
smallPop.push_back(ind1);
smallPop.push_back(ind2);
eoEvalFuncPtr<eoReal<double>, double, const std::vector<double> &> mainEval(real_value);
eoEvalFuncCounter<eoReal<double>> eval(mainEval);
RankingTest fixture(parser, eval, 2); // Use fixture to get parameters
eoRanking<eoReal<double>> ranking(fixture.pressure(), fixture.exponent());
eoRankingCached<eoReal<double>> rankingCached(fixture.pressure(), fixture.exponent());
apply<eoReal<double>>(eval, smallPop);
ranking(smallPop);
rankingCached(smallPop);
if (ranking.value()[0] >= ranking.value()[1] ||
rankingCached.value()[0] >= rankingCached.value()[1])
{
throw std::runtime_error("Invalid ranking for population size 2");
}
std::clog << "Test 2 passed: Minimum population size handled correctly" << std::endl;
}
// Test case 3: Verify caching actually works
void test_CachingEffectiveness(eoParser &parser)
{
eoEvalFuncPtr<eoReal<double>, double, const std::vector<double> &> mainEval(real_value);
eoEvalFuncCounter<eoReal<double>> eval(mainEval);
RankingTest fixture(parser, eval, 50); // Fixed size for cache test
eoRankingCached<eoReal<double>> rankingCached(fixture.pressure(), fixture.exponent());
// First run - should compute all values
rankingCached(fixture.pop);
const auto firstValues = rankingCached.value();
// Modify fitness values but keep same population size
for (auto &ind : fixture.pop)
{
ind[0] = fixture.rng.uniform();
}
apply<eoReal<double>>(eval, fixture.pop);
// Second run - should use cached coefficients
rankingCached(fixture.pop);
// Add one individual to invalidate cache
eoReal<double> newInd;
newInd.resize(1);
newInd[0] = fixture.rng.uniform();
fixture.pop.push_back(newInd);
apply<eoReal<double>>(eval, fixture.pop);
// Third run - should recompute coefficients
rankingCached(fixture.pop);
std::clog << "Test 3 passed: Caching mechanism properly invalidated" << std::endl;
}
// Helper function to test constructor assertions
bool testRankingConstructor(double pressure, double exponent)
{
try
{
eoRanking<eoReal<double>> ranking(pressure, exponent);
return true; // Constructor succeeded
}
catch (...)
{
return false; // Assertion failed
}
}
// Helper function to test constructor assertions
bool testRankingCachedConstructor(double pressure, double exponent)
{
try
{
eoRankingCached<eoReal<double>> ranking(pressure, exponent);
return true;
}
catch (...)
{
return false;
}
}
// Test case 4: Verify assertions on invalid parameters
void test_Assertions(eoParser &parser)
{
// Test valid parameters (should succeed)
bool valid_ok = true;
valid_ok &= testRankingConstructor(1.1, 1.0); // Valid pressure
valid_ok &= testRankingCachedConstructor(1.1, 1.0); // Valid pressure
// Test invalid parameters (should fail)
bool invalid_ok = true;
invalid_ok &= !testRankingConstructor(1.0, 1.0); // pressure = 1 (invalid)
invalid_ok &= !testRankingConstructor(0.5, 1.0); // pressure < 1 (invalid)
invalid_ok &= !testRankingConstructor(2.1, 1.0); // pressure > 2 (invalid)
invalid_ok &= !testRankingCachedConstructor(1.0, 1.0); // pressure = 1 (invalid)
invalid_ok &= !testRankingCachedConstructor(0.5, 1.0); // pressure < 1 (invalid)
invalid_ok &= !testRankingCachedConstructor(2.1, 1.0); // pressure > 2 (invalid)
if (!valid_ok)
{
throw std::runtime_error("Valid parameter tests failed");
}
if (!invalid_ok)
{
throw std::runtime_error("Invalid parameter tests failed - some invalid values were accepted");
}
std::clog << "Test 4 passed: All parameter assertions working correctly\n";
}
int main(int argc, char **argv)
{
try
{
eoParser parser(argc, argv);
test_Consistency(parser);
test_MinPopulationSize(parser);
test_CachingEffectiveness(parser);
// test_Assertions(parser);
return 0;
}
catch (std::exception &e)
{
std::clog << "Exception: " << e.what() << std::endl;
return 1;
}
}

View file

@ -0,0 +1,28 @@
#include <iostream>
#include <eo>
#include <es.h>
using namespace std;
int main(int, char**)
{
eoIntInterval bounds(1,5);
using Chrom = eoInt<double>;
using MutWrapper = eoRealToIntMonOp<Chrom>;
eoDetUniformMutation< typename MutWrapper::EOTreal > mutreal(/*range*/6, /*nb*/5);
MutWrapper mutint(mutreal, bounds);
Chrom sol({1,2,3,4,5});
bool changed = mutint(sol);
assert(changed);
for(auto& x : sol) {
assert(bounds.isInBounds(x));
}
}

View file

@ -0,0 +1,35 @@
#include <iostream>
#include <eo>
#include <es.h>
using namespace std;
int main(int, char**)
{
eoIntInterval intbounds(1,5);
eoRealInterval rb(1,5);
eoRealVectorBounds realbounds(5, rb);
using Chrom = eoInt<double>;
using CrossWrapper = eoRealToIntQuadOp<Chrom>;
eoSegmentCrossover< typename CrossWrapper::EOTreal > crossreal(realbounds, /*alpha*/0);
CrossWrapper crossint(crossreal, intbounds);
Chrom sol1({1,2,3,4,5});
Chrom sol2({1,2,3,4,5});
bool changed = crossint(sol1, sol2);
assert(changed);
for(auto& x : sol1) {
assert(intbounds.isInBounds(x));
}
for(auto& x : sol2) {
assert(intbounds.isInBounds(x));
}
}

View file

@ -126,7 +126,7 @@ eoValueParam<unsigned> tournamentSizeParam = parser.createParam(unsigned(2), "to
}
// hard-coded directory name ...
system("mkdir ResSelect");
(void) system("mkdir ResSelect");
std::cout << "Testing the Selections\nParents size = " << pSize
<< ", offspring rate = " << oRate;
std::cout << " and putting rsulting files in dir ResSelect" << std::endl;

View file

@ -193,7 +193,7 @@ int the_main(int argc, char **argv)
std::cout << "The resulting file (in dir ResSelect), contains \n";
std::cout << " the empirical proba. for each indi to be selected." << std::endl;
system("mkdir ResSelect");
(void) system("mkdir ResSelect");
// initialize parent population
parentsOrg.resize(pSize);

View file

@ -37,8 +37,6 @@ struct Dummy : public EO<double>
int the_main(int argc, char **argv)
{ // ok, we have a command line parser and a state
typedef eoBit<float> Chrom;
eoParser parser(argc, argv);
// Define Parameters

View file

@ -19,7 +19,7 @@ int main(int /*argc*/, char** /*argv*/)
eoBooleanGenerator gen(0.5);
eoInitFixedLength<EOT> init(dim, gen);
eoGenContinue<EOT> common_cont(100);
eoGenContinue<EOT> common_cont(5);
eoForgeVector< eoContinue<EOT> > continuators;
continuators.add< eoSteadyFitContinue<EOT> >(10,10);

View file

@ -0,0 +1,54 @@
Bootstrap: docker
From: ubuntu:24.04
%post
# Update the available packages list.
apt -y update
# And add the "universe" repository (allow to install many more software).
apt -y install software-properties-common
add-apt-repository universe
apt -y update
# Update the operating systems (install last versions with bugfixes).
apt -y dist-upgrade
# Install dependencies for your project.
apt -y install git g++ cmake ccache make libeigen3-dev libopenmpi-dev doxygen graphviz libgnuplot-iostream-dev
# Download sources.
git clone --branch master --single-branch --recurse-submodules https://github.com/nojhan/paradiseo
cd paradiseo
# Build directory that holds built binaries and cache.
mkdir -p build
cd build
# Example of minimum build:
# Use that if you want the minimal set of libraries needed to build a simple solver.
# cmake -DCMAKE_BUILD_TYPE=Release -DEDO=ON .. && make
# Example of trying to build everything:
# Use that to test if everything can be built with your setup,
# or if you modified something in Paradiseo and want to test it.
cmake -DCMAKE_BUILD_TYPE=Release -DEDO=ON -DENABLE_CMAKE_EXAMPLE=ON -DENABLE_CMAKE_TESTING=ON -DENABLE_GNUPLOT=ON -DENABLE_OPENMP=ON -DMPI=ON -DSMP=ON .. && make
# You may run the tests, to check if everything works:
ctest
# Make the documentation:
make doc
# Clean-up of the APT cache (will lighten the container).
apt -y purge software-properties-common git g++ cmake ccache make libeigen3-dev libopenmpi-dev doxygen graphviz libgnuplot-iostream-dev
apt -y --purge autoremove
apt -y autoclean
apt clean
%environment
%runscript
# When executing the container, this will be called,
# and pass all the command line arguments.
./paradiseo/build/edo/application/cmaes/cmaes $*
%labels
Author Johann Dreo

View file

@ -79,6 +79,20 @@ public:
explorer(_neighborhood, _eval, defaultSolNeighborComp, _cool)
{}
/**
* Constructor without cooling schedule, but with a continuator.
*
* @param _neighborhood the neighborhood
* @param _fullEval the full evaluation function
* @param _eval neighbor's evaluation function
* @param _cont an external continuator
*/
moSA(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, moContinuator<Neighbor>& _cont):
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
defaultCool(0, 0, 0, 0),
explorer(_neighborhood, _eval, defaultSolNeighborComp, defaultCool)
{}
/**
* General constructor for a simulated annealing
* @param _neighborhood the neighborhood

View file

@ -54,7 +54,11 @@ public:
* @param _maxFullEval number maximum of iterations
* @param _restartCounter if true the counter of number of evaluations restarts to "zero" at initialization, if false, the number is cumulative
*/
moFullEvalContinuator(eoEvalFuncCounter<EOT> & _eval, unsigned int _maxFullEval, bool _restartCounter = true): eval(_eval), maxFullEval(_maxFullEval), restartCounter(_restartCounter) {
moFullEvalContinuator(eoEvalFuncCounter<EOT> & _eval, unsigned int _maxFullEval, bool _restartCounter = true):
eval(_eval),
restartCounter(_restartCounter),
maxFullEval(_maxFullEval)
{
nbEval_start = eval.value();
}

View file

@ -167,7 +167,7 @@ public :
if (nb > 1) {
sd = 0;
for(int i = 0; i < nb; i++)
for(unsigned i = 0; i < nb; i++)
sd += (neighborFitness[i] - mean) * (neighborFitness[i] - mean) ;
sd = sqrt( sd / (nb - 1.0) ); // becareful: could be infinite when large values
//sd = sqrt( (sd - nb * mean * mean) / (nb - 1.0) ); // becareful: could be negative due to approximation of large values

View file

@ -62,7 +62,7 @@ public :
* Set the first and the third quartile of fitness in the neighborhood
* @param _sol the first solution
*/
virtual void init(EOT & _sol) {
virtual void init(EOT & /*_sol*/) {
value().first = nhStat.getQ1();
value().second = nhStat.getQ3();
}
@ -71,7 +71,7 @@ public :
* Set the first and the third quartile fitness in the neighborhood
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol) {
virtual void operator()(EOT & /*_sol*/) {
value().first = nhStat.getQ1();
value().second = nhStat.getQ3();
}

View file

@ -184,6 +184,10 @@
#include <problems/permutation/moTwoOptExNeighbor.h>
#include <problems/permutation/moTwoOptExNeighborhood.h>
#include <problems/partition/moBinaryPartition.h>
#include <problems/partition/moBinaryPartitionSwapNeighbor.h>
#include <problems/partition/moBinaryPartitionSwapNeighborhood.h>
//#include <problems/eval/moMaxSATincrEval.h>
//#include <problems/eval/moOneMaxIncrEval.h>
//#include <problems/eval/moQAPIncrEval.h>
@ -193,7 +197,6 @@
//#include <problems/eval/moUBQPBitsIncrEval.h>
//#include <problems/eval/moNKlandscapesIncrEval.h>
#include <sampling/moAdaptiveWalkSampling.h>
#include <sampling/moAutocorrelationSampling.h>
#include <sampling/moDensityOfStatesSampling.h>

View file

@ -72,7 +72,7 @@ public:
* @param _neighbor the neighbor to assign
* @return a neighbor equal to the other
*/
virtual moNeighbor<EOT, Fitness>& operator=(
moNeighbor<EOT, Fitness>& operator=(
const moNeighbor<EOT, Fitness>& _neighbor) {
if (!(_neighbor.invalid()))
fitness(_neighbor.fitness());
@ -93,7 +93,7 @@ public:
* @param _neighbor a neighbor
* @return if _neighbor and this one are equals
*/
virtual bool equals(moNeighbor<EOT, Fitness> & /*_neighbor*/) {
bool equals(moNeighbor<EOT, Fitness> & /*_neighbor*/) {
return false;
}

View file

@ -52,7 +52,7 @@ public:
/**
* Default constructor with first search heuristics
*
* @param _firstLS first local search
* @param _firstLS first local search
* @param _firstShake first heuristic which perturbs the solution
* @param _cycle when true, the first heuristics follows the last ones. Otherwise the search stop.
*/
@ -67,7 +67,7 @@ public:
}
/**
* test if there is still some heuristics
* test if there is still some heuristics
*
* @param _solution the current solution
* @return true if there is some heuristics
@ -83,11 +83,17 @@ public:
*/
virtual void init(EOT& /*_solution*/) {
if(order.size() == 0)
for(unsigned int i = 0; i < LSvector.size(); i++)
order.push_back(i);
for(unsigned int i = 0; i < LSvector.size(); i++) {
order.push_back(i); }
#if __cplusplus >= 201103L
std::random_device rd;
std::mt19937 gen(rd());
std::shuffle(order.begin(), order.end(), gen);
#else
UF_random_generator<unsigned int> gen(order.size());
std::random_shuffle(order.begin(), order.end(), gen);
#endif
currentOrder = 0;
current = order[currentOrder];

View file

@ -112,7 +112,7 @@ private:
nonSig = 0;
unsigned int n = 1;
for(int j = 0; j < nk.K + 1; j++) {
for(unsigned j = 0; j < nk.K + 1; j++) {
if (_solution[ nk.links[i][j] ] == 1)
sig = sig | n;

View file

@ -0,0 +1,218 @@
#pragma once
#include <set>
#include <eo>
/** A partition of a binary space.
*
* This data structure defines a grouping of the elements of a multi-dimensional
* set in a space of boolean numbers.
* \f[
* \mathrm{1}^n = \bigcup_{i=1}^n \{0,1\}_i
* \f]
* Elements of the set may be either "selected" (in the set S) or "rejected" (in the set R).
* \f[
* (S \in \mathrm{1}^m) \cup (R \in \mathrm{1}^k) \in \mathrm{1}^n,\; n=m+k
* \f]
* Elements are referred to by their index in the set (hereby named "atoms").
*
* This representation is useful if your problem can be defined has selecting
* a subset of elements that optimize some objective function.
*
* The core data structures are two ordered sets of unique atoms,
* the union of which is guaranteed to have the correct dimension.
*/
template<class FitT>
class moBinaryPartition : public EO<FitT>
{
public:
/** The type for indices. */
using AtomType = size_t;
/** The data structures holding the indices. */
using ContainerType = std::set<AtomType>;
/** The set of selected atoms. */
ContainerType selected;
/** The set of not-selected atoms. */
ContainerType rejected;
/** Consistent constructor
*
* Put all `total_nb_atoms` indices in the @ref rejected set.
* Indices starts at zero and fill the set in increasing order.
*
* @param total_nb_atoms Total number of possible atoms from whith to select.
*/
moBinaryPartition( const size_t total_nb_atoms )
{
// Fill the rejected list with all possible gene indices,
// starting from zero.
for(size_t i = 0; i < total_nb_atoms; ++i) {
rejected.insert(i);
}
// None selected.
}
/** Empty constructor
*
* Do not fill the @ref rejected set.
* You are responsible for making it consistent after instantiation.
*
* @warning If you do not fill at least the @ref rejected set,
* errors will be raised when trying to @ref select or @ref reject.
*/
moBinaryPartition()
{ }
/** Move one atom in the @ref selected set.
*
* That is: erase the atom from @ref rejected,
* insert it in @ref selected.
*
* @note In debug mode, double check that elements were actually moved.
*/
void select(const size_t atom) {
#if __cplusplus >= 202002L
assert(not selected.contains(atom));
#else
assert(selected.count(atom) == 0);
#endif
#ifndef NDEBUG
size_t has_erased =
#endif
this->rejected.erase(atom);
assert(has_erased == 1);
#ifndef NDEBUG
auto [where, has_inserted] =
#endif
this->selected.insert(atom);
assert(has_inserted);
}
/** Move one atom in the @ref rejected set.
*
* That is: insert the atom in @ref rejected,
* erase it from @ref selected.
*
* @note In debug mode, double check that elements were actually moved.
*/
void reject(const size_t atom) {
#if __cplusplus >= 202002L
assert(not rejected.contains(atom));
#else
assert(rejected.count(atom) == 0);
#endif
#ifndef NDEBUG
size_t has_erased =
#endif
this->selected.erase(atom);
assert(has_erased == 1);
#ifndef NDEBUG
auto [where, has_inserted] =
#endif
this->rejected.insert(atom);
assert(has_inserted);
}
/** Serialization of the `selected`.
*
* Output a string of the form (spaces replaced with period here, to show their count):
* `<fitness>..<nb_selected>..<sel_0><sel_n>`
*/
virtual void printSelectedOn(std::ostream& out) const
{
EO<FitT>::printOn(out); // Fitness.
// Trailing space already inserted.
out << " " << selected.size() << " "; // Size.
std::copy(std::begin(selected), std::end(selected),
std::ostream_iterator<AtomType>(out, " ")); // Values.
}
//! Convenience function to only render the fitness and the selected atoms (and not the rejected ones).
std::string str() const
{
std::ostringstream msg;
this->printSelectedOn(msg);
return msg.str();
}
/** Serialization of the `selected` and `rejected` atoms.
*
* Output a string of the form (spaces replaced with period here, to show their count):
* `<fitness>..<nb_selected>..<sel_0><sel_n>...<nb_rejected>..<rej_0><rej_m>`
*/
virtual void printOn(std::ostream& out) const override
{
this->printSelectedOn(out);
// Printing the rejected atom should not be necessary,
// as this is the complementary set of the selected.
// out << " ";
// out << rejected.size() << " "; // Size.
// std::copy(std::begin(rejected), std::end(rejected),
// std::ostream_iterator<AtomType>(out, " ")); // Values.
}
/** Deserialization of the `selected` and `rejected` atoms.
*
* Expects a string of the form (spaces replaced with period here, to show their count):
* `<fitness>..<nb_selected>..<sel_0><sel_n>...<nb_rejected>..<rej_0><rej_m>`
*/
virtual void readFrom(std::istream& in) override
{
EO<FitT>::readFrom(in); // Fitness.
unsigned size;
in >> size; // Size.
for(size_t i = 0; i < size; ++i) {
AtomType atom;
in >> atom; // Value.
selected.insert(atom);
}
assert(selected.size() == size);
in >> size; // Size.
for(size_t i = 0; i < size; ++i) {
AtomType atom;
in >> atom; // Value.
rejected.insert(atom);
}
assert(rejected.size() == size);
}
/** Returns true if all sets are equals. */
bool operator==(const moBinaryPartition& other) {
return this->selected == other.selected
and this->rejected == other.rejected;
}
//! Class name for state management.
virtual std::string className() const override
{
return "moBinaryPartition";
}
// //! Accessor to set fitness.
// virtual void fitness(const FitT& fit) override
// {
// // std::clog << "Fitness assignment -- solution: " << *this << " gets fitness: " << fit << std::endl;
// EO<FitT>::fitness(fit);
// }
// //! Accessor to get fitness.
// virtual const FitT& fitness() const override
// {
// return EO<FitT>::fitness();
// }
// //! Accessor to invalidate fitness.
// virtual void invalidate() override
// {
// // this->fitness().clear();
// EO<FitT>::invalidate();
// }
};

View file

@ -0,0 +1,223 @@
#pragma once
#include <utility>
#include <mo>
#include "moBinaryPartition.h"
/** Stable neighbor for a binary partition.
*
* Models how to move from a solution to a neighbor,
* by swaping one selected atom for one rejected atom.
* The number of selected atoms is thus guaranteed to be stable.
*
* The core data structure is two atoms:
* - the selected one,
* - the rejected one.
*/
template<class EOT, class Fitness=typename EOT::Fitness>
class moBinaryPartitionSwapNeighbor :
public moBackableNeighbor<EOT,Fitness>//,
// public moIndexNeighbor<EOT,double> // FIXME see if we can model that.
{
public:
/** Shortcut for Atoms type. */
using AtomType = typename EOT::AtomType;
/** Shortcut for containers type. */
using ContainerType = typename EOT::ContainerType;
/** Shortcut for fitness. */
using moBackableNeighbor<EOT, Fitness>::fitness;
// using moIndexNeighbor<EOT, Fitness>::key;
// using moIndexNeighbor<EOT, Fitness>::index;
/** Consistent constructor.
*
* Will ensure that the dimension of the partition does not change.
*
* @param _selected_nb Number of selected atoms to maintain.
*/
moBinaryPartitionSwapNeighbor( const size_t _selected_nb ) :
selected_nb(_selected_nb)
#ifndef NDEBUG
, is_set(false)
#endif
{
assert(selected_nb > 0);
}
/** Default constructor.
*
* Will NOT ensure that the dimension of the partition does not change.
*/
moBinaryPartitionSwapNeighbor() :
selected_nb(0)
#ifndef NDEBUG
, is_set(false)
#endif
{
// Invalid fitness by default.
}
/** Copy constructor.
*/
moBinaryPartitionSwapNeighbor( const moBinaryPartitionSwapNeighbor<EOT>& other) :
selected_nb(other.selected_nb),
select(other.select),
reject(other.reject)
#ifndef NDEBUG
, is_set(other.is_set)
#endif
{
this->fitness(other.fitness());
}
/** Default assignment operator.
*/
moBinaryPartitionSwapNeighbor<EOT>& operator=(
const moBinaryPartitionSwapNeighbor<EOT>& other)
{
this->selected_nb = other.selected_nb;
this->select = other.select;
this->reject = other.reject;
#ifndef NDEBUG
this->is_set = other.is_set;
#endif
this->fitness(other.fitness());
return *this;
}
/** Apply the currently stored move.
*
* That is: reject one atom and select one other.
*/
virtual void move(EOT& solution) override {
assert(is_set);
// Swap the two atoms.
solution.reject(this->reject);
solution.select(this->select);
assert(solution.selected.size() == this->selected_nb);
// this->fitness( Fitness(solution.fitness()) ); // For the cache.
solution.invalidate();
}
/** Apply the opposite of the currently stored move.
*
* That is: reject the selected atom, and select the rejected one.
*/
virtual void moveBack(EOT& solution) override {
assert(is_set);
solution.reject(this->select);
solution.select(this->reject);
assert(solution.selected.size() == this->selected_nb);
// this->fitness( Fitness(solution.fitness()) ); // For the cache.
solution.invalidate();
}
/** Set the considered atoms.
*
* @param in The selected atom.
* @param out The rejected atom.
*/
void set(AtomType in, AtomType out) {
this->select = in;
this->reject = out;
#ifndef NDEBUG
is_set = true;
#endif
this->invalidate();
}
/** Set the considered atoms.
*
* @param in_out A pair of {selected,rejected} atoms.
*/
void set(std::pair<AtomType,AtomType> in_out) {
this->set(in_out.first, in_out.second);
}
/** Get the considered atom.
*
* @returns A pair of atoms, the first being the selected atom, the second being the rejected one.
*/
std::pair<AtomType,AtomType> get() {
assert(is_set);
return std::make_pair(select, reject);
}
/** Returns true if this neighbor has the same selected & rejected atoms than the given neighbor. */
virtual bool equals(moBinaryPartitionSwapNeighbor<EOT,Fitness>& neighbor) {
auto [in, out] = neighbor.get();
return this->select == in and this->reject == out;
}
private:
// Disable access to `equals(moNeighbor<…>&)` (removes the related overloaded-virtual warning).
using moBackableNeighbor<EOT,Fitness>::equals;
public:
//! Class name for state management.
virtual std::string className() const override {
return "moBinaryPartitionSwapNeighbor";
}
/** Fancy print. */
virtual void printOn(std::ostream& out) const override {
assert(is_set);
EO<Fitness>::printOn(out); // Fitness.
out << " "
<< selected_nb
<< " -" << reject
<< " +" << select;
}
//! Accessor to set the size.
void size(size_t _selected_nb) {
assert(_selected_nb > 0);
this->selected_nb = _selected_nb;
this->invalidate();
}
//! Accessor to get the size.
size_t size() const {
return this->selected_nb;
}
// virtual void fitness(const Fitness& fit) override
// {
// // std::clog << "Fitness assignment -- neighbor: " << *this << " gets fitness: " << fit << std::endl;
// EO<Fitness>::fitness(fit);
// }
// virtual const Fitness& fitness() const override
// {
// return EO<Fitness>::fitness();
// }
#ifndef NDEBUG
public:
#else
protected:
#endif
/** Fixed dimension of the handled solutions. */
size_t selected_nb;
/** Selected atom. */
AtomType select;
/** Rejected atom. */
AtomType reject;
#ifndef NDEBUG
/** Sanity flag.
*
* Used in debug builds to ensure that the neighbor
* have been set before being used.
*/
bool is_set;
#endif
};

View file

@ -0,0 +1,157 @@
#pragma once
#include <utility>
#include <mo>
#include "moBinaryPartition.h"
/** Stable neighborhood for binary partitions.
*
* This generates all neighbors of a binary partition
* that have the same dimension than the considered solution.
* I.e. it enumerates all the swaps of two atoms
* between the selected and rejected sets.
*
* The core data structure is two indices:
* - one for the position within the selected set of a binary partition,
* - the other for the position within the rejected set.
*
* The neighborhood is defined as enumerating the neighbors,
* first by going over the rejected atoms (outer loop),
* then by iterating over the selected atoms (inner loop).
*/
template <class EOT, class Fitness=typename EOT::Fitness>
class moBinaryPartitionSwapNeighborhood : public moNeighborhood<moBinaryPartitionSwapNeighbor<EOT, Fitness> >
{
public:
/** Shortcut for neighbor's type. */
using Neighbor = moBinaryPartitionSwapNeighbor<EOT, Fitness>;
/** Shortcut for Atoms type. */
using AtomType = typename EOT::AtomType;
/** Get the currently pointed selected atom. */
AtomType selected(EOT& from, const size_t i_select) const {
typename EOT::ContainerType::iterator
it = std::begin(from.rejected);
std::advance(it, i_select);
return *it;
}
/** Get the currently pointed rejected atom. */
AtomType rejected(EOT& from, const size_t j_reject) const {
typename EOT::ContainerType::iterator
it = std::begin(from.selected);
std::advance(it, j_reject);
return *it;
}
/** Initialize the neighborhood.
*
* This actually make the neighborhood point to the first possible swap:
* between the first selected atom and the first rejected atom.
*/
virtual void init(EOT& from, Neighbor& to) override {
i_select = 0;
j_reject = 0;
// std::clog << "Init neighborhood:"
// << " outer:" << j_reject+1 << "/" << from.selected.size() << ","
// << " inner:" << i_select+1 << "/" << from.rejected.size() << " ="
// << " -" << rejected(from, j_reject)
// << " +" << selected(from, i_select)
// << " from: " << from
// << std::endl;
// First item in both lists.
AtomType in = selected(from, i_select);
AtomType out = rejected(from, j_reject);
to.set(in, out);
to.size(from.selected.size());
to.invalidate();
}
/** Point to the next neighbor. */
virtual void next(EOT& from, Neighbor& to) override {
// If last item of the inner loop.
if( i_select == from.rejected.size()-1 ) {
i_select = 0; // Reset inner loop.
j_reject++; // Next outer loop.
} else {
i_select++; // Next inner loop.
}
// std::clog << "Next in neighborhood:"
// << " -" << rejected(from, j_reject)
// << " +" << selected(from, i_select)
// << " from: " << from
// << std::endl;
#if __cplusplus >= 202002L
assert( from.rejected.contains(selected(from,i_select)) );
assert( from.selected.contains(rejected(from,j_reject)) );
#else
assert( from.rejected.count(selected(from,i_select)) > 0 );
assert( from.selected.count(rejected(from,j_reject)) > 0 );
#endif
assert( selected(from,i_select) != rejected(from,j_reject) );
// Implant this move in the neighbor.
to.set(
selected(from, i_select),
rejected(from, j_reject)
);
to.size(from.selected.size());
to.invalidate();
}
/** Returns true if there is more neighbors to be enumerated. */
virtual bool cont(EOT& from) override {
// std::clog << "cont neighborhood?"
// << " outer:" << j_reject+1 << "/" << from.selected.size() << ","
// << " inner:" << i_select+1 << "/" << from.rejected.size()// << " ="
// // << " -" << rejected(from, j_reject)
// // << " +" << selected(from, i_select)
// << " from: " << from
// << std::endl;
// If reached the last item of the outer loop.
if( i_select == from.rejected.size()-1
and j_reject == from.selected.size()-1) {
// We should also have reached the end of the inner loop,
// and have set the inner loop to zero.
// std::clog << "\tnope" << std::endl;
return false;
} else { // There is still some items in the outer loop.
// and thus also in the inner loop.
// std::clog << "\tyes" << std::endl;
assert( j_reject < from.selected.size() );
return true;
}
}
/** Returns true if there is actual neighbors in the neighborhood.
*
* Essentially just tells if the rejected set is not empty.
*/
virtual bool hasNeighbor(EOT& solution) override {
return solution.rejected.size() > 0;
}
//! Class name for state management.
virtual std::string className() const override {
return "moBinaryPartitionSwapNeighborhood";
}
#ifndef NDEBUG
public:
#else
protected:
#endif
/** Index of the currently pointed selected atom. */
size_t i_select;
/** Index of the currently pointed rejected atom. */
size_t j_reject;
};

View file

@ -84,10 +84,10 @@ public:
moEval<Neighbor>& _eval,
unsigned int _nbAdaptWalk) :
moSampling<Neighbor>(initHC, * new moRandomSearch<Neighbor>(initHC, _fullEval, _nbAdaptWalk), copyStat),
neighborEvalCount(_eval),
nEvalStat(neighborEvalCount, true),
copyStat(lengthStat), // copy is used to report the statistic of the first walk
neighborEvalCount(_eval),
nEvalStat(neighborEvalCount, true),
copyEvalStat(nEvalStat),
copyStat(lengthStat), // copy is used to report the statistic of the first walk
checkpoint(trueCont),
hc(_neighborhood, _fullEval, neighborEvalCount, checkpoint),
initHC(_init, hc)
@ -95,15 +95,15 @@ public:
// to count the number of step in the HC
checkpoint.add(lengthStat);
// set the long name of this statistic which is the length of the walk
copyStat.setLongName("length");
// set the long name of this statistic which is the length of the walk
copyStat.setLongName("length");
// to count the number of evaluations
// to count the number of evaluations
checkpoint.add(nEvalStat);
// set the long name of this statistic which is the number of neighbor evaluation
copyEvalStat.setLongName("ngheval");
// set the long name of this statistic which is the number of neighbor evaluation
copyEvalStat.setLongName("ngheval");
// add the solution into statistics
this->add(copyEvalStat);
this->add(solStat);
@ -118,10 +118,10 @@ public:
}
protected:
/* count the number of evaluations */
moEvalCounter<Neighbor> neighborEvalCount;
moValueStat<EOT, unsigned long> nEvalStat;
moStatFromStat<EOT, double> copyEvalStat;
/* count the number of evaluations */
moEvalCounter<Neighbor> neighborEvalCount;
moValueStat<EOT, unsigned long> nEvalStat;
moStatFromStat<EOT, double> copyEvalStat;
moSolutionStat<EOT> solStat;
moMinusOneCounterStat<EOT> lengthStat;

View file

@ -192,9 +192,9 @@ protected:
moSolutionStat<EOT> solutionStat;
moDistanceStat<EOT> distStat;
moNeighborhoodStat< Neighbor > neighborhoodStat;
moMinNeighborStat< Neighbor > minStat;
moAverageFitnessNeighborStat< Neighbor > averageStat;
moStdFitnessNeighborStat< Neighbor > stdStat;
moMinNeighborStat< Neighbor > minStat;
moMaxNeighborStat< Neighbor > maxStat;
moNbSupNeighborStat< Neighbor > nbSupStat;
moNbInfNeighborStat< Neighbor > nbInfStat;

View file

@ -96,6 +96,7 @@ set (TEST_LIST
t-moIndexedVectorTabuList
# t-moRndIndexedVectorTabuList
t-moDynSpanCoolingSchedule
t-moBinaryPartition
)
######################################################################################

View file

@ -71,15 +71,15 @@ typedef EO<int> Solution;
class moDummyNeighborTest: public moNeighbor<Solution> {
public:
virtual void move(Solution & _solution) {
virtual void move(Solution & /*_solution*/) {
}
};
class moDummyBackableNeighbor: public moBackableNeighbor<Solution> {
public:
virtual void move(Solution & _solution) {
virtual void move(Solution & /*_solution*/) {
}
virtual void moveBack(Solution & _solution) {
virtual void moveBack(Solution & /*_solution*/) {
}
};
@ -91,7 +91,7 @@ public:
i(0), j(0) {
}
virtual bool hasNeighbor(EOT & _solution) {
virtual bool hasNeighbor(EOT & /*_solution*/) {
bool res;
if (i % 3 == 0 || i == 1)
res = false;
@ -100,11 +100,11 @@ public:
i++;
return res;
}
virtual void init(EOT & _solution, Neighbor & _current) {
virtual void init(EOT & /*_solution*/, Neighbor & /*_current*/) {
}
virtual void next(EOT & _solution, Neighbor & _current) {
virtual void next(EOT & /*_solution*/, Neighbor & /*_current*/) {
}
virtual bool cont(EOT & _solution) {
virtual bool cont(EOT & /*_solution*/) {
j++;
return (j % 10 != 0);
}
@ -227,7 +227,7 @@ private:
class dummyInit: public eoInit<bitVector> {
public:
void operator()(bitVector& sol) {
void operator()(bitVector& /*sol*/) {
}
};

View file

@ -0,0 +1,88 @@
#include <mo>
int main()
{
using Signature = moBinaryPartition<double>;
const size_t genes_nb = 4;
/**********************************************
* Test if neighborhood has all neighbors.
**********************************************/
Signature geneset(genes_nb);
std::clog << "Available genes:";
for(size_t g : geneset.rejected) {
std::clog << " " << g;
}
std::clog << std::endl;
const size_t n = 2;
for(size_t i=0; i < n; ++i) {
geneset.select(i);
}
std::clog << "Init geneset: " << geneset << std::endl;
std::clog << std::endl;
moBinaryPartitionSwapNeighborhood<Signature> neighborhood;
// Save generated solutions for testing.
std::vector<Signature> solutions;
// Follows the framework's workflow (see moRandomBestHCexplorer):
// 1) if hasNeighbor()
// 2) neighborhood.init(…)
// 3) [eval]
// 4) while neighborhood.cont(…)
// 5) neighborhood.next(…)
// 6) [eval]
// … loop.
if(neighborhood.hasNeighbor(geneset)) {
moBinaryPartitionSwapNeighbor<Signature> neighbor(n);
neighborhood.init(geneset, neighbor);
std::clog << "Init neighbor: " << neighbor << std::endl;
// Print what it looks like.
std::clog << "Current geneset: " << geneset << std::endl;
Signature new_geneset = geneset;
neighbor.move(new_geneset);
std::clog << "Moved to solution: " << new_geneset << std::endl;
solutions.push_back(new_geneset);
std::clog << std::endl;
while(neighborhood.cont(geneset)) {
// Generate next neighbor.
neighborhood.next(geneset, neighbor);
std::clog << "New neighbor: " << neighbor << std::endl;
// Print what it looks like.
std::clog << "Current geneset: " << geneset << std::endl;
Signature new_geneset = geneset;
neighbor.move(new_geneset);
std::clog << "Moved to solution: " << new_geneset << std::endl;
solutions.push_back(new_geneset);
// Double check that one can moveBack and get the same solution.
neighbor.moveBack(new_geneset);
assert(new_geneset == geneset);
std::clog << std::endl;
}
}
std::clog << "Generated " << solutions.size() << " neighbors of: " << geneset << std::endl;
for(Signature s : solutions) {
std::clog << "\t" << s << std::endl;
}
assert(solutions.size() == 4);
/**********************************************
* Test if a full solution does not have neighbor.
**********************************************/
Signature full(genes_nb);
for(size_t i=0; i < genes_nb; ++i) {
full.select(i);
}
assert(not neighborhood.hasNeighbor(full));
}

View file

@ -258,9 +258,9 @@ public:
void filtre(){
eoPop<MOEOT> pop;
for(int i=0; i<size(); i++)
for(unsigned i=0; i<size(); i++)
pop.push_back(operator[](i));
for(int i=0; i<pop.size(); i++)
for(unsigned i=0; i<pop.size(); i++)
(*this)(pop[i]);
}

View file

@ -81,7 +81,7 @@ public:
* Default ctor.
* @param _maxSize the size of archive (must be smaller or equal to the population size)
*/
moeoSPEA2Archive(unsigned int _maxSize=100): moeoFixedSizeArchive < MOEOT >(true), maxSize(_maxSize), borne(0), indiComparator(defaultComparator), distance(defaultDistance)
moeoSPEA2Archive(unsigned int _maxSize=100): moeoFixedSizeArchive < MOEOT >(true), maxSize(_maxSize), borne(0), defaultComparator(), indiComparator(defaultComparator), defaultDistance(), distance(defaultDistance)
{}
@ -90,7 +90,7 @@ public:
* @param _dist the distance used
* @param _maxSize the size of archive (must be smaller or egal to the population size)
*/
moeoSPEA2Archive(moeoDistance <MOEOT, double>& _dist, unsigned int _maxSize=100): moeoFixedSizeArchive < MOEOT >(true), maxSize(_maxSize), borne(0), indiComparator(defaultComparator), distance(_dist)
moeoSPEA2Archive(moeoDistance <MOEOT, double>& _dist, unsigned int _maxSize=100): moeoFixedSizeArchive < MOEOT >(true), maxSize(_maxSize), borne(0), defaultComparator(), indiComparator(defaultComparator), distance(_dist)
{}
@ -99,7 +99,7 @@ public:
* @param _comparator the functor used to compare objective vectors
* @param _maxSize the size of archive (must be smaller or egal to the population size)
*/
moeoSPEA2Archive(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, unsigned int _maxSize=100): moeoFixedSizeArchive < MOEOT >(_comparator, true), maxSize(_maxSize), borne(0), indiComparator(defaultComparator), distance(defaultDistance)
moeoSPEA2Archive(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, unsigned int _maxSize=100): moeoFixedSizeArchive < MOEOT >(_comparator, true), maxSize(_maxSize), borne(0), defaultComparator(), indiComparator(defaultComparator), defaultDistance(), distance(defaultDistance)
{}
@ -108,7 +108,7 @@ public:
* @param _indiComparator the functor used to compare MOEOT
* @param _maxSize the size of archive (must be smaller or egal to the population size)
*/
moeoSPEA2Archive(moeoComparator <MOEOT>& _indiComparator, unsigned int _maxSize=100): moeoFixedSizeArchive < MOEOT >(true), maxSize(_maxSize), borne(0), indiComparator(_indiComparator), distance(defaultDistance)
moeoSPEA2Archive(moeoComparator <MOEOT>& _indiComparator, unsigned int _maxSize=100): moeoFixedSizeArchive < MOEOT >(true), maxSize(_maxSize), borne(0), defaultComparator(), indiComparator(_indiComparator), defaultDistance(), distance(defaultDistance)
{}
@ -119,7 +119,7 @@ public:
* @param _comparator the functor used to compare objective vectors
* @param _maxSize the size of archive (must be smaller or egal to the population size)
*/
moeoSPEA2Archive(moeoComparator <MOEOT>& _indiComparator, moeoDistance <MOEOT, double>& _dist, moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, unsigned int _maxSize=100) : moeoFixedSizeArchive < MOEOT >(_comparator, true), maxSize(_maxSize), borne(0), indiComparator(_indiComparator), distance(_dist)
moeoSPEA2Archive(moeoComparator <MOEOT>& _indiComparator, moeoDistance <MOEOT, double>& _dist, moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, unsigned int _maxSize=100) : moeoFixedSizeArchive < MOEOT >(_comparator, true), maxSize(_maxSize), borne(0), defaultComparator(), indiComparator(_indiComparator), distance(_dist)
{}
@ -283,11 +283,12 @@ public:
private:
/** archive max size */
unsigned int maxSize;
/** archive size */
unsigned int borne;
/** default moeoComparator*/
moeoFitnessThenDiversityComparator < MOEOT > defaultComparator;
/**
* Wrapper which allow to used an moeoComparator in std::sort
* @param _comp the comparator to used
@ -314,12 +315,10 @@ private:
moeoComparator < MOEOT > & comp;
}
indiComparator;
/** default moeoComparator*/
moeoFitnessThenDiversityComparator < MOEOT > defaultComparator;
/** distance */
moeoDistance <MOEOT, double>& distance;
/** default distance */
moeoEuclideanDistance < MOEOT > defaultDistance;
/** distance */
moeoDistance <MOEOT, double>& distance;
/**

View file

@ -99,7 +99,11 @@ class moeoBitVector : public moeoVector < MOEOObjectiveVector, bool, MOEOFitness
if (_is)
{
resize(bits.size());
#if __cplusplus >= 201103L
std::transform(bits.begin(), bits.end(), begin(), std::bind(std::equal_to<char>(), std::placeholders::_1, '1'));
#else
std::transform(bits.begin(), bits.end(), begin(), std::bind2nd(std::equal_to<char>(), '1'));
#endif
}
}

View file

@ -52,7 +52,7 @@ class moeoDistance : public eoBF < const MOEOT &, const MOEOT &, const Type >
* Nothing to do
* @param _pop the population
*/
virtual void setup(const eoPop < MOEOT > & _pop)
virtual void setup(const eoPop < MOEOT > & /*_pop*/)
{}
@ -62,7 +62,7 @@ class moeoDistance : public eoBF < const MOEOT &, const MOEOT &, const Type >
* @param _max upper bound
* @param _obj the objective index
*/
virtual void setup(double _min, double _max, unsigned int _obj)
virtual void setup(double /*_min*/, double /*_max*/, unsigned int /*_obj*/)
{}
@ -71,7 +71,7 @@ class moeoDistance : public eoBF < const MOEOT &, const MOEOT &, const Type >
* @param _realInterval the eoRealInterval object
* @param _obj the objective index
*/
virtual void setup(eoRealInterval _realInterval, unsigned int _obj)
virtual void setup(eoRealInterval /*_realInterval*/, unsigned int /*_obj*/)
{}
};

View file

@ -100,7 +100,7 @@ class moeoCrowdingDiversityAssignment : public moeoDiversityAssignment < MOEOT >
* @param _objVec the objective vector
* @warning NOT IMPLEMENTED, DO NOTHING !
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/)
{
std::cout << "WARNING : updateByDeleting not implemented in moeoCrowdingDiversityAssignment" << std::endl;
}

View file

@ -66,7 +66,7 @@ public:
* @param _objVec the objective vector
* @warning NOT IMPLEMENTED, DO NOTHING !
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/)
{
std::cout << "WARNING : updateByDeleting not implemented in moeoFrontByFrontCrowdingDistanceDiversityAssignment" << std::endl;
}

View file

@ -78,7 +78,7 @@ class moeoFrontByFrontSharingDiversityAssignment : public moeoSharingDiversityAs
* @param _objVec the objective vector
* @warning NOT IMPLEMENTED, DO NOTHING !
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/)
{
std::cout << "WARNING : updateByDeleting not implemented in moeoSharingDiversityAssignment" << std::endl;
}

View file

@ -143,7 +143,7 @@ public:
* @param _objVec the objective vector
* @warning NOT IMPLEMENTED, DOES NOTHING !
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/)
{
std::cout << "WARNING : updateByDeleting not implemented in moeoNearestNeighborDiversityAssignment" << std::endl;
}

View file

@ -102,7 +102,7 @@ class moeoSharingDiversityAssignment : public moeoDiversityAssignment < MOEOT >
* @param _objVec the objective vector
* @warning NOT IMPLEMENTED, DO NOTHING !
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/)
{
std::cout << "WARNING : updateByDeleting not implemented in moeoSharingDiversityAssignment" << std::endl;
}

View file

@ -66,7 +66,7 @@ bool testDirRes(std::string _dirName, bool _erase);
* @param _archive the archive of non-dominated solutions
*/
template < class MOEOT >
eoCheckPoint < MOEOT > & do_make_checkpoint_moeo (eoParser & _parser, eoState & _state, eoEvalFuncCounter < MOEOT > & _eval, eoContinue < MOEOT > & _continue, eoPop < MOEOT > & _pop, moeoArchive < MOEOT > & _archive)
eoCheckPoint < MOEOT > & do_make_checkpoint_moeo (eoParser & _parser, eoState & _state, eoEvalFuncCounter < MOEOT > & /*_eval*/, eoContinue < MOEOT > & _continue, eoPop < MOEOT > & _pop, moeoArchive < MOEOT > & _archive)
{
eoCheckPoint < MOEOT > & checkpoint = _state.storeFunctor(new eoCheckPoint < MOEOT > (_continue));
/* the objective vector type */

View file

@ -85,7 +85,7 @@
* @param _archive the archive of non-dominated solutions
*/
template < class MOEOT >
moeoEA < MOEOT > & do_make_ea_moeo(eoParser & _parser, eoState & _state, eoEvalFunc < MOEOT > & _eval, eoContinue < MOEOT > & _continue, eoGenOp < MOEOT > & _op, moeoArchive < MOEOT > & _archive)
moeoEA < MOEOT > & do_make_ea_moeo(eoParser & _parser, eoState & _state, eoEvalFunc < MOEOT > & _eval, eoContinue < MOEOT > & _continue, eoGenOp < MOEOT > & _op, moeoArchive < MOEOT > & /*_archive*/)
{
/* the objective vector type */

View file

@ -113,12 +113,12 @@ class moeoAggregationFitnessAssignment : public moeoSingleObjectivization < MOEO
* @param _pop the population
* @param _objVec the objective vector
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec){}
void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/){}
private:
class DummyEval: public eoEvalFunc<MOEOT>{
void operator()(MOEOT &moeo){}
void operator()(MOEOT &/*moeo*/){}
}defaultEval;
//the vector of weight

View file

@ -135,7 +135,7 @@ class moeoConstraintFitnessAssignment : public moeoSingleObjectivization < MOEOT
* @param _pop the population
* @param _objVec the objective vector
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/)
{
//std::cout << "WARNING : updateByDeleting not implemented in moeoAssignmentFitnessAssignment" << std::endl;
}
@ -144,7 +144,7 @@ class moeoConstraintFitnessAssignment : public moeoSingleObjectivization < MOEOT
//dummy evaluation function
class DummyEval: public eoEvalFunc<MOEOT>{
void operator()(MOEOT &moeo){
void operator()(MOEOT &/*moeo*/){
}
} defaultEval;

View file

@ -119,7 +119,7 @@ public:
* @param _pop the population
* @param _objVec the objective vector
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/)
{
std::cout << "WARNING : updateByDeleting not implemented in moeoDominanceCountFitnessAssignment" << std::endl;
}

View file

@ -123,7 +123,7 @@ public:
* @param _pop the population
* @param _objVec the objective vector
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/)
{
std::cout << "WARNING : updateByDeleting not implemented in moeoDominanceCountRankingFitnessAssignment" << std::endl;
}

View file

@ -123,7 +123,7 @@ public:
* @param _pop the population
* @param _objVec the objective vector
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/)
{
std::cout << "WARNING : updateByDeleting not implemented in moeoDominanceRankFitnessAssignment" << std::endl;
}

View file

@ -74,7 +74,7 @@ class moeoDummyFitnessAssignment : public moeoFitnessAssignment < MOEOT >
* @param _pop the population
* @param _objVec the objective vector
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/)
{
// nothing to do... ;-)
}

View file

@ -108,8 +108,8 @@ class moeoDMLSMonOp : public eoMonOp < typename Neighbor::EOT >
tmp = rng.random(dmlsArchive.size());
_moeo = dmlsArchive[tmp];
defaultContinuator.totalGenerations(defaultContinuator.totalGenerations());
if(verbose)
std::cout << "moeoDMLSMonOp: dmls stop" << std::endl << std::endl;
if(verbose) {
std::cout << "moeoDMLSMonOp: dmls stop" << std::endl << std::endl; }
return false;
}

View file

@ -55,7 +55,7 @@ class moeoHyperVolumeMetric : public moeoVectorUnaryMetric < ObjectiveVector , d
* @param _normalize allow to normalize data (default true)
* @param _rho coefficient to determine the reference point.
*/
moeoHyperVolumeMetric(bool _normalize=true, double _rho=1.1): normalize(_normalize), rho(_rho), ref_point(NULL){
moeoHyperVolumeMetric(bool _normalize=true, double _rho=1.1): normalize(_normalize), rho(_rho) {
bounds.resize(ObjectiveVector::Traits::nObjectives());
// initialize bounds in case someone does not want to use them
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
@ -69,7 +69,7 @@ class moeoHyperVolumeMetric : public moeoVectorUnaryMetric < ObjectiveVector , d
* @param _normalize allow to normalize data (default true)
* @param _ref_point the reference point
*/
moeoHyperVolumeMetric(bool _normalize=true, ObjectiveVector& _ref_point=NULL): normalize(_normalize), rho(0.0), ref_point(_ref_point){
moeoHyperVolumeMetric(bool _normalize, ObjectiveVector& _ref_point): normalize(_normalize), rho(0.0), ref_point(_ref_point){
bounds.resize(ObjectiveVector::Traits::nObjectives());
// initialize bounds in case someone does not want to use them
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
@ -318,8 +318,8 @@ class moeoHyperVolumeMetric : public moeoVectorUnaryMetric < ObjectiveVector , d
//if there are less than 3 objectifs take the fisrt objectif of the first point of front to begin computation of hypervolume
if(_no_objectives < 3){
if(_no_objectives < 1)
throw("Error in moeoHyperVolumeUnaryMetric::calc_hypervolume -> argument3: _no_objectives must be greater than 0");
if(_no_objectives < 1) {
throw("Error in moeoHyperVolumeUnaryMetric::calc_hypervolume -> argument3: _no_objectives must be greater than 0"); }
temp_vol=_front[0][0];
}
//else if there at least 3 objectives, a recursive computation of hypervolume starts with _no_objectives -1 on the filter_nondominated_set calculating previously.

Some files were not shown because too many files have changed in this diff Show more