From bcf37466adfb6fab82ba90730534e2b39d94a3d3 Mon Sep 17 00:00:00 2001 From: Sergio Vieira Date: Thu, 27 Jul 2017 12:58:42 -0300 Subject: [PATCH 01/29] - Adds CMake files --- CMakeLists.txt | 59 +++++++++++++++++++ src/CMakeLists.txt | 9 +++ src/core/CMakeLists.txt | 2 + src/encodings/CMakeLists.txt | 2 + src/encodings/solutionType/CMakeLists.txt | 2 + src/encodings/variable/CMakeLists.txt | 2 + src/experiments/CMakeLists.txt | 3 + src/experiments/main/CMakeLists.txt | 2 + src/experiments/settings/CMakeLists.txt | 2 + src/experiments/util/CMakeLists.txt | 2 + src/main/CMakeLists.txt | 2 + src/metaheuristics/CMakeLists.txt | 9 +++ src/metaheuristics/gde3/CMakeLists.txt | 2 + src/metaheuristics/mochc/CMakeLists.txt | 2 + src/metaheuristics/moead/CMakeLists.txt | 2 + src/metaheuristics/nsgaII/CMakeLists.txt | 2 + src/metaheuristics/omopso/CMakeLists.txt | 2 + src/metaheuristics/paes/CMakeLists.txt | 2 + .../singleObjective/CMakeLists.txt | 4 ++ .../singleObjective/cmaes/CMakeLists.txt | 1 + .../cmaes/utils/CMakeLists.txt | 2 + .../differentialEvolution/CMakeLists.txt | 2 + .../geneticAlgorithm/CMakeLists.txt | 2 + .../particleSwarmOptimization/CMakeLists.txt | 2 + src/metaheuristics/smpso/CMakeLists.txt | 2 + src/metaheuristics/smsemoa/CMakeLists.txt | 2 + src/operators/CMakeLists.txt | 3 + src/operators/crossover/CMakeLists.txt | 2 + src/operators/mutation/CMakeLists.txt | 2 + src/operators/selection/CMakeLists.txt | 2 + src/problems/CMakeLists.txt | 4 ++ src/problems/DTLZ/CMakeLists.txt | 2 + src/problems/LZ09/CMakeLists.txt | 2 + src/problems/ZDT/CMakeLists.txt | 2 + src/problems/singleObjective/CMakeLists.txt | 1 + .../cec2005Competition/CMakeLists.txt | 2 + src/qualityIndicator/CMakeLists.txt | 3 + .../fastHypervolume/CMakeLists.txt | 2 + src/qualityIndicator/main/CMakeLists.txt | 2 + src/qualityIndicator/util/CMakeLists.txt | 2 + src/util/CMakeLists.txt | 3 + src/util/archive/CMakeLists.txt | 2 + src/util/comparators/CMakeLists.txt | 2 + src/util/wrapper/CMakeLists.txt | 2 + 44 files changed, 165 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 src/CMakeLists.txt create mode 100644 src/core/CMakeLists.txt create mode 100644 src/encodings/CMakeLists.txt create mode 100644 src/encodings/solutionType/CMakeLists.txt create mode 100644 src/encodings/variable/CMakeLists.txt create mode 100644 src/experiments/CMakeLists.txt create mode 100644 src/experiments/main/CMakeLists.txt create mode 100644 src/experiments/settings/CMakeLists.txt create mode 100644 src/experiments/util/CMakeLists.txt create mode 100644 src/main/CMakeLists.txt create mode 100644 src/metaheuristics/CMakeLists.txt create mode 100644 src/metaheuristics/gde3/CMakeLists.txt create mode 100644 src/metaheuristics/mochc/CMakeLists.txt create mode 100644 src/metaheuristics/moead/CMakeLists.txt create mode 100644 src/metaheuristics/nsgaII/CMakeLists.txt create mode 100644 src/metaheuristics/omopso/CMakeLists.txt create mode 100644 src/metaheuristics/paes/CMakeLists.txt create mode 100644 src/metaheuristics/singleObjective/CMakeLists.txt create mode 100644 src/metaheuristics/singleObjective/cmaes/CMakeLists.txt create mode 100644 src/metaheuristics/singleObjective/cmaes/utils/CMakeLists.txt create mode 100644 src/metaheuristics/singleObjective/differentialEvolution/CMakeLists.txt create mode 100644 src/metaheuristics/singleObjective/geneticAlgorithm/CMakeLists.txt create mode 100644 src/metaheuristics/singleObjective/particleSwarmOptimization/CMakeLists.txt create mode 100644 src/metaheuristics/smpso/CMakeLists.txt create mode 100644 src/metaheuristics/smsemoa/CMakeLists.txt create mode 100644 src/operators/CMakeLists.txt create mode 100644 src/operators/crossover/CMakeLists.txt create mode 100644 src/operators/mutation/CMakeLists.txt create mode 100644 src/operators/selection/CMakeLists.txt create mode 100644 src/problems/CMakeLists.txt create mode 100644 src/problems/DTLZ/CMakeLists.txt create mode 100644 src/problems/LZ09/CMakeLists.txt create mode 100644 src/problems/ZDT/CMakeLists.txt create mode 100644 src/problems/singleObjective/CMakeLists.txt create mode 100644 src/problems/singleObjective/cec2005Competition/CMakeLists.txt create mode 100644 src/qualityIndicator/CMakeLists.txt create mode 100644 src/qualityIndicator/fastHypervolume/CMakeLists.txt create mode 100644 src/qualityIndicator/main/CMakeLists.txt create mode 100644 src/qualityIndicator/util/CMakeLists.txt create mode 100644 src/util/CMakeLists.txt create mode 100644 src/util/archive/CMakeLists.txt create mode 100644 src/util/comparators/CMakeLists.txt create mode 100644 src/util/wrapper/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..ae6bb5e --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,59 @@ +cmake_minimum_required(VERSION 3.6) +project(jMetalCpp) +set(CMAKE_CXX_STANDARD 11) + +define_property(GLOBAL PROPERTY SOURCE_LIST BRIEF_DOCS "Global list of source code" FULL_DOCS "Global list of source code") +set_property(GLOBAL PROPERTY SOURCE_LIST "") + +macro(LIST_APPEND var) + set_property(GLOBAL APPEND PROPERTY SOURCE_LIST "${var}") +endmacro(LIST_APPEND) + +include_directories( + ${PROJECT_SOURCE_DIR}/src + ${PROJECT_SOURCE_DIR}/src/core + ${PROJECT_SOURCE_DIR}/src/encodings + ${PROJECT_SOURCE_DIR}/src/encodings/solutionType + ${PROJECT_SOURCE_DIR}/src/encodings/variable + ${PROJECT_SOURCE_DIR}/src/experiments + ${PROJECT_SOURCE_DIR}/src/experiments/main + ${PROJECT_SOURCE_DIR}/src/experiments/settings + ${PROJECT_SOURCE_DIR}/src/experiments/util + ${PROJECT_SOURCE_DIR}/src/main + ${PROJECT_SOURCE_DIR}/src/metaheuristics + ${PROJECT_SOURCE_DIR}/src/metaheuristics/gde3 + ${PROJECT_SOURCE_DIR}/src/metaheuristics/mochc + ${PROJECT_SOURCE_DIR}/src/metaheuristics/moead + ${PROJECT_SOURCE_DIR}/src/metaheuristics/nsgaII + ${PROJECT_SOURCE_DIR}/src/metaheuristics/omopso + ${PROJECT_SOURCE_DIR}/src/metaheuristics/paes + ${PROJECT_SOURCE_DIR}/src/metaheuristics/singleObjective + ${PROJECT_SOURCE_DIR}/src/metaheuristics/singleObjective/cmaes + ${PROJECT_SOURCE_DIR}/src/metaheuristics/singleObjective/cmaes/utils + ${PROJECT_SOURCE_DIR}/src/metaheuristics/singleObjective/differentialEvolution + ${PROJECT_SOURCE_DIR}/src/metaheuristics/singleObjective/geneticAlgorithm + ${PROJECT_SOURCE_DIR}/src/metaheuristics/singleObjective/particleSwarmOptimization + ${PROJECT_SOURCE_DIR}/src/metaheuristics/smpso + ${PROJECT_SOURCE_DIR}/src/metaheuristics/smsemoa + ${PROJECT_SOURCE_DIR}/src/operators + ${PROJECT_SOURCE_DIR}/src/operators/crossover + ${PROJECT_SOURCE_DIR}/src/operators/mutation + ${PROJECT_SOURCE_DIR}/src/operators/selection + ${PROJECT_SOURCE_DIR}/src/problems + ${PROJECT_SOURCE_DIR}/src/problems/DTLZ + ${PROJECT_SOURCE_DIR}/src/problems/LZ09 + ${PROJECT_SOURCE_DIR}/src/problems/singleObjective + ${PROJECT_SOURCE_DIR}/src/problems/singleObjective/cec2005Competition + ${PROJECT_SOURCE_DIR}/src/problems/ZDT + ${PROJECT_SOURCE_DIR}/src/qualityIndicator + ${PROJECT_SOURCE_DIR}/src/qualityIndicator/fastHypervolume + ${PROJECT_SOURCE_DIR}/src/qualityIndicator/main + ${PROJECT_SOURCE_DIR}/src/qualityIndicator/util + ${PROJECT_SOURCE_DIR}/src/util + ${PROJECT_SOURCE_DIR}/src/util/archive + ${PROJECT_SOURCE_DIR}/src/util/comparators + ${PROJECT_SOURCE_DIR}/src/util/wrapper + ) +add_subdirectory(${PROJECT_SOURCE_DIR}/src) +get_property(my_source_list GLOBAL PROPERTY SOURCE_LIST) +add_library(${PROJECT_NAME} SHARED ${my_source_list}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..babc786 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,9 @@ +add_subdirectory(core) +add_subdirectory(encodings) +add_subdirectory(experiments) +add_subdirectory(main) +add_subdirectory(metaheuristics) +add_subdirectory(operators) +add_subdirectory(problems) +add_subdirectory(qualityIndicator) +add_subdirectory(util) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/core/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/encodings/CMakeLists.txt b/src/encodings/CMakeLists.txt new file mode 100644 index 0000000..d7041cd --- /dev/null +++ b/src/encodings/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(solutionType) +add_subdirectory(variable) \ No newline at end of file diff --git a/src/encodings/solutionType/CMakeLists.txt b/src/encodings/solutionType/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/encodings/solutionType/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/encodings/variable/CMakeLists.txt b/src/encodings/variable/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/encodings/variable/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/experiments/CMakeLists.txt b/src/experiments/CMakeLists.txt new file mode 100644 index 0000000..5603ab0 --- /dev/null +++ b/src/experiments/CMakeLists.txt @@ -0,0 +1,3 @@ +add_subdirectory(main) +add_subdirectory(settings) +add_subdirectory(util) diff --git a/src/experiments/main/CMakeLists.txt b/src/experiments/main/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/experiments/main/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/experiments/settings/CMakeLists.txt b/src/experiments/settings/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/experiments/settings/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/experiments/util/CMakeLists.txt b/src/experiments/util/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/experiments/util/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/main/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/metaheuristics/CMakeLists.txt b/src/metaheuristics/CMakeLists.txt new file mode 100644 index 0000000..1f8a9fe --- /dev/null +++ b/src/metaheuristics/CMakeLists.txt @@ -0,0 +1,9 @@ +add_subdirectory(gde3) +add_subdirectory(mochc) +add_subdirectory(moead) +add_subdirectory(nsgaII) +add_subdirectory(omopso) +add_subdirectory(paes) +add_subdirectory(singleObjective) +add_subdirectory(smpso) +add_subdirectory(smsemoa) \ No newline at end of file diff --git a/src/metaheuristics/gde3/CMakeLists.txt b/src/metaheuristics/gde3/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/metaheuristics/gde3/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/metaheuristics/mochc/CMakeLists.txt b/src/metaheuristics/mochc/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/metaheuristics/mochc/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/metaheuristics/moead/CMakeLists.txt b/src/metaheuristics/moead/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/metaheuristics/moead/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/metaheuristics/nsgaII/CMakeLists.txt b/src/metaheuristics/nsgaII/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/metaheuristics/nsgaII/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/metaheuristics/omopso/CMakeLists.txt b/src/metaheuristics/omopso/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/metaheuristics/omopso/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/metaheuristics/paes/CMakeLists.txt b/src/metaheuristics/paes/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/metaheuristics/paes/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/metaheuristics/singleObjective/CMakeLists.txt b/src/metaheuristics/singleObjective/CMakeLists.txt new file mode 100644 index 0000000..17ef0be --- /dev/null +++ b/src/metaheuristics/singleObjective/CMakeLists.txt @@ -0,0 +1,4 @@ +add_subdirectory(cmaes) +add_subdirectory(differentialEvolution) +add_subdirectory(geneticAlgorithm) +add_subdirectory(particleSwarmOptimization) \ No newline at end of file diff --git a/src/metaheuristics/singleObjective/cmaes/CMakeLists.txt b/src/metaheuristics/singleObjective/cmaes/CMakeLists.txt new file mode 100644 index 0000000..47202fc --- /dev/null +++ b/src/metaheuristics/singleObjective/cmaes/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(utils) \ No newline at end of file diff --git a/src/metaheuristics/singleObjective/cmaes/utils/CMakeLists.txt b/src/metaheuristics/singleObjective/cmaes/utils/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/metaheuristics/singleObjective/cmaes/utils/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/metaheuristics/singleObjective/differentialEvolution/CMakeLists.txt b/src/metaheuristics/singleObjective/differentialEvolution/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/metaheuristics/singleObjective/differentialEvolution/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/metaheuristics/singleObjective/geneticAlgorithm/CMakeLists.txt b/src/metaheuristics/singleObjective/geneticAlgorithm/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/metaheuristics/singleObjective/geneticAlgorithm/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/CMakeLists.txt b/src/metaheuristics/singleObjective/particleSwarmOptimization/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/metaheuristics/smpso/CMakeLists.txt b/src/metaheuristics/smpso/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/metaheuristics/smpso/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/metaheuristics/smsemoa/CMakeLists.txt b/src/metaheuristics/smsemoa/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/metaheuristics/smsemoa/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/operators/CMakeLists.txt b/src/operators/CMakeLists.txt new file mode 100644 index 0000000..1107f2e --- /dev/null +++ b/src/operators/CMakeLists.txt @@ -0,0 +1,3 @@ +add_subdirectory(crossover) +add_subdirectory(mutation) +add_subdirectory(selection) \ No newline at end of file diff --git a/src/operators/crossover/CMakeLists.txt b/src/operators/crossover/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/operators/crossover/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/operators/mutation/CMakeLists.txt b/src/operators/mutation/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/operators/mutation/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/operators/selection/CMakeLists.txt b/src/operators/selection/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/operators/selection/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/problems/CMakeLists.txt b/src/problems/CMakeLists.txt new file mode 100644 index 0000000..99cd101 --- /dev/null +++ b/src/problems/CMakeLists.txt @@ -0,0 +1,4 @@ +add_subdirectory(DTLZ) +add_subdirectory(LZ09) +add_subdirectory(singleObjective) +add_subdirectory(ZDT) \ No newline at end of file diff --git a/src/problems/DTLZ/CMakeLists.txt b/src/problems/DTLZ/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/problems/DTLZ/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/problems/LZ09/CMakeLists.txt b/src/problems/LZ09/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/problems/LZ09/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/problems/ZDT/CMakeLists.txt b/src/problems/ZDT/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/problems/ZDT/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/problems/singleObjective/CMakeLists.txt b/src/problems/singleObjective/CMakeLists.txt new file mode 100644 index 0000000..9f4a222 --- /dev/null +++ b/src/problems/singleObjective/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(cec2005Competition) \ No newline at end of file diff --git a/src/problems/singleObjective/cec2005Competition/CMakeLists.txt b/src/problems/singleObjective/cec2005Competition/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/problems/singleObjective/cec2005Competition/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/qualityIndicator/CMakeLists.txt b/src/qualityIndicator/CMakeLists.txt new file mode 100644 index 0000000..0b76022 --- /dev/null +++ b/src/qualityIndicator/CMakeLists.txt @@ -0,0 +1,3 @@ +add_subdirectory(fastHypervolume) +add_subdirectory(main) +add_subdirectory(util) \ No newline at end of file diff --git a/src/qualityIndicator/fastHypervolume/CMakeLists.txt b/src/qualityIndicator/fastHypervolume/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/qualityIndicator/fastHypervolume/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/qualityIndicator/main/CMakeLists.txt b/src/qualityIndicator/main/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/qualityIndicator/main/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/qualityIndicator/util/CMakeLists.txt b/src/qualityIndicator/util/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/qualityIndicator/util/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt new file mode 100644 index 0000000..f8d4f34 --- /dev/null +++ b/src/util/CMakeLists.txt @@ -0,0 +1,3 @@ +add_subdirectory(archive) +add_subdirectory(comparators) +add_subdirectory(wrapper) \ No newline at end of file diff --git a/src/util/archive/CMakeLists.txt b/src/util/archive/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/util/archive/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/util/comparators/CMakeLists.txt b/src/util/comparators/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/util/comparators/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) diff --git a/src/util/wrapper/CMakeLists.txt b/src/util/wrapper/CMakeLists.txt new file mode 100644 index 0000000..c384717 --- /dev/null +++ b/src/util/wrapper/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB SOURCES *.cpp) +LIST_APPEND(${SOURCES}) From 20923874a287c81ec92cee7974deed9453fe86b0 Mon Sep 17 00:00:00 2001 From: Sergio Vieira Date: Thu, 27 Jul 2017 13:00:32 -0300 Subject: [PATCH 02/29] Updates gitigore --- .gitignore | 297 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 297 insertions(+) diff --git a/.gitignore b/.gitignore index d340a43..b9bdf52 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Ignore the build and lib dirs build/ lib/ +vs/ # Ignore any executables bin/ @@ -18,3 +19,299 @@ nbproject/ *.xcworkspacedata *.xcuserstate *.xcsettings + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Typescript v1 declaration files +typings/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs \ No newline at end of file From 3b0141f11f4b309d6ec085305e7b4b07507396b4 Mon Sep 17 00:00:00 2001 From: Sergio Vieira Date: Thu, 27 Jul 2017 13:01:29 -0300 Subject: [PATCH 03/29] - Removed memory leaks - Some code improvements --- src/main/NSGAIIbin_main.cpp | 4 ++-- src/main/gGAbin_main.cpp | 4 ++-- src/operators/mutation/BitFlipMutation.cpp | 1 + src/problems/Srinivas.cpp | 2 +- src/qualityIndicator/fastHypervolume/FastHypervolume.cpp | 2 +- src/util/AdaptiveGrid.cpp | 4 ++++ src/util/Distance.cpp | 2 +- 7 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/NSGAIIbin_main.cpp b/src/main/NSGAIIbin_main.cpp index 13ed677..49af279 100644 --- a/src/main/NSGAIIbin_main.cpp +++ b/src/main/NSGAIIbin_main.cpp @@ -56,7 +56,7 @@ int main(int argc, char ** argv) { strcpy(argv[0], "200"); argv[1] = new char[1]; strcpy(argv[1], "2"); - char * problemName = new char[6]; + char * problemName = new char[7]; strcpy(problemName, "OneMax"); problem = ProblemFactory::getProblem(problemName, 2, argv); @@ -64,7 +64,7 @@ int main(int argc, char ** argv) { delete argv[0]; delete argv[1]; delete [] argv; - delete problemName; + delete [] problemName; } diff --git a/src/main/gGAbin_main.cpp b/src/main/gGAbin_main.cpp index 7e9e0e2..44b8d2c 100644 --- a/src/main/gGAbin_main.cpp +++ b/src/main/gGAbin_main.cpp @@ -53,7 +53,7 @@ int main(int argc, char ** argv) { strcpy(argv[0], "400"); argv[1] = new char[1]; strcpy(argv[1], "2"); - char * problemName = new char[6]; + char * problemName = new char[7]; strcpy(problemName, "OneMax"); problem = ProblemFactory::getProblem(problemName, 2, argv); @@ -61,7 +61,7 @@ int main(int argc, char ** argv) { delete argv[0]; delete argv[1]; delete [] argv; - delete problemName; + delete [] problemName; } diff --git a/src/operators/mutation/BitFlipMutation.cpp b/src/operators/mutation/BitFlipMutation.cpp index 09325ff..51ff7ea 100644 --- a/src/operators/mutation/BitFlipMutation.cpp +++ b/src/operators/mutation/BitFlipMutation.cpp @@ -54,6 +54,7 @@ void * BitFlipMutation::doMutation(double probability, Solution *solution) { if (PseudoRandom::randDouble() <= mutationProbability_) variable->flip(j) ; } + return nullptr; } // doMutation diff --git a/src/problems/Srinivas.cpp b/src/problems/Srinivas.cpp index 03648a6..3030b4e 100644 --- a/src/problems/Srinivas.cpp +++ b/src/problems/Srinivas.cpp @@ -129,6 +129,6 @@ void Srinivas::evaluateConstraints(Solution *solution) { solution->setOverallConstraintViolation(total); solution->setNumberOfViolatedConstraints(number); - + delete [] constraint; } // evaluateConstraints diff --git a/src/qualityIndicator/fastHypervolume/FastHypervolume.cpp b/src/qualityIndicator/fastHypervolume/FastHypervolume.cpp index b338d7b..dd7a556 100644 --- a/src/qualityIndicator/fastHypervolume/FastHypervolume.cpp +++ b/src/qualityIndicator/fastHypervolume/FastHypervolume.cpp @@ -47,7 +47,7 @@ FastHypervolume::~FastHypervolume() { } // ~FastHypervolume double FastHypervolume::computeHypervolume(SolutionSet* solutionSet) { - double hv; + double hv = 0.0; if (solutionSet->size() == 0) { hv = 0.0; } else { diff --git a/src/util/AdaptiveGrid.cpp b/src/util/AdaptiveGrid.cpp index 983ce38..7cd1cee 100644 --- a/src/util/AdaptiveGrid.cpp +++ b/src/util/AdaptiveGrid.cpp @@ -176,7 +176,10 @@ int AdaptiveGrid::location(Solution * solution){ if ((solution->getObjective(obj) > upperLimits_[obj]) || (solution->getObjective(obj) < lowerLimits_[obj])) + { + delete [] position; return -1; + } else if (solution->getObjective(obj) ==lowerLimits_[obj]) position[obj] = 0; else if (solution->getObjective(obj) ==upperLimits_[obj]) @@ -202,6 +205,7 @@ int AdaptiveGrid::location(Solution * solution){ for (int obj = 0; obj < objectives_; obj++) { location += position[obj] * (int)pow(2.0,obj * bisections_); } + delete [] position; return location; } //location diff --git a/src/util/Distance.cpp b/src/util/Distance.cpp index 25cfb4e..b62040a 100644 --- a/src/util/Distance.cpp +++ b/src/util/Distance.cpp @@ -49,7 +49,7 @@ double ** Distance::distanceMatrix(SolutionSet * solutionSet) { //The matrix of distances int size = solutionSet->size(); - double ** distance;// = new double [size][size]; + double ** distance = nullptr;// = new double [size][size]; for (int i = 0; i < solutionSet->size(); i++){ distance[i] = new double[size]; } From 731b06fc0dc125c0ea62e86c5f6977473a6a3c72 Mon Sep 17 00:00:00 2001 From: Sergio Vieira Date: Thu, 27 Jul 2017 13:16:05 -0300 Subject: [PATCH 04/29] Change source code format style --- src/core/Algorithm.cpp | 46 +- src/core/Algorithm.h | 33 +- src/core/Operator.cpp | 18 +- src/core/Operator.h | 19 +- src/core/Problem.cpp | 132 +- src/core/Problem.h | 65 +- src/core/Solution.cpp | 423 +++--- src/core/Solution.h | 111 +- src/core/SolutionSet.cpp | 397 ++--- src/core/SolutionSet.h | 63 +- src/core/SolutionType.cpp | 32 +- src/core/SolutionType.h | 13 +- src/core/Variable.cpp | 21 +- src/core/Variable.h | 27 +- .../solutionType/ArrayRealSolutionType.cpp | 37 +- .../solutionType/ArrayRealSolutionType.h | 9 +- .../solutionType/BinaryRealSolutionType.cpp | 39 +- .../solutionType/BinaryRealSolutionType.h | 7 +- .../solutionType/BinarySolutionType.cpp | 55 +- .../solutionType/BinarySolutionType.h | 9 +- .../solutionType/RealSolutionType.cpp | 33 +- src/encodings/solutionType/RealSolutionType.h | 7 +- src/encodings/variable/ArrayReal.cpp | 168 ++- src/encodings/variable/ArrayReal.h | 45 +- src/encodings/variable/Binary.cpp | 163 ++- src/encodings/variable/Binary.h | 41 +- src/encodings/variable/BinaryReal.cpp | 83 +- src/encodings/variable/BinaryReal.h | 33 +- src/encodings/variable/Real.cpp | 75 +- src/encodings/variable/Real.h | 33 +- src/experiments/Experiment.cpp | 135 +- src/experiments/Experiment.h | 23 +- src/experiments/ExperimentExecution.cpp | 135 +- src/experiments/ExperimentExecution.h | 39 +- src/experiments/ExperimentIndividual.cpp | 24 +- src/experiments/ExperimentIndividual.h | 17 +- src/experiments/ExperimentReport.cpp | 1280 +++++++++-------- src/experiments/ExperimentReport.h | 51 +- src/experiments/Settings.cpp | 13 +- src/experiments/Settings.h | 19 +- .../main/StandardStudyExecution.cpp | 107 +- src/experiments/main/StandardStudyExecution.h | 7 +- .../main/StandardStudyExecutionSO.cpp | 115 +- .../main/StandardStudyExecutionSO.h | 7 +- .../main/StandardStudyReportPF.cpp | 120 +- .../main/StandardStudyReportRF.cpp | 91 +- .../main/StandardStudyReportSO.cpp | 93 +- src/experiments/settings/DE_Settings.cpp | 74 +- src/experiments/settings/DE_Settings.h | 27 +- src/experiments/settings/GDE3_Settings.cpp | 68 +- src/experiments/settings/GDE3_Settings.h | 25 +- src/experiments/settings/NSGAII_Settings.cpp | 92 +- src/experiments/settings/NSGAII_Settings.h | 31 +- src/experiments/settings/PSO_Settings.cpp | 58 +- src/experiments/settings/PSO_Settings.h | 23 +- src/experiments/settings/SMPSO_Settings.cpp | 60 +- src/experiments/settings/SMPSO_Settings.h | 25 +- src/experiments/settings/gGA_Settings.cpp | 92 +- src/experiments/settings/gGA_Settings.h | 31 +- src/experiments/settings/ssGA_Settings.cpp | 92 +- src/experiments/settings/ssGA_Settings.h | 31 +- src/experiments/util/FileUtils.cpp | 72 +- src/experiments/util/FileUtils.h | 13 +- src/experiments/util/RBoxplot.cpp | 142 +- src/experiments/util/RBoxplot.h | 7 +- src/experiments/util/RWilcoxon.cpp | 550 +++---- src/experiments/util/RWilcoxon.h | 7 +- src/experiments/util/RunExperiment.cpp | 247 ++-- src/experiments/util/RunExperiment.h | 53 +- src/experiments/util/Statistics.cpp | 63 +- src/experiments/util/Statistics.h | 7 +- src/main/CMAES_main.cpp | 74 +- src/main/DE_main.cpp | 142 +- src/main/FastSMSEMOA_main.cpp | 170 +-- src/main/GDE3_main.cpp | 136 +- src/main/MOCHC_main.cpp | 142 +- src/main/MOEAD_main.cpp | 174 +-- src/main/NSGAII_main.cpp | 136 +- src/main/NSGAIIbin_main.cpp | 174 +-- src/main/OMOPSO_main.cpp | 163 ++- src/main/PAES_main.cpp | 140 +- src/main/PSO_main.cpp | 90 +- src/main/SMPSO_main.cpp | 126 +- src/main/SMPSOhv_main.cpp | 145 +- src/main/SMSEMOA_main.cpp | 170 +-- src/main/StandardPSO2007_main.cpp | 74 +- src/main/StandardPSO2011_main.cpp | 74 +- src/main/gGA_main.cpp | 150 +- src/main/gGAbin_main.cpp | 174 +-- src/main/ssGA_main.cpp | 148 +- src/main/ssNSGAII_main.cpp | 160 ++- src/metaheuristics/gde3/GDE3.cpp | 318 ++-- src/metaheuristics/gde3/GDE3.h | 13 +- src/metaheuristics/mochc/MOCHC.cpp | 399 ++--- src/metaheuristics/mochc/MOCHC.h | 19 +- src/metaheuristics/moead/MOEAD.cpp | 703 ++++----- src/metaheuristics/moead/MOEAD.h | 111 +- src/metaheuristics/moead/UtilsMOEAD.cpp | 118 +- src/metaheuristics/moead/UtilsMOEAD.h | 13 +- src/metaheuristics/nsgaII/NSGAII.cpp | 289 ++-- src/metaheuristics/nsgaII/NSGAII.h | 7 +- src/metaheuristics/nsgaII/ssNSGAII.cpp | 299 ++-- src/metaheuristics/nsgaII/ssNSGAII.h | 13 +- src/metaheuristics/omopso/OMOPSO.cpp | 438 +++--- src/metaheuristics/omopso/OMOPSO.h | 245 ++-- src/metaheuristics/paes/paes.cpp | 93 +- src/metaheuristics/paes/paes.h | 9 +- .../singleObjective/cmaes/CMAES.cpp | 860 ++++++----- .../singleObjective/cmaes/CMAES.h | 27 +- .../cmaes/utils/UtilsCMAES.cpp | 612 ++++---- .../singleObjective/cmaes/utils/UtilsCMAES.h | 17 +- .../differentialEvolution/DE.cpp | 224 +-- .../differentialEvolution/DE.h | 7 +- .../singleObjective/geneticAlgorithm/gGA.cpp | 169 +-- .../singleObjective/geneticAlgorithm/gGA.h | 11 +- .../singleObjective/geneticAlgorithm/ssGA.cpp | 137 +- .../singleObjective/geneticAlgorithm/ssGA.h | 7 +- .../particleSwarmOptimization/PSO.cpp | 504 ++++--- .../particleSwarmOptimization/PSO.h | 139 +- .../StandardPSO2007.cpp | 419 +++--- .../StandardPSO2007.h | 57 +- .../StandardPSO2011.cpp | 470 +++--- .../StandardPSO2011.h | 59 +- src/metaheuristics/smpso/SMPSO.cpp | 594 ++++---- src/metaheuristics/smpso/SMPSO.h | 173 +-- src/metaheuristics/smpso/SMPSOhv.cpp | 502 ++++--- src/metaheuristics/smpso/SMPSOhv.h | 275 ++-- src/metaheuristics/smsemoa/FastSMSEMOA.cpp | 327 +++-- src/metaheuristics/smsemoa/FastSMSEMOA.h | 15 +- src/metaheuristics/smsemoa/SMSEMOA.cpp | 489 ++++--- src/metaheuristics/smsemoa/SMSEMOA.h | 15 +- src/operators/crossover/Crossover.cpp | 4 +- src/operators/crossover/Crossover.h | 7 +- .../DifferentialEvolutionCrossover.cpp | 450 +++--- .../DifferentialEvolutionCrossover.h | 25 +- src/operators/crossover/HUXCrossover.cpp | 101 +- src/operators/crossover/HUXCrossover.h | 13 +- src/operators/crossover/SBXCrossover.cpp | 262 ++-- src/operators/crossover/SBXCrossover.h | 23 +- .../crossover/SinglePointCrossover.cpp | 195 +-- .../crossover/SinglePointCrossover.h | 13 +- src/operators/mutation/BitFlipMutation.cpp | 40 +- src/operators/mutation/BitFlipMutation.h | 15 +- src/operators/mutation/Mutation.cpp | 2 +- src/operators/mutation/Mutation.h | 7 +- src/operators/mutation/NonUniformMutation.cpp | 112 +- src/operators/mutation/NonUniformMutation.h | 97 +- src/operators/mutation/PolynomialMutation.cpp | 102 +- src/operators/mutation/PolynomialMutation.h | 21 +- src/operators/mutation/UniformMutation.cpp | 66 +- src/operators/mutation/UniformMutation.h | 55 +- .../selection/BestSolutionSelection.cpp | 42 +- .../selection/BestSolutionSelection.h | 9 +- src/operators/selection/BinaryTournament.cpp | 56 +- src/operators/selection/BinaryTournament.h | 11 +- src/operators/selection/BinaryTournament2.cpp | 91 +- src/operators/selection/BinaryTournament2.h | 15 +- .../DifferentialEvolutionSelection.cpp | 56 +- .../DifferentialEvolutionSelection.h | 7 +- src/operators/selection/RandomSelection.cpp | 27 +- src/operators/selection/RandomSelection.h | 11 +- src/operators/selection/Selection.cpp | 2 +- src/operators/selection/Selection.h | 7 +- .../selection/WorstSolutionSelection.cpp | 42 +- .../selection/WorstSolutionSelection.h | 9 +- src/problems/DTLZ/DTLZ1.cpp | 142 +- src/problems/DTLZ/DTLZ1.h | 15 +- src/problems/DTLZ/DTLZ2.cpp | 152 +- src/problems/DTLZ/DTLZ2.h | 15 +- src/problems/DTLZ/DTLZ3.cpp | 124 +- src/problems/DTLZ/DTLZ3.h | 15 +- src/problems/DTLZ/DTLZ4.cpp | 152 +- src/problems/DTLZ/DTLZ4.h | 15 +- src/problems/DTLZ/DTLZ5.cpp | 150 +- src/problems/DTLZ/DTLZ5.h | 19 +- src/problems/DTLZ/DTLZ6.cpp | 150 +- src/problems/DTLZ/DTLZ6.h | 17 +- src/problems/DTLZ/DTLZ7.cpp | 135 +- src/problems/DTLZ/DTLZ7.h | 15 +- src/problems/Fonseca.cpp | 176 +-- src/problems/Fonseca.h | 13 +- src/problems/Kursawe.cpp | 164 ++- src/problems/Kursawe.h | 9 +- src/problems/LZ09/LZ09.cpp | 620 ++++---- src/problems/LZ09/LZ09.h | 25 +- src/problems/LZ09/LZ09_F1.cpp | 140 +- src/problems/LZ09/LZ09_F1.h | 15 +- src/problems/LZ09/LZ09_F2.cpp | 136 +- src/problems/LZ09/LZ09_F2.h | 15 +- src/problems/LZ09/LZ09_F3.cpp | 136 +- src/problems/LZ09/LZ09_F3.h | 15 +- src/problems/LZ09/LZ09_F4.cpp | 136 +- src/problems/LZ09/LZ09_F4.h | 15 +- src/problems/LZ09/LZ09_F5.cpp | 136 +- src/problems/LZ09/LZ09_F5.h | 15 +- src/problems/LZ09/LZ09_F6.cpp | 136 +- src/problems/LZ09/LZ09_F6.h | 15 +- src/problems/LZ09/LZ09_F7.cpp | 136 +- src/problems/LZ09/LZ09_F7.h | 15 +- src/problems/LZ09/LZ09_F8.cpp | 136 +- src/problems/LZ09/LZ09_F8.h | 15 +- src/problems/LZ09/LZ09_F9.cpp | 150 +- src/problems/LZ09/LZ09_F9.h | 15 +- src/problems/ProblemFactory.cpp | 976 +++++++------ src/problems/ProblemFactory.h | 9 +- src/problems/Schaffer.cpp | 81 +- src/problems/Schaffer.h | 9 +- src/problems/Srinivas.cpp | 186 +-- src/problems/Srinivas.h | 17 +- src/problems/Tanaka.cpp | 169 ++- src/problems/Tanaka.h | 21 +- src/problems/ZDT/ZDT1.cpp | 126 +- src/problems/ZDT/ZDT1.h | 15 +- src/problems/ZDT/ZDT2.cpp | 134 +- src/problems/ZDT/ZDT2.h | 15 +- src/problems/ZDT/ZDT3.cpp | 134 +- src/problems/ZDT/ZDT3.h | 17 +- src/problems/ZDT/ZDT4.cpp | 136 +- src/problems/ZDT/ZDT4.h | 17 +- src/problems/ZDT/ZDT5.cpp | 114 +- src/problems/ZDT/ZDT5.h | 17 +- src/problems/ZDT/ZDT6.cpp | 136 +- src/problems/ZDT/ZDT6.h | 17 +- .../singleObjective/CEC2005Problem.cpp | 130 +- src/problems/singleObjective/CEC2005Problem.h | 13 +- src/problems/singleObjective/Griewank.cpp | 110 +- src/problems/singleObjective/Griewank.h | 15 +- src/problems/singleObjective/OneMax.cpp | 66 +- src/problems/singleObjective/OneMax.h | 9 +- src/problems/singleObjective/Rastrigin.cpp | 137 +- src/problems/singleObjective/Rastrigin.h | 21 +- src/problems/singleObjective/Rosenbrock.cpp | 125 +- src/problems/singleObjective/Rosenbrock.h | 15 +- src/problems/singleObjective/Sphere.cpp | 127 +- src/problems/singleObjective/Sphere.h | 15 +- .../cec2005Competition/Benchmark.cpp | 693 +++++---- .../cec2005Competition/Benchmark.h | 118 +- .../cec2005Competition/F01ShiftedSphere.cpp | 36 +- .../cec2005Competition/F01ShiftedSphere.h | 27 +- .../cec2005Competition/F02ShiftedSchwefel.cpp | 36 +- .../cec2005Competition/F02ShiftedSchwefel.h | 27 +- .../F03ShiftedRotatedHighCondElliptic.cpp | 88 +- .../F03ShiftedRotatedHighCondElliptic.h | 39 +- .../F04ShiftedSchwefelNoise.cpp | 42 +- .../F04ShiftedSchwefelNoise.h | 27 +- .../F05SchwefelGlobalOptBound.cpp | 128 +- .../F05SchwefelGlobalOptBound.h | 31 +- .../F06ShiftedRosenbrock.cpp | 47 +- .../cec2005Competition/F06ShiftedRosenbrock.h | 27 +- .../F07ShiftedRotatedGriewank.cpp | 77 +- .../F07ShiftedRotatedGriewank.h | 37 +- .../F08ShiftedRotatedAckleyGlobalOptBound.cpp | 86 +- .../F08ShiftedRotatedAckleyGlobalOptBound.h | 37 +- .../F09ShiftedRastrigin.cpp | 36 +- .../cec2005Competition/F09ShiftedRastrigin.h | 27 +- .../F10ShiftedRotatedRastrigin.cpp | 77 +- .../F10ShiftedRotatedRastrigin.h | 37 +- .../F11ShiftedRotatedWeierstrass.cpp | 77 +- .../F11ShiftedRotatedWeierstrass.h | 43 +- .../cec2005Competition/F12Schwefel.cpp | 150 +- .../cec2005Competition/F12Schwefel.h | 33 +- .../F13ShiftedExpandedGriewankRosenbrock.cpp | 47 +- .../F13ShiftedExpandedGriewankRosenbrock.h | 27 +- .../F14ShiftedRotatedExpandedScaffer.cpp | 77 +- .../F14ShiftedRotatedExpandedScaffer.h | 37 +- .../F15HybridComposition1.cpp | 242 ++-- .../F15HybridComposition1.h | 62 +- .../F16RotatedHybridComposition1.cpp | 236 +-- .../F16RotatedHybridComposition1.h | 80 +- .../F17RotatedHybridComposition1Noise.cpp | 242 ++-- .../F17RotatedHybridComposition1Noise.h | 80 +- .../F18RotatedHybridComposition2.cpp | 241 ++-- .../F18RotatedHybridComposition2.h | 80 +- ...HybridComposition2NarrowBasinGlobalOpt.cpp | 241 ++-- ...edHybridComposition2NarrowBasinGlobalOpt.h | 80 +- ...otatedHybridComposition2GlobalOptBound.cpp | 248 ++-- ...0RotatedHybridComposition2GlobalOptBound.h | 80 +- .../F21RotatedHybridComposition3.cpp | 230 +-- .../F21RotatedHybridComposition3.h | 80 +- ...tedHybridComposition3HighCondNumMatrix.cpp | 230 +-- ...tatedHybridComposition3HighCondNumMatrix.h | 80 +- ...NoncontinuousRotatedHybridComposition3.cpp | 237 +-- ...23NoncontinuousRotatedHybridComposition3.h | 80 +- .../F24RotatedHybridComposition4.cpp | 250 ++-- .../F24RotatedHybridComposition4.h | 80 +- .../F25RotatedHybridComposition4Bound.cpp | 250 ++-- .../F25RotatedHybridComposition4Bound.h | 80 +- .../cec2005Competition/HCJob.cpp | 18 +- .../cec2005Competition/HCJob.h | 57 +- .../cec2005Competition/TestFunc.cpp | 30 +- .../cec2005Competition/TestFunc.h | 23 +- src/qualityIndicator/Epsilon.cpp | 151 +- src/qualityIndicator/Epsilon.h | 25 +- src/qualityIndicator/Fitness.cpp | 38 +- src/qualityIndicator/Fitness.h | 11 +- src/qualityIndicator/GenerationalDistance.cpp | 111 +- src/qualityIndicator/GenerationalDistance.h | 15 +- src/qualityIndicator/Hypervolume.cpp | 399 ++--- src/qualityIndicator/Hypervolume.h | 33 +- .../InvertedGenerationalDistance.cpp | 111 +- .../InvertedGenerationalDistance.h | 15 +- src/qualityIndicator/QualityIndicator.cpp | 106 +- src/qualityIndicator/QualityIndicator.h | 29 +- src/qualityIndicator/Spread.cpp | 174 +-- src/qualityIndicator/Spread.h | 15 +- .../fastHypervolume/FastHypervolume.cpp | 205 +-- .../fastHypervolume/FastHypervolume.h | 27 +- .../FastHypervolumeArchive.cpp | 127 +- .../fastHypervolume/FastHypervolumeArchive.h | 99 +- src/qualityIndicator/main/Epsilon_main.cpp | 46 +- .../main/GenerationalDistance_main.cpp | 46 +- .../main/Hypervolume_main.cpp | 46 +- .../InvertedGenerationalDistance_main.cpp | 48 +- src/qualityIndicator/main/Spread_main.cpp | 46 +- .../util/LexicoGraphicalComparator.cpp | 41 +- .../util/LexicoGraphicalComparator.h | 5 +- src/qualityIndicator/util/MetricsUtil.cpp | 386 ++--- src/qualityIndicator/util/MetricsUtil.h | 25 +- src/util/AdaptiveGrid.cpp | 413 +++--- src/util/AdaptiveGrid.h | 107 +- src/util/AdaptiveRandomNeighborhood.cpp | 173 ++- src/util/AdaptiveRandomNeighborhood.h | 23 +- src/util/Distance.cpp | 271 ++-- src/util/Distance.h | 21 +- src/util/NonDominatedSolutionList.cpp | 86 +- src/util/NonDominatedSolutionList.h | 15 +- src/util/PermutationUtility.cpp | 55 +- src/util/PermutationUtility.h | 5 +- src/util/PseudoRandom.cpp | 120 +- src/util/PseudoRandom.h | 19 +- src/util/RandomGenerator.cpp | 175 ++- src/util/RandomGenerator.h | 29 +- src/util/Ranking.cpp | 220 +-- src/util/Ranking.h | 21 +- src/util/archive/AdaptiveGridArchive.cpp | 180 +-- src/util/archive/AdaptiveGridArchive.h | 33 +- src/util/archive/Archive.cpp | 5 +- src/util/archive/Archive.h | 5 +- src/util/archive/CrowdingArchive.cpp | 104 +- src/util/archive/CrowdingArchive.h | 21 +- src/util/comparators/Comparator.h | 7 +- src/util/comparators/CrowdingComparator.cpp | 43 +- src/util/comparators/CrowdingComparator.h | 11 +- .../CrowdingDistanceComparator.cpp | 25 +- .../comparators/CrowdingDistanceComparator.h | 5 +- src/util/comparators/DominanceComparator.cpp | 130 +- src/util/comparators/DominanceComparator.h | 11 +- .../EpsilonDominanceComparator.cpp | 130 +- .../comparators/EpsilonDominanceComparator.h | 53 +- .../EpsilonObjectiveComparator.cpp | 43 +- .../comparators/EpsilonObjectiveComparator.h | 47 +- src/util/comparators/EqualSolutions.cpp | 109 +- src/util/comparators/EqualSolutions.h | 5 +- src/util/comparators/ObjectiveComparator.cpp | 72 +- src/util/comparators/ObjectiveComparator.h | 13 +- .../OverallConstraintViolationComparator.cpp | 49 +- .../OverallConstraintViolationComparator.h | 5 +- src/util/comparators/RankComparator.cpp | 25 +- src/util/comparators/RankComparator.h | 5 +- src/util/comparators/SolutionComparator.cpp | 26 +- src/util/comparators/SolutionComparator.h | 7 +- src/util/wrapper/XReal.cpp | 183 +-- src/util/wrapper/XReal.h | 25 +- 363 files changed, 20594 insertions(+), 17809 deletions(-) diff --git a/src/core/Algorithm.cpp b/src/core/Algorithm.cpp index ff53e0c..0988513 100644 --- a/src/core/Algorithm.cpp +++ b/src/core/Algorithm.cpp @@ -20,7 +20,6 @@ // You should have received a copy of the GNU Lesser General Public License // along with this program. If not, see . - #include @@ -28,16 +27,18 @@ * Constructor * @param problem **/ -Algorithm::Algorithm(Problem *problem) { - problem_ = problem; +Algorithm::Algorithm(Problem *problem) +{ + problem_ = problem; } /** * Destructor */ -Algorithm::~Algorithm() { - delete problem_; +Algorithm::~Algorithm() +{ + delete problem_; } // ~Algorithm @@ -48,8 +49,9 @@ Algorithm::~Algorithm() { * @param name The operator name * @param operator The operator **/ -void Algorithm::addOperator(string name, Operator * operator_) { - operators_[name] = operator_; +void Algorithm::addOperator(string name, Operator * operator_) +{ + operators_[name] = operator_; } @@ -60,8 +62,9 @@ void Algorithm::addOperator(string name, Operator * operator_) { * @param name The operator name * @return The operator if exists, null in another case. **/ -Operator * Algorithm::getOperator(string name) { - return operators_[name]; +Operator * Algorithm::getOperator(string name) +{ + return operators_[name]; } @@ -74,8 +77,9 @@ Operator * Algorithm::getOperator(string name) { * @param object Object that represent a parameter for the * algorithm. **/ -void Algorithm::setInputParameter(string name, void *value) { - inputParameters_[name] = value; +void Algorithm::setInputParameter(string name, void *value) +{ + inputParameters_[name] = value; } @@ -86,8 +90,9 @@ void Algorithm::setInputParameter(string name, void *value) { * @return Object representing the parameter or null if the parameter doesn't * exist or the name is wrong **/ -void * Algorithm::getInputParameter(string name) { - return inputParameters_[name]; +void * Algorithm::getInputParameter(string name) +{ + return inputParameters_[name]; } @@ -99,8 +104,9 @@ void * Algorithm::getInputParameter(string name) { * @param name The output parameter name * @param object Object representing the output parameter **/ -void Algorithm::setOutputParameter(string name, void *value) { - outputParameters_[name] = value; +void Algorithm::setOutputParameter(string name, void *value) +{ + outputParameters_[name] = value; } @@ -111,8 +117,9 @@ void Algorithm::setOutputParameter(string name, void *value) { * @return Object representing the output parameter, or null if the parameter * doesn't exist or the name is wrong. **/ -void * Algorithm::getOutputParameter(string name) { - return outputParameters_[name]; +void * Algorithm::getOutputParameter(string name) +{ + return outputParameters_[name]; } @@ -120,6 +127,7 @@ void * Algorithm::getOutputParameter(string name) { * Returns the problem to solve * @return Problem The problem to solve **/ -Problem * Algorithm::getProblem() { - return problem_; +Problem * Algorithm::getProblem() +{ + return problem_; } diff --git a/src/core/Algorithm.h b/src/core/Algorithm.h index d9db7ea..c8ef331 100644 --- a/src/core/Algorithm.h +++ b/src/core/Algorithm.h @@ -35,26 +35,27 @@ * The class declares an abstract method called execute, which * defines the behavior of the algorithm. **/ -class Algorithm { +class Algorithm +{ public: - Algorithm(Problem *problem); - virtual ~Algorithm(); - virtual SolutionSet * execute() = 0; // this launch the execution - // of an algorithm - void addOperator(string name, Operator *operator_); - Operator * getOperator(string name); - void setInputParameter(string name, void *value); - void * getInputParameter(string name); - void setOutputParameter(string name, void *value); - void * getOutputParameter(string name); - Problem * getProblem(); + Algorithm(Problem *problem); + virtual ~Algorithm(); + virtual SolutionSet * execute() = 0; // this launch the execution + // of an algorithm + void addOperator(string name, Operator *operator_); + Operator * getOperator(string name); + void setInputParameter(string name, void *value); + void * getInputParameter(string name); + void setOutputParameter(string name, void *value); + void * getOutputParameter(string name); + Problem * getProblem(); protected: - Problem *problem_; - map operators_; - map inputParameters_; - map outputParameters_; + Problem *problem_; + map operators_; + map inputParameters_; + map outputParameters_; }; // Algorithm diff --git a/src/core/Operator.cpp b/src/core/Operator.cpp index fdc5952..0dbd471 100644 --- a/src/core/Operator.cpp +++ b/src/core/Operator.cpp @@ -27,15 +27,17 @@ /** * Constructor. **/ -Operator::Operator() { +Operator::Operator() +{ } // Operator /** * Constructor. **/ -Operator::Operator(map parameters) { - parameters_ = parameters; +Operator::Operator(map parameters) +{ + parameters_ = parameters; } // Operator @@ -50,8 +52,9 @@ Operator::~Operator() { /* do nothing */ } * @param name The parameter name. * @param value Object representing the parameter. **/ -void Operator::setParameter(string name, void *value) { - parameters_[name] = value; +void Operator::setParameter(string name, void *value) +{ + parameters_[name] = value; } // setParameter @@ -60,7 +63,8 @@ void Operator::setParameter(string name, void *value) { * @param name The parameter name. * @return the parameter. **/ -void * Operator::getParameter(string name) { - return parameters_[name]; +void * Operator::getParameter(string name) +{ + return parameters_[name]; } diff --git a/src/core/Operator.h b/src/core/Operator.h index 2e1c044..d417436 100644 --- a/src/core/Operator.h +++ b/src/core/Operator.h @@ -35,18 +35,19 @@ using namespace std; * and it allow objects to be accessed by their names, which are specified * by the string. **/ -class Operator { +class Operator +{ protected: - map parameters_; - + map parameters_; + public: - Operator (); - Operator (map parameters); - virtual ~Operator() = 0; - virtual void *execute(void *) = 0; - void setParameter(string name, void *value); - void *getParameter(string name); + Operator (); + Operator (map parameters); + virtual ~Operator() = 0; + virtual void *execute(void *) = 0; + void setParameter(string name, void *value); + void *getParameter(string name); }; // Operator diff --git a/src/core/Problem.cpp b/src/core/Problem.cpp index 2759f9e..c46d993 100644 --- a/src/core/Problem.cpp +++ b/src/core/Problem.cpp @@ -30,16 +30,18 @@ const int Problem::DEFAULT_PRECISSION = 16; /** * Constructor. */ -Problem::Problem() { - solutionType_ = NULL; +Problem::Problem() +{ + solutionType_ = NULL; } // Problem /** * Constructor. */ -Problem::Problem(SolutionType * solutionType) { - solutionType_ = solutionType ; +Problem::Problem(SolutionType * solutionType) +{ + solutionType_ = solutionType ; } // Problem @@ -56,16 +58,18 @@ Problem::~Problem() { } // ~Problem * Gets the number of decision variables of the problem. * @return the number of decision variables. */ -int Problem::getNumberOfVariables() { - return numberOfVariables_; +int Problem::getNumberOfVariables() +{ + return numberOfVariables_; } // getNumberOfVariables /** * Sets the number of decision variables of the problem. */ -void Problem::setNumberOfVariables(int numberOfVariables) { - numberOfVariables_ = numberOfVariables; +void Problem::setNumberOfVariables(int numberOfVariables) +{ + numberOfVariables_ = numberOfVariables; } // setNumberOfVariables @@ -73,30 +77,34 @@ void Problem::setNumberOfVariables(int numberOfVariables) { * Gets the the number of objectives of the problem. * @return the number of objectives. */ -int Problem::getNumberOfObjectives() { - return numberOfObjectives_; +int Problem::getNumberOfObjectives() +{ + return numberOfObjectives_; } // getNumberOfObjectives /** * Sets the the number of objectives of the problem. */ -void Problem::setNumberOfObjectives(int numberOfObjectives) { - numberOfObjectives_ = numberOfObjectives; +void Problem::setNumberOfObjectives(int numberOfObjectives) +{ + numberOfObjectives_ = numberOfObjectives; } // setNumberOfObjectives - + /** * Gets the lower bound of the ith variable of the problem. * @param i The index of the variable. * @return The lower bound. */ -double Problem::getLowerLimit(int i) { - if ((lowerLimit_ == NULL) || (i >= numberOfVariables_)) { - cout << "Error: lower limits have been not initialized or accessing to a variable out of range" << endl; - // exit(-1); - } - return lowerLimit_[i]; +double Problem::getLowerLimit(int i) +{ + if ((lowerLimit_ == NULL) || (i >= numberOfVariables_)) + { + cout << "Error: lower limits have been not initialized or accessing to a variable out of range" << endl; + // exit(-1); + } + return lowerLimit_[i]; } // getLowerLimit @@ -105,12 +113,14 @@ double Problem::getLowerLimit(int i) { * @param i The index of the variable. * @return The upper bound. */ -double Problem::getUpperLimit(int i) { - if ((upperLimit_ == NULL) || (i >= numberOfVariables_)) { - cout << "Error: upper limits have been not initialized or accessing to a variable out of range" << endl; - //exit(-1); - } - return upperLimit_[i]; +double Problem::getUpperLimit(int i) +{ + if ((upperLimit_ == NULL) || (i >= numberOfVariables_)) + { + cout << "Error: upper limits have been not initialized or accessing to a variable out of range" << endl; + //exit(-1); + } + return upperLimit_[i]; } // getUpperLimit @@ -118,8 +128,9 @@ double Problem::getUpperLimit(int i) { * Gets the number of side constraints in the problem. * @return the number of constraints. */ -int Problem::getNumberOfConstraints() { - return numberOfConstraints_ ; +int Problem::getNumberOfConstraints() +{ + return numberOfConstraints_ ; } // getNumberOfConstraints @@ -128,9 +139,10 @@ int Problem::getNumberOfConstraints() { * object. * @param solution The Solution to evaluate. */ -void Problem::evaluateConstraints(Solution * solution) { - // The default behavior is to do nothing. Only constrained problems have to - // re-define this method +void Problem::evaluateConstraints(Solution * solution) +{ + // The default behavior is to do nothing. Only constrained problems have to + // re-define this method } // evaluateConstraints @@ -139,8 +151,9 @@ void Problem::evaluateConstraints(Solution * solution) { * variables * @return the number of bits. */ -int Problem::getPrecision(int var) { - return precision_[var] ; +int Problem::getPrecision(int var) +{ + return precision_[var] ; } // getPrecision @@ -149,8 +162,9 @@ int Problem::getPrecision(int var) { * binary-real variables. * @return the number of bits. */ -int * Problem::getPrecision() { - return precision_; +int * Problem::getPrecision() +{ + return precision_; } // getPrecision @@ -159,8 +173,9 @@ int * Problem::getPrecision() { * binary-real variables. * @param precision The array */ -void Problem::setPrecision(int * precision) { - precision_ = precision; +void Problem::setPrecision(int * precision) +{ + precision_ = precision; } // setPrecision @@ -168,23 +183,27 @@ void Problem::setPrecision(int * precision) { * Returns the length of the variable. * @return the variable length. */ -int Problem::getLength(int var) { - if (length_ == NULL) { - return DEFAULT_PRECISSION; - } - return length_[var] ; +int Problem::getLength(int var) +{ + if (length_ == NULL) + { + return DEFAULT_PRECISSION; + } + return length_[var] ; } // getLength /** * Returns the number of bits of the solutions of the problem * @return The number of bits solutions of the problem */ -int Problem::getNumberOfBits() { - int result = 0; - for (int var = 0; var < numberOfVariables_; var++) { - result += getLength(var); - } - return result; +int Problem::getNumberOfBits() +{ + int result = 0; + for (int var = 0; var < numberOfVariables_; var++) + { + result += getLength(var); + } + return result; } // getNumberOfBits @@ -195,14 +214,15 @@ int Problem::getNumberOfBits() { //int Problem::getNumberOfConstraints() { // return numberOfConstraints_; //} // getNumberOfConstraints - + /** * Sets the type of the variables of the problem. * @param type The type of the variables */ -void Problem::setSolutionType(SolutionType * type) { - solutionType_ = type; +void Problem::setSolutionType(SolutionType * type) +{ + solutionType_ = type; } // setSolutionType @@ -210,8 +230,9 @@ void Problem::setSolutionType(SolutionType * type) { * Returns the type of the variables of the problem. * @return type of the variables of the problem. */ -SolutionType * Problem::getSolutionType() { - return solutionType_; +SolutionType * Problem::getSolutionType() +{ + return solutionType_; } // getSolutionType @@ -219,7 +240,8 @@ SolutionType * Problem::getSolutionType() { * Returns the problem name * @return The problem name */ -string Problem::getName() { - return problemName_; +string Problem::getName() +{ + return problemName_; } // getName - + diff --git a/src/core/Problem.h b/src/core/Problem.h index db32a9e..1c9e44f 100644 --- a/src/core/Problem.h +++ b/src/core/Problem.h @@ -37,43 +37,44 @@ class Solution; /** * Abstract class representing a multiobjective optimization problem */ -class Problem { +class Problem +{ private: - static const int DEFAULT_PRECISSION; + static const int DEFAULT_PRECISSION; protected: - int numberOfVariables_; - int numberOfObjectives_; - int numberOfConstraints_; - string problemName_; - SolutionType *solutionType_; - double *lowerLimit_; - double *upperLimit_; - int *precision_; - int *length_; - + int numberOfVariables_; + int numberOfObjectives_; + int numberOfConstraints_; + string problemName_; + SolutionType *solutionType_; + double *lowerLimit_; + double *upperLimit_; + int *precision_; + int *length_; + public: - Problem(); - Problem(SolutionType * solutionType); - virtual ~Problem() = 0; - int getNumberOfVariables(); - void setNumberOfVariables(int numberOfVariables); - int getNumberOfObjectives(); - void setNumberOfObjectives(int numberOfObjectives); - double getLowerLimit(int i); - double getUpperLimit(int i); - virtual void evaluate(Solution * solution) = 0; - int getNumberOfConstraints(); - virtual void evaluateConstraints(Solution * solution); - int getPrecision(int var); - int * getPrecision(); - void setPrecision(int * precision); - int getLength(int var); - void setSolutionType(SolutionType * type); - SolutionType * getSolutionType(); - string getName(); - int getNumberOfBits(); + Problem(); + Problem(SolutionType * solutionType); + virtual ~Problem() = 0; + int getNumberOfVariables(); + void setNumberOfVariables(int numberOfVariables); + int getNumberOfObjectives(); + void setNumberOfObjectives(int numberOfObjectives); + double getLowerLimit(int i); + double getUpperLimit(int i); + virtual void evaluate(Solution * solution) = 0; + int getNumberOfConstraints(); + virtual void evaluateConstraints(Solution * solution); + int getPrecision(int var); + int * getPrecision(); + void setPrecision(int * precision); + int getLength(int var); + void setSolutionType(SolutionType * type); + SolutionType * getSolutionType(); + string getName(); + int getNumberOfBits(); }; // Problem diff --git a/src/core/Solution.cpp b/src/core/Solution.cpp index d7fe6fa..3a24b0d 100644 --- a/src/core/Solution.cpp +++ b/src/core/Solution.cpp @@ -27,17 +27,18 @@ /** * Constructor. */ -Solution::Solution () { - problem_ = NULL; - marked_ = false; - overallConstraintViolation_ = 0.0; - numberOfViolatedConstraints_ = 0; - numberOfVariables_ = 0; - numberOfObjectives_ = 0; - type_ = NULL; - variable_ = NULL; - objective_ = NULL; - rank_ = 0; +Solution::Solution () +{ + problem_ = NULL; + marked_ = false; + overallConstraintViolation_ = 0.0; + numberOfViolatedConstraints_ = 0; + numberOfVariables_ = 0; + numberOfObjectives_ = 0; + type_ = NULL; + variable_ = NULL; + objective_ = NULL; + rank_ = 0; } //Solution @@ -48,17 +49,19 @@ Solution::Solution () { * This constructor is used mainly to read objective values from a file to * variables of a SolutionSet to apply quality indicators */ -Solution::Solution (int numberOfObjectives) { - overallConstraintViolation_ = 0.0; - numberOfObjectives_ = numberOfObjectives; - numberOfVariables_ = 0; - variable_ = NULL; - objective_ = new double[numberOfObjectives_]; - if (objective_ == NULL) { - cout << "ERROR GRAVE: Impossible to reserve memory for storing objectives in class Solution" << endl; - exit(-1); - } - rank_ = 0; +Solution::Solution (int numberOfObjectives) +{ + overallConstraintViolation_ = 0.0; + numberOfObjectives_ = numberOfObjectives; + numberOfVariables_ = 0; + variable_ = NULL; + objective_ = new double[numberOfObjectives_]; + if (objective_ == NULL) + { + cout << "ERROR GRAVE: Impossible to reserve memory for storing objectives in class Solution" << endl; + exit(-1); + } + rank_ = 0; } @@ -67,28 +70,30 @@ Solution::Solution (int numberOfObjectives) { * @param problem The problem to solve * @throws ClassNotFoundException */ -Solution::Solution (Problem *problem) { - problem_ = problem; - type_ = problem_->getSolutionType(); - overallConstraintViolation_ = 0.0; - numberOfObjectives_ = problem_->getNumberOfObjectives(); - numberOfVariables_ = problem_->getNumberOfVariables(); - - // creating the objective vector - objective_ = new double[numberOfObjectives_]; - if (objective_ == NULL) { - cout << "ERROR GRAVE: Impossible to reserve memory for storing objectives in class Solution" << endl; - exit(-1); - } - // at this point objective vector has been created successfully - - // Setting initial values - fitness_ = 0.0; - kDistance_ = 0.0; - crowdingDistance_ = 0.0; - distanceToSolutionSet_ = std::numeric_limits::max(); - variable_ = type_->createVariables(); - rank_ = 0; +Solution::Solution (Problem *problem) +{ + problem_ = problem; + type_ = problem_->getSolutionType(); + overallConstraintViolation_ = 0.0; + numberOfObjectives_ = problem_->getNumberOfObjectives(); + numberOfVariables_ = problem_->getNumberOfVariables(); + + // creating the objective vector + objective_ = new double[numberOfObjectives_]; + if (objective_ == NULL) + { + cout << "ERROR GRAVE: Impossible to reserve memory for storing objectives in class Solution" << endl; + exit(-1); + } + // at this point objective vector has been created successfully + + // Setting initial values + fitness_ = 0.0; + kDistance_ = 0.0; + crowdingDistance_ = 0.0; + distanceToSolutionSet_ = std::numeric_limits::max(); + variable_ = type_->createVariables(); + rank_ = 0; } // Solution @@ -96,20 +101,21 @@ Solution::Solution (Problem *problem) { * Constructor * @param problem The problem to solve */ -Solution::Solution (Problem * problem, Variable ** variables) { - problem_ = problem; - type_ = problem->getSolutionType(); - numberOfObjectives_ = problem->getNumberOfObjectives(); - numberOfVariables_ = problem_->getNumberOfVariables(); - objective_ = new double[numberOfObjectives_] ; - - // Setting initial values - fitness_ = 0.0; - kDistance_ = 0.0; - crowdingDistance_ = 0.0; - distanceToSolutionSet_ = std::numeric_limits::max(); - variable_ = variables; - rank_ = 0; +Solution::Solution (Problem * problem, Variable ** variables) +{ + problem_ = problem; + type_ = problem->getSolutionType(); + numberOfObjectives_ = problem->getNumberOfObjectives(); + numberOfVariables_ = problem_->getNumberOfVariables(); + objective_ = new double[numberOfObjectives_] ; + + // Setting initial values + fitness_ = 0.0; + kDistance_ = 0.0; + crowdingDistance_ = 0.0; + distanceToSolutionSet_ = std::numeric_limits::max(); + variable_ = variables; + rank_ = 0; } // Solution @@ -117,54 +123,58 @@ Solution::Solution (Problem * problem, Variable ** variables) { * Copy constructor. * @param solution Solution to copy. */ -Solution::Solution (Solution *solution) { - problem_ = solution->problem_; - type_ = solution->type_; - numberOfObjectives_ = solution->getNumberOfObjectives(); - numberOfVariables_ = solution->getNumberOfVariables(); - - // creating the objective vector - objective_ = new double[numberOfObjectives_]; - if (objective_ == NULL) { - cout << "ERROR GRAVE: Impossible to reserve memory for storing objectives in class Solution" << endl; - exit(-1); - } - for (int i = 0; i< numberOfObjectives_; i++) { - objective_[i] = solution->objective_[i]; - } - - variable_ = type_->copyVariables(solution->variable_) ; - overallConstraintViolation_ = solution->getOverallConstraintViolation(); - numberOfViolatedConstraints_ = solution->getNumberOfViolatedConstraints(); - distanceToSolutionSet_ = solution->getDistanceToSolutionSet(); - crowdingDistance_ = solution->getCrowdingDistance(); - kDistance_ = solution->getKDistance(); - fitness_ = solution->getFitness(); - marked_ = solution->isMarked(); - rank_ = solution->getRank(); - location_ = solution->getLocation(); - - // create the variables - //old fashion of copying variables - //decisionVariables_ = (Variable *)new Variable*[numberOfVariables_]; - //for (i = 0; i < numberOfVariables_; i++) { - // decisionVariables_[i] = another_->decisionVariables_[i].deepCopy() - //} - //new fashion of copying variables - //decisionVariables_ = solutionType_->copyVariables(another->decisionVariables_); - +Solution::Solution (Solution *solution) +{ + problem_ = solution->problem_; + type_ = solution->type_; + numberOfObjectives_ = solution->getNumberOfObjectives(); + numberOfVariables_ = solution->getNumberOfVariables(); + + // creating the objective vector + objective_ = new double[numberOfObjectives_]; + if (objective_ == NULL) + { + cout << "ERROR GRAVE: Impossible to reserve memory for storing objectives in class Solution" << endl; + exit(-1); + } + for (int i = 0; i< numberOfObjectives_; i++) + { + objective_[i] = solution->objective_[i]; + } + + variable_ = type_->copyVariables(solution->variable_) ; + overallConstraintViolation_ = solution->getOverallConstraintViolation(); + numberOfViolatedConstraints_ = solution->getNumberOfViolatedConstraints(); + distanceToSolutionSet_ = solution->getDistanceToSolutionSet(); + crowdingDistance_ = solution->getCrowdingDistance(); + kDistance_ = solution->getKDistance(); + fitness_ = solution->getFitness(); + marked_ = solution->isMarked(); + rank_ = solution->getRank(); + location_ = solution->getLocation(); + + // create the variables + //old fashion of copying variables + //decisionVariables_ = (Variable *)new Variable*[numberOfVariables_]; + //for (i = 0; i < numberOfVariables_; i++) { + // decisionVariables_[i] = another_->decisionVariables_[i].deepCopy() + //} + //new fashion of copying variables + //decisionVariables_ = solutionType_->copyVariables(another->decisionVariables_); + } // Solution /** * Destructor */ -Solution::~Solution() { - delete[]objective_ ; - if (variable_ != NULL) - for (int i = 0; i < numberOfVariables_; i++) - delete variable_[i] ; - delete [] variable_ ; +Solution::~Solution() +{ + delete[]objective_ ; + if (variable_ != NULL) + for (int i = 0; i < numberOfVariables_; i++) + delete variable_[i] ; + delete [] variable_ ; } // ~Solution @@ -173,7 +183,8 @@ Solution::~Solution() { * The value is stored in distanceToSolutionSet_. * @param distance The distance to a solutionSet. */ -void Solution::setDistanceToSolutionSet(double distance) { +void Solution::setDistanceToSolutionSet(double distance) +{ distanceToSolutionSet_ = distance; } // setDistanceToSolutionSet @@ -184,8 +195,9 @@ void Solution::setDistanceToSolutionSet(double distance) { * setDistanceToPopulation. * @return the distance to a specific solutionSet. */ -double Solution::getDistanceToSolutionSet() { - return distanceToSolutionSet_; +double Solution::getDistanceToSolutionSet() +{ + return distanceToSolutionSet_; } // getDistanceToSolutionSet @@ -194,8 +206,9 @@ double Solution::getDistanceToSolutionSet() { * a SolutionSet. The value is stored in kDistance_. * @param distance The distance to the k-nearest neighbor. */ -void Solution::setKDistance(double distance) { - kDistance_ = distance; +void Solution::setKDistance(double distance) +{ + kDistance_ = distance; } // setKDistance @@ -206,8 +219,9 @@ void Solution::setKDistance(double distance) { * after calling setKDistance. * @return the distance to k-nearest neighbor. */ -double Solution::getKDistance() { - return kDistance_; +double Solution::getKDistance() +{ + return kDistance_; } // getKDistance @@ -216,8 +230,9 @@ double Solution::getKDistance() { * The value is stored in crowdingDistance_. * @param distance The crowding distance of the solution. */ -void Solution::setCrowdingDistance(double distance) { - crowdingDistance_ = distance; +void Solution::setCrowdingDistance(double distance) +{ + crowdingDistance_ = distance; } // setCrowdingDistance @@ -228,8 +243,9 @@ void Solution::setCrowdingDistance(double distance) { * setCrowdingDistance. * @return the distance crowding distance of the solution. */ -double Solution::getCrowdingDistance() { - return crowdingDistance_; +double Solution::getCrowdingDistance() +{ + return crowdingDistance_; } // getCrowdingDistance @@ -238,8 +254,9 @@ double Solution::getCrowdingDistance() { * The value is stored in fitness_. * @param fitness The fitness of the solution. */ -void Solution::setFitness(double fitness) { - fitness_ = fitness; +void Solution::setFitness(double fitness) +{ + fitness_ = fitness; } // setFitness @@ -250,8 +267,9 @@ void Solution::setFitness(double fitness) { * setFitness(). * @return the fitness. */ -double Solution::getFitness() { - return fitness_; +double Solution::getFitness() +{ + return fitness_; } // getFitness @@ -260,13 +278,15 @@ double Solution::getFitness() { * @param i The number identifying the objective. * @param value The value to be stored. */ -void Solution::setObjective(int i, double value) { - if (i < 0 || i >= numberOfObjectives_) { - cout << "Solution::setObjective: objective index out of range: " << i - << endl; - exit(-1); - } - objective_[i] = value; +void Solution::setObjective(int i, double value) +{ + if (i < 0 || i >= numberOfObjectives_) + { + cout << "Solution::setObjective: objective index out of range: " << i + << endl; + exit(-1); + } + objective_[i] = value; } // setObjective @@ -274,13 +294,15 @@ void Solution::setObjective(int i, double value) { * Returns the value of the i-th objective. * @param i The value of the objective. */ -double Solution::getObjective(int i) { - if (i < 0 || i >= numberOfObjectives_) { - cout << "Solution::getObjective: objective index out of range: " << i - << endl; - exit(-1); - } - return objective_[i]; +double Solution::getObjective(int i) +{ + if (i < 0 || i >= numberOfObjectives_) + { + cout << "Solution::getObjective: objective index out of range: " << i + << endl; + exit(-1); + } + return objective_[i]; } // getObjective @@ -288,8 +310,9 @@ double Solution::getObjective(int i) { * Returns the number of objectives. * @return The number of objectives. */ -int Solution::getNumberOfObjectives() { - return numberOfObjectives_; +int Solution::getNumberOfObjectives() +{ + return numberOfObjectives_; } // getNumberOfObjectives @@ -297,8 +320,9 @@ int Solution::getNumberOfObjectives() { * Returns the number of decision variables of the solution. * @return The number of decision variables. */ -int Solution::getNumberOfVariables() { - return numberOfVariables_; +int Solution::getNumberOfVariables() +{ + return numberOfVariables_; } // getNumberOfVariables @@ -306,25 +330,28 @@ int Solution::getNumberOfVariables() { * Returns a string representing the solution. * @return The string. */ -string Solution::toString() { - string aux = ""; - - for (int i = 0; i < numberOfVariables_; i++) { - std::ostringstream stringStream; +string Solution::toString() +{ + string aux = ""; + + for (int i = 0; i < numberOfVariables_; i++) + { + std::ostringstream stringStream; // stringStream << this->getDecisionVariables()[i]->getValue() ; - stringStream << this->getDecisionVariables()[i]->toString() ; - aux = aux + stringStream.str() + " "; - } - aux = aux + " | " ; - for (int i = 0; i < numberOfObjectives_; i++) { - std::ostringstream stringStream; - stringStream << this->getObjective(i) ; - // aux = aux + string(this->getDecisionVariables()[i]->getValue()) + " "; - // aux = aux + string(0.03) + " "; - aux = aux + stringStream.str() + " "; - } - - return aux; + stringStream << this->getDecisionVariables()[i]->toString() ; + aux = aux + stringStream.str() + " "; + } + aux = aux + " | " ; + for (int i = 0; i < numberOfObjectives_; i++) + { + std::ostringstream stringStream; + stringStream << this->getObjective(i) ; + // aux = aux + string(this->getDecisionVariables()[i]->getValue()) + " "; + // aux = aux + string(0.03) + " "; + aux = aux + stringStream.str() + " "; + } + + return aux; } // toString @@ -333,8 +360,9 @@ string Solution::toString() { * @return the DecisionVariables object representing the decision * variables of the solution. */ -Variable ** Solution::getDecisionVariables() { - return variable_; +Variable ** Solution::getDecisionVariables() +{ + return variable_; } // getDecisionVariables @@ -343,8 +371,9 @@ Variable ** Solution::getDecisionVariables() { * @param decisionVariables The DecisionVariables object * representing the decision variables of the solution. */ -void Solution::setDecisionVariables(Variable **variables) { - variable_ = variables ; +void Solution::setDecisionVariables(Variable **variables) +{ + variable_ = variables ; } // setDecisionVariables @@ -354,24 +383,27 @@ void Solution::setDecisionVariables(Variable **variables) { * that, the method unmarked hasn't been called. False in other * case. */ -bool Solution::isMarked() { - return marked_; +bool Solution::isMarked() +{ + return marked_; } // isMarked /** * Establishes the solution as marked. */ -void Solution::mark() { - marked_ = true; +void Solution::mark() +{ + marked_ = true; } // mark /** * Established the solution as unmarked. */ -void Solution::unMark() { - marked_ = false; +void Solution::unMark() +{ + marked_ = false; } // unMark @@ -379,8 +411,9 @@ void Solution::unMark() { * Sets the rank of a solution. * @param value The rank of the solution. */ -void Solution::setRank(int rank) { - rank_ = rank ; +void Solution::setRank(int rank) +{ + rank_ = rank ; } // setRank @@ -390,8 +423,9 @@ void Solution::setRank(int rank) { * setRank(). * @return the rank of the solution. */ -int Solution::getRank() { - return rank_; +int Solution::getRank() +{ + return rank_; } // getRank @@ -399,8 +433,9 @@ int Solution::getRank() { * Sets the overall constraints violated by the solution. * @param value The overall constraints violated by the solution. */ -void Solution::setOverallConstraintViolation(double value) { - overallConstraintViolation_ = value; +void Solution::setOverallConstraintViolation(double value) +{ + overallConstraintViolation_ = value; } // setOverallConstraintViolation @@ -410,8 +445,9 @@ void Solution::setOverallConstraintViolation(double value) { * overallConstraintViolation. * @return the overall constraint violation by the solution. */ -double Solution::getOverallConstraintViolation() { - return overallConstraintViolation_; +double Solution::getOverallConstraintViolation() +{ + return overallConstraintViolation_; } // getOverallConstraintViolation @@ -419,8 +455,9 @@ double Solution::getOverallConstraintViolation() { * Sets the number of constraints violated by the solution. * @param value The number of constraints violated by the solution. */ -void Solution::setNumberOfViolatedConstraints(int number) { - numberOfViolatedConstraints_ = number; +void Solution::setNumberOfViolatedConstraints(int number) +{ + numberOfViolatedConstraints_ = number; } // setNumberOfViolatedConstraints @@ -430,8 +467,9 @@ void Solution::setNumberOfViolatedConstraints(int number) { * setNumberOfViolatedConstraint. * @return the number of constraints violated by the solution. */ -int Solution::getNumberOfViolatedConstraints() { - return numberOfViolatedConstraints_; +int Solution::getNumberOfViolatedConstraints() +{ + return numberOfViolatedConstraints_; } // getNumberOfViolatedConstraints @@ -439,8 +477,9 @@ int Solution::getNumberOfViolatedConstraints() { * Sets the location of the solution into a solutionSet. * @param location The location of the solution. */ -void Solution::setLocation(int location) { - location_ = location; +void Solution::setLocation(int location) +{ + location_ = location; } // setLocation @@ -450,8 +489,9 @@ void Solution::setLocation(int location) { * setLocation. * @return the location of the solution into a solutionSet */ -int Solution::getLocation() { - return location_; +int Solution::getLocation() +{ + return location_; } // getLocation @@ -459,8 +499,9 @@ int Solution::getLocation() { * Sets the type of the variable. * @param type The type of the variable. */ -void Solution::setType(SolutionType * type) { - type_ = type; +void Solution::setType(SolutionType * type) +{ + type_ = type; } // setType @@ -468,8 +509,9 @@ void Solution::setType(SolutionType * type) { * Gets the type of the variable * @return the type of the variable */ -SolutionType * Solution::getType() { - return type_; +SolutionType * Solution::getType() +{ + return type_; } // getType @@ -477,20 +519,23 @@ SolutionType * Solution::getType() { * Returns the aggregative value of the solution * @return The aggregative value. */ -double Solution::getAggregativeValue() { - double value = 0.0; - for (int i = 0; i < numberOfObjectives_; i++){ - value += objective_[i]; - } - return value; +double Solution::getAggregativeValue() +{ + double value = 0.0; + for (int i = 0; i < numberOfObjectives_; i++) + { + value += objective_[i]; + } + return value; } // getAggregativeValue /** * Returns the problem being solved * @return The problem. */ -Problem * Solution::getProblem() { - return problem_ ; +Problem * Solution::getProblem() +{ + return problem_ ; } // getAggregativeValue diff --git a/src/core/Solution.h b/src/core/Solution.h index fa0b3c0..c621d3a 100644 --- a/src/core/Solution.h +++ b/src/core/Solution.h @@ -43,66 +43,67 @@ class SolutionType ; * @class Solution * @brief Class representing a solution for a problem **/ -class Solution { +class Solution +{ private: - Problem * problem_; - SolutionType * type_; - Variable ** variable_; - int numberOfVariables_; - double *objective_; - int numberOfObjectives_; - double fitness_; - bool marked_; - int rank_; - double overallConstraintViolation_; - int numberOfViolatedConstraints_; - int location_; - double kDistance_; - double crowdingDistance_; - double distanceToSolutionSet_; - + Problem * problem_; + SolutionType * type_; + Variable ** variable_; + int numberOfVariables_; + double *objective_; + int numberOfObjectives_; + double fitness_; + bool marked_; + int rank_; + double overallConstraintViolation_; + int numberOfViolatedConstraints_; + int location_; + double kDistance_; + double crowdingDistance_; + double distanceToSolutionSet_; + public: - Solution (); - Solution (int numberOfObjectives); - Solution (Problem * problem); - //getNewsolution (Problem *problem); - Solution(Problem * problem, Variable ** variables); - Solution (Solution * solution); + Solution (); + Solution (int numberOfObjectives); + Solution (Problem * problem); + //getNewsolution (Problem *problem); + Solution(Problem * problem, Variable ** variables); + Solution (Solution * solution); - ~Solution(); + ~Solution(); - void setDistanceToSolutionSet(double distance); - double getDistanceToSolutionSet(); - void setKDistance(double distance); - double getKDistance(); - void setCrowdingDistance(double distance); - double getCrowdingDistance(); - void setFitness(double fitness); - double getFitness(); - void setObjective(int i, double value); - double getObjective(int i); - int getNumberOfObjectives(); - int getNumberOfVariables(); - string toString(); - Variable ** getDecisionVariables(); - void setDecisionVariables(Variable ** variables); - bool isMarked(); - void mark(); - void unMark(); - void setRank(int value); - int getRank(); - void setOverallConstraintViolation(double value); - double getOverallConstraintViolation(); - void setNumberOfViolatedConstraints(int value); - int getNumberOfViolatedConstraints(); - void setLocation(int location); - int getLocation(); - void setType(SolutionType * type); - SolutionType *getType(); - double getAggregativeValue(); - Problem * getProblem() ; - //int getNumberOfBits(); + void setDistanceToSolutionSet(double distance); + double getDistanceToSolutionSet(); + void setKDistance(double distance); + double getKDistance(); + void setCrowdingDistance(double distance); + double getCrowdingDistance(); + void setFitness(double fitness); + double getFitness(); + void setObjective(int i, double value); + double getObjective(int i); + int getNumberOfObjectives(); + int getNumberOfVariables(); + string toString(); + Variable ** getDecisionVariables(); + void setDecisionVariables(Variable ** variables); + bool isMarked(); + void mark(); + void unMark(); + void setRank(int value); + int getRank(); + void setOverallConstraintViolation(double value); + double getOverallConstraintViolation(); + void setNumberOfViolatedConstraints(int value); + int getNumberOfViolatedConstraints(); + void setLocation(int location); + int getLocation(); + void setType(SolutionType * type); + SolutionType *getType(); + double getAggregativeValue(); + Problem * getProblem() ; + //int getNumberOfBits(); }; diff --git a/src/core/SolutionSet.cpp b/src/core/SolutionSet.cpp index ef9d3be..090fa31 100644 --- a/src/core/SolutionSet.cpp +++ b/src/core/SolutionSet.cpp @@ -28,8 +28,9 @@ * Constructor. * Creates an unbounded solution set. */ -SolutionSet::SolutionSet () { - capacity_ = 0; +SolutionSet::SolutionSet () +{ + capacity_ = 0; } // SolutionSet @@ -37,18 +38,21 @@ SolutionSet::SolutionSet () { * Creates a empty solutionSet with a maximum capacity. * @param maximumSize Maximum size. */ -SolutionSet::SolutionSet (int maximumSize) { - capacity_ = maximumSize; +SolutionSet::SolutionSet (int maximumSize) +{ + capacity_ = maximumSize; } // SolutionSet /** * Destructor */ -SolutionSet::~SolutionSet() { - for (int i = 0; i < solutionsList_.size(); i++) { - delete solutionsList_[i]; - } +SolutionSet::~SolutionSet() +{ + for (int i = 0; i < solutionsList_.size(); i++) + { + delete solutionsList_[i]; + } } // ~SolutionSet @@ -58,13 +62,15 @@ SolutionSet::~SolutionSet() { * @return True If the Solution has been inserted, false * otherwise. */ -bool SolutionSet::add(Solution * solution) { - if (solutionsList_.size() >= capacity_) { - cout << "Error in class SolutionSet the maximum capacity of the set has been reached" << endl; - exit(-1); - } - solutionsList_.push_back(solution); - return true; +bool SolutionSet::add(Solution * solution) +{ + if (solutionsList_.size() >= capacity_) + { + cout << "Error in class SolutionSet the maximum capacity of the set has been reached" << endl; + exit(-1); + } + solutionsList_.push_back(solution); + return true; } // add @@ -75,9 +81,10 @@ bool SolutionSet::add(Solution * solution) { * @return True If the Solution has been inserted, false * otherwise. */ -bool SolutionSet::add(int index, Solution * solution) { - solutionsList_.insert(solutionsList_.begin()+index, solution); - return true; +bool SolutionSet::add(int index, Solution * solution) +{ + solutionsList_.insert(solutionsList_.begin()+index, solution); + return true; } /** @@ -86,12 +93,14 @@ bool SolutionSet::add(int index, Solution * solution) { * @return The Solution at the position i. * @throws IndexOutOfBoundsException. */ -Solution * SolutionSet::get(int i) { - if (i < 0 || i >= solutionsList_.size()) { - cout << "Error in class SolutionSet trying to access to an element out of range" << endl; - exit(-1); - } - return solutionsList_[i]; +Solution * SolutionSet::get(int i) +{ + if (i < 0 || i >= solutionsList_.size()) + { + cout << "Error in class SolutionSet trying to access to an element out of range" << endl; + exit(-1); + } + return solutionsList_[i]; } // get @@ -99,8 +108,9 @@ Solution * SolutionSet::get(int i) { * Returns the maximum capacity of the solution set * @return The maximum capacity of the solution set */ -int SolutionSet::getMaxSize() { - return capacity_; +int SolutionSet::getMaxSize() +{ + return capacity_; } // getMaxSize @@ -108,20 +118,25 @@ int SolutionSet::getMaxSize() { * Sorts a SolutionSet using a Comparator. * @param comparator Comparator used to sort. */ -void SolutionSet::sort(Comparator * comparator){ - if (comparator == NULL) { - cout << "Error. No criterium for compare exist" << endl; - exit(-1); - } // if - for (int i = 0; i < solutionsList_.size(); i++) { - for (int j = i+1; j < solutionsList_.size(); j++) { - if ((comparator->compare(solutionsList_[i],solutionsList_[j]))==1) { - Solution *tmp = solutionsList_[i]; - solutionsList_[i] = solutionsList_[j]; - solutionsList_[j] = tmp; - } - } - } // At this point the solution set will be sorted +void SolutionSet::sort(Comparator * comparator) +{ + if (comparator == NULL) + { + cout << "Error. No criterium for compare exist" << endl; + exit(-1); + } // if + for (int i = 0; i < solutionsList_.size(); i++) + { + for (int j = i+1; j < solutionsList_.size(); j++) + { + if ((comparator->compare(solutionsList_[i],solutionsList_[j]))==1) + { + Solution *tmp = solutionsList_[i]; + solutionsList_[i] = solutionsList_[j]; + solutionsList_[j] = tmp; + } + } + } // At this point the solution set will be sorted } // sort @@ -132,24 +147,28 @@ void SolutionSet::sort(Comparator * comparator){ * @return The index of the best Solution attending to the comparator or * -1 if the SolutionSet is empty */ -int SolutionSet::indexBest(Comparator *comparator) { - if (solutionsList_.empty()) { - return -1; - } - int index = 0; - Solution * bestKnown = solutionsList_[0]; - Solution * candidateSolution; - int flag; - for (int i = 1; i < solutionsList_.size(); i++) { - candidateSolution = solutionsList_[i]; - flag = comparator->compare(bestKnown, candidateSolution); - //cout << "flag: " << flag << endl; - if (flag == 1) { - index = i; - bestKnown = candidateSolution; +int SolutionSet::indexBest(Comparator *comparator) +{ + if (solutionsList_.empty()) + { + return -1; } - } - return index; + int index = 0; + Solution * bestKnown = solutionsList_[0]; + Solution * candidateSolution; + int flag; + for (int i = 1; i < solutionsList_.size(); i++) + { + candidateSolution = solutionsList_[i]; + flag = comparator->compare(bestKnown, candidateSolution); + //cout << "flag: " << flag << endl; + if (flag == 1) + { + index = i; + bestKnown = candidateSolution; + } + } + return index; } // indexBest @@ -160,13 +179,17 @@ int SolutionSet::indexBest(Comparator *comparator) { * @return The best Solution attending to the comparator or null * if the SolutionSet is empty */ -Solution * SolutionSet::best(Comparator * comparator){ - int indexBest = this->indexBest(comparator); - if (indexBest < 0) { - return NULL; - } else { - return solutionsList_[indexBest]; - } +Solution * SolutionSet::best(Comparator * comparator) +{ + int indexBest = this->indexBest(comparator); + if (indexBest < 0) + { + return NULL; + } + else + { + return solutionsList_[indexBest]; + } } // best @@ -177,23 +200,27 @@ Solution * SolutionSet::best(Comparator * comparator){ * @return The index of the worst Solution attending to the comparator or * -1 if the SolutionSet is empty */ -int SolutionSet::indexWorst(Comparator * comparator){ - if (solutionsList_.empty()) { - return -1; - } - int index = 0; - Solution * worstKnown = solutionsList_[0]; - Solution * candidateSolution; - int flag; - for (int i = 1; i < solutionsList_.size(); i++) { - candidateSolution = solutionsList_[i]; - flag = comparator->compare(worstKnown, candidateSolution); - if (flag == -1) { - index = i; - worstKnown = candidateSolution; +int SolutionSet::indexWorst(Comparator * comparator) +{ + if (solutionsList_.empty()) + { + return -1; } - } - return index; + int index = 0; + Solution * worstKnown = solutionsList_[0]; + Solution * candidateSolution; + int flag; + for (int i = 1; i < solutionsList_.size(); i++) + { + candidateSolution = solutionsList_[i]; + flag = comparator->compare(worstKnown, candidateSolution); + if (flag == -1) + { + index = i; + worstKnown = candidateSolution; + } + } + return index; } // indexWorst @@ -204,13 +231,17 @@ int SolutionSet::indexWorst(Comparator * comparator){ * @return The worst Solution attending to the comparator or null * if the SolutionSet is empty */ -Solution * SolutionSet::worst(Comparator * comparator){ - int index = indexWorst(comparator); - if (index < 0) { - return NULL; - } else { - return solutionsList_[index]; - } +Solution * SolutionSet::worst(Comparator * comparator) +{ + int index = indexWorst(comparator); + if (index < 0) + { + return NULL; + } + else + { + return solutionsList_[index]; + } } // worst @@ -218,8 +249,9 @@ Solution * SolutionSet::worst(Comparator * comparator){ * Returns the number of solutions in the SolutionSet. * @return The size of the SolutionSet. */ -int SolutionSet::size() { - return solutionsList_.size(); +int SolutionSet::size() +{ + return solutionsList_.size(); } // size @@ -228,19 +260,22 @@ int SolutionSet::size() { * objects into the set in a file. * @param path The output file name */ -void SolutionSet::printObjectivesToFile(string file){ - std::ofstream out(file.c_str()); - cout.setf(ios::fixed); - for (int i = 0; i < solutionsList_.size(); i++) { - int nObj = solutionsList_[i]->getNumberOfObjectives(); - for (int obj = 0; obj < nObj; obj++) { - out << solutionsList_[i]->getObjective(obj) << " "; - //cout << setprecision(15) << solutionsList_[i]->getObjective(obj) << " "; +void SolutionSet::printObjectivesToFile(string file) +{ + std::ofstream out(file.c_str()); + cout.setf(ios::fixed); + for (int i = 0; i < solutionsList_.size(); i++) + { + int nObj = solutionsList_[i]->getNumberOfObjectives(); + for (int obj = 0; obj < nObj; obj++) + { + out << solutionsList_[i]->getObjective(obj) << " "; + //cout << setprecision(15) << solutionsList_[i]->getObjective(obj) << " "; + } + out << endl; + //cout << endl; } - out << endl; - //cout << endl; - } - out.close(); + out.close(); } // printObjectivesToFile @@ -251,21 +286,27 @@ void SolutionSet::printObjectivesToFile(string file){ * @param append If the objectives will be appended in case a file * already exists */ -void SolutionSet::printObjectivesToFile(string file, bool append){ - if (append) { - std::fstream out(file.c_str(), std::ios::out | std::ios::app); - cout.setf(ios::fixed); - for (int i = 0; i < solutionsList_.size(); i++) { - int nObj = solutionsList_[i]->getNumberOfObjectives(); - for (int obj = 0; obj < nObj; obj++) { - out << solutionsList_[i]->getObjective(obj) << " "; - } - out << endl; +void SolutionSet::printObjectivesToFile(string file, bool append) +{ + if (append) + { + std::fstream out(file.c_str(), std::ios::out | std::ios::app); + cout.setf(ios::fixed); + for (int i = 0; i < solutionsList_.size(); i++) + { + int nObj = solutionsList_[i]->getNumberOfObjectives(); + for (int obj = 0; obj < nObj; obj++) + { + out << solutionsList_[i]->getObjective(obj) << " "; + } + out << endl; + } + out.close(); + } + else + { + this->printObjectivesToFile(file); } - out.close(); - } else { - this->printObjectivesToFile(file); - } } // printObjectivesToFile @@ -274,12 +315,14 @@ void SolutionSet::printObjectivesToFile(string file, bool append){ * solutions objects into the set in a file. * @param path The output file name */ -void SolutionSet::printVariablesToFile(string file) { - std::ofstream out(file.c_str()); - for (int i = 0; i < solutionsList_.size(); i++) { - out << solutionsList_[i]->toString() << endl ; - } - out.close(); +void SolutionSet::printVariablesToFile(string file) +{ + std::ofstream out(file.c_str()); + for (int i = 0; i < solutionsList_.size(); i++) + { + out << solutionsList_[i]->toString() << endl ; + } + out.close(); } // printVariablesToFile @@ -288,24 +331,30 @@ void SolutionSet::printVariablesToFile(string file) { * solutions objects into the set in a file. * @param path The output file name */ -void SolutionSet::printVariablesToFile(string file, bool append) { - if (append) { - std::fstream out(file.c_str(), std::ios::out | std::ios::app); - for (int i = 0; i < solutionsList_.size(); i++) { - out << solutionsList_[i]->toString() << endl ; +void SolutionSet::printVariablesToFile(string file, bool append) +{ + if (append) + { + std::fstream out(file.c_str(), std::ios::out | std::ios::app); + for (int i = 0; i < solutionsList_.size(); i++) + { + out << solutionsList_[i]->toString() << endl ; + } + out.close(); + } + else + { + this->printVariablesToFile(file); } - out.close(); - } else { - this->printVariablesToFile(file); - } } // printVariablesToFile /** * Empties the SolutionSet */ -void SolutionSet::clear(){ - solutionsList_.clear(); +void SolutionSet::clear() +{ + solutionsList_.clear(); } // clear @@ -313,12 +362,14 @@ void SolutionSet::clear(){ * Deletes the Solution at position i in the set. * @param i The position of the solution to remove. */ -void SolutionSet::remove(int i) { - if (i < 0 || i >= solutionsList_.size()) { - cout << "Error in class SolutionSet trying to access to an element out of range" << endl; - exit(-1); - } - solutionsList_.erase(solutionsList_.begin() + i); +void SolutionSet::remove(int i) +{ + if (i < 0 || i >= solutionsList_.size()) + { + cout << "Error in class SolutionSet trying to access to an element out of range" << endl; + exit(-1); + } + solutionsList_.erase(solutionsList_.begin() + i); } // remove @@ -328,16 +379,19 @@ void SolutionSet::remove(int i) { * @param solutionSet SolutionSet to join with the current solutionSet. * @return The result of the union operation. */ -SolutionSet * SolutionSet::join(SolutionSet *another) { - SolutionSet *result = - new SolutionSet(solutionsList_.size()+another->size()); - for (int i=0;iadd(new Solution(this->get(i))); - } - for (int i=0;isize();i++) { - result->add(new Solution(another->get(i))); - } - return result; +SolutionSet * SolutionSet::join(SolutionSet *another) +{ + SolutionSet *result = + new SolutionSet(solutionsList_.size()+another->size()); + for (int i=0; iadd(new Solution(this->get(i))); + } + for (int i=0; isize(); i++) + { + result->add(new Solution(another->get(i))); + } + return result; } // join @@ -346,12 +400,14 @@ SolutionSet * SolutionSet::join(SolutionSet *another) { * @param position The position of the solution to replace * @param solution The new solution */ -void SolutionSet::replace(int position, Solution *solution) { - if (position < 0 || position >= solutionsList_.size()) { - cout << "Error in class SolutionSet trying to access to an element out of range" << endl; - exit(-1); - } - solutionsList_[position] = solution; +void SolutionSet::replace(int position, Solution *solution) +{ + if (position < 0 || position >= solutionsList_.size()) + { + cout << "Error in class SolutionSet trying to access to an element out of range" << endl; + exit(-1); + } + solutionsList_[position] = solution; } // replace @@ -359,22 +415,27 @@ void SolutionSet::replace(int position, Solution *solution) { * Copies the objectives of the solution set to a matrix * @return A matrix containing the objectives */ -vector > SolutionSet::writeObjectivesToMatrix() { - vector > objectives; - //objectives = new double[size()][get(0).numberOfObjectives()]; - for (int i = 0; i < size(); i++) { - vector list; - for (int j = 0; j < get(0)->getNumberOfObjectives(); j++) { - list.push_back(get(i)->getObjective(j)); +vector > SolutionSet::writeObjectivesToMatrix() +{ + vector > objectives; + //objectives = new double[size()][get(0).numberOfObjectives()]; + for (int i = 0; i < size(); i++) + { + vector list; + for (int j = 0; j < get(0)->getNumberOfObjectives(); j++) + { + list.push_back(get(i)->getObjective(j)); + } + objectives.push_back(list); } - objectives.push_back(list); - } - return objectives; + return objectives; } // writeObjectivesMatrix -void SolutionSet::printObjectives() { - for (int i = 0; i < solutionsList_.size(); i++) { - cout << solutionsList_.at(i)->toString() << endl; - } +void SolutionSet::printObjectives() +{ + for (int i = 0; i < solutionsList_.size(); i++) + { + cout << solutionsList_.at(i)->toString() << endl; + } } diff --git a/src/core/SolutionSet.h b/src/core/SolutionSet.h index 37f3749..e514843 100644 --- a/src/core/SolutionSet.h +++ b/src/core/SolutionSet.h @@ -42,44 +42,45 @@ class Comparator; * @class SolutionSet * @brief This class is aimed at representing a solution set **/ -class SolutionSet { +class SolutionSet +{ protected: - vector solutionsList_; - int capacity_; + vector solutionsList_; + int capacity_; public: - SolutionSet(); - SolutionSet(int maximumSize); - ~SolutionSet(); + SolutionSet(); + SolutionSet(int maximumSize); + ~SolutionSet(); - bool add(Solution * solution); - bool add(int index, Solution * solution); - Solution *get(int index); - int getMaxSize(); - void sort(Comparator * comparator); - int indexBest(Comparator * comparator); - Solution * best(Comparator * comparator); - int indexWorst(Comparator * comparator); - Solution * worst(Comparator * comparator); - int size(); - void printObjectivesToFile(string path); - void printObjectivesToFile(string path, bool append); - void printVariablesToFile(string file); - void printVariablesToFile(string file, bool append); - void clear(); - void clear(bool del); - void remove(int i); - void remove(int i, bool del); - SolutionSet * join(SolutionSet * another); - void replace(int position, Solution * solution); - void replace(int position, Solution * solution, bool del); - vector > writeObjectivesToMatrix(); - void printObjectives(); + bool add(Solution * solution); + bool add(int index, Solution * solution); + Solution *get(int index); + int getMaxSize(); + void sort(Comparator * comparator); + int indexBest(Comparator * comparator); + Solution * best(Comparator * comparator); + int indexWorst(Comparator * comparator); + Solution * worst(Comparator * comparator); + int size(); + void printObjectivesToFile(string path); + void printObjectivesToFile(string path, bool append); + void printVariablesToFile(string file); + void printVariablesToFile(string file, bool append); + void clear(); + void clear(bool del); + void remove(int i); + void remove(int i, bool del); + SolutionSet * join(SolutionSet * another); + void replace(int position, Solution * solution); + void replace(int position, Solution * solution, bool del); + vector > writeObjectivesToMatrix(); + void printObjectives(); - //void reset() ; - //string toString(); + //void reset() ; + //string toString(); }; diff --git a/src/core/SolutionType.cpp b/src/core/SolutionType.cpp index fee2fcc..d9c086e 100644 --- a/src/core/SolutionType.cpp +++ b/src/core/SolutionType.cpp @@ -28,8 +28,9 @@ * Constructor * @param problem The problem to solve **/ -SolutionType::SolutionType(Problem *problem) { - problem_ = problem; +SolutionType::SolutionType(Problem *problem) +{ + problem_ = problem; } /** @@ -43,19 +44,22 @@ SolutionType::~SolutionType() { } * @param decisionVariables * @return An array of variables **/ -Variable ** SolutionType::copyVariables(Variable **vars) { - int numberOfVar = problem_->getNumberOfVariables(); - int var; - Variable ** variables = new Variable*[numberOfVar]; +Variable ** SolutionType::copyVariables(Variable **vars) +{ + int numberOfVar = problem_->getNumberOfVariables(); + int var; + Variable ** variables = new Variable*[numberOfVar]; - if (variables == NULL) { - cout << "Error grave: Impossible to reserve memory for allocating a copy of variables" << endl; - exit(-1); - } + if (variables == NULL) + { + cout << "Error grave: Impossible to reserve memory for allocating a copy of variables" << endl; + exit(-1); + } - for (var = 0; var < numberOfVar; var++) { - variables[var] = vars[var]->deepCopy(); - } + for (var = 0; var < numberOfVar; var++) + { + variables[var] = vars[var]->deepCopy(); + } - return variables; + return variables; } // copyVariables diff --git a/src/core/SolutionType.h b/src/core/SolutionType.h index 37cf3d4..fc5cad6 100644 --- a/src/core/SolutionType.h +++ b/src/core/SolutionType.h @@ -37,16 +37,17 @@ class Problem; * Advantages: Flexibility for defining different types of solutions * (mixing variable types, etc) **/ -class SolutionType { +class SolutionType +{ protected: - Problem *problem_; + Problem *problem_; public: - SolutionType(Problem *problem); - virtual ~SolutionType(); - virtual Variable **createVariables() = 0; - Variable **copyVariables(Variable **vars); + SolutionType(Problem *problem); + virtual ~SolutionType(); + virtual Variable **createVariables() = 0; + Variable **copyVariables(Variable **vars); }; // SolutionType diff --git a/src/core/Variable.cpp b/src/core/Variable.cpp index 6eb7035..043803c 100644 --- a/src/core/Variable.cpp +++ b/src/core/Variable.cpp @@ -26,7 +26,7 @@ /** - * This is an abstract class for storing the variables composing a solution. + * This is an abstract class for storing the variables composing a solution. * Some examples of variables can be Real, Binary, etc. There is no guaratee * that those variables are implemented on the current version of this project */ @@ -100,9 +100,10 @@ Variable::~Variable() { /* do nothing */ } * is considered a fatal error by default and the program is terminated. * Those classes requiring this method must to redefine it. */ -void Variable::setLowerBound(double lowerBound) { - cout << "Class " << typeid(this).name() << " does not implement " << - "method setLowerBound" << endl; +void Variable::setLowerBound(double lowerBound) +{ + cout << "Class " << typeid(this).name() << " does not implement " << + "method setLowerBound" << endl; } // setLowerBound @@ -112,9 +113,10 @@ void Variable::setLowerBound(double lowerBound) { * is considered a fatal error by default, and the program is terminated. * Those classes requiring this method must redefine it. */ -void Variable::setUpperBound(double upperBound) { - cout << "Class " << typeid(this).name() << " does not implement " << - "method setUpperBound" << endl; +void Variable::setUpperBound(double upperBound) +{ + cout << "Class " << typeid(this).name() << " does not implement " << + "method setUpperBound" << endl; } // setUpperBound @@ -123,6 +125,7 @@ void Variable::setUpperBound(double upperBound) { * @return The type of the variable */ -string Variable::getVariableType() { - return typeid(this).name() ; +string Variable::getVariableType() +{ + return typeid(this).name() ; } // getVariableType diff --git a/src/core/Variable.h b/src/core/Variable.h index 7da680a..9b60d16 100644 --- a/src/core/Variable.h +++ b/src/core/Variable.h @@ -30,24 +30,25 @@ using namespace std ; /** - * This is an abstract class for storing the variables composing a solution. + * This is an abstract class for storing the variables composing a solution. * Some examples of variables can be Real, Binary, etc. There is no guarantee * that those variables are implemented on the current version of this project */ -class Variable { +class Variable +{ public: - virtual ~Variable() = 0; - virtual Variable * deepCopy() = 0; - virtual double getValue() = 0; - virtual void setValue(double value) = 0; - virtual double getLowerBound() = 0; - virtual double getUpperBound() = 0; - void setLowerBound(double bound); - void setUpperBound(double bound); - //void setVariableType(VariableType_ variableType); - string getVariableType(); - virtual string toString() = 0; + virtual ~Variable() = 0; + virtual Variable * deepCopy() = 0; + virtual double getValue() = 0; + virtual void setValue(double value) = 0; + virtual double getLowerBound() = 0; + virtual double getUpperBound() = 0; + void setLowerBound(double bound); + void setUpperBound(double bound); + //void setVariableType(VariableType_ variableType); + string getVariableType(); + virtual string toString() = 0; }; // Variable diff --git a/src/encodings/solutionType/ArrayRealSolutionType.cpp b/src/encodings/solutionType/ArrayRealSolutionType.cpp index c49b7bf..3462a49 100644 --- a/src/encodings/solutionType/ArrayRealSolutionType.cpp +++ b/src/encodings/solutionType/ArrayRealSolutionType.cpp @@ -28,24 +28,26 @@ * @param problem */ ArrayRealSolutionType::ArrayRealSolutionType(Problem * problem) -: SolutionType(problem) { } + : SolutionType(problem) { } /** * Creates the variables of the solution */ -Variable ** ArrayRealSolutionType::createVariables() { - int i; - - Variable **variables = new Variable*[1]; //malloc(sizeof(Real) * problem->getNumberOfVariables()); - if (problem_->getSolutionType() == NULL) { - cout << "Error grave: Impossible to reserve memory for variable type" << endl; - exit(-1); - } - - variables[0] = new ArrayReal(problem_->getNumberOfVariables(),problem_); - - return variables; +Variable ** ArrayRealSolutionType::createVariables() +{ + int i; + + Variable **variables = new Variable*[1]; //malloc(sizeof(Real) * problem->getNumberOfVariables()); + if (problem_->getSolutionType() == NULL) + { + cout << "Error grave: Impossible to reserve memory for variable type" << endl; + exit(-1); + } + + variables[0] = new ArrayReal(problem_->getNumberOfVariables(),problem_); + + return variables; } // createVariables @@ -54,8 +56,9 @@ Variable ** ArrayRealSolutionType::createVariables() { * @param decisionVariables * @return An array of variables */ -Variable ** ArrayRealSolutionType::copyVariables(Variable ** vars) { - Variable **variables = new Variable*[1]; - variables[0] = vars[0]->deepCopy(); - return variables ; +Variable ** ArrayRealSolutionType::copyVariables(Variable ** vars) +{ + Variable **variables = new Variable*[1]; + variables[0] = vars[0]->deepCopy(); + return variables ; } // copyVariables diff --git a/src/encodings/solutionType/ArrayRealSolutionType.h b/src/encodings/solutionType/ArrayRealSolutionType.h index 1d2c1a0..5e2f6ab 100644 --- a/src/encodings/solutionType/ArrayRealSolutionType.h +++ b/src/encodings/solutionType/ArrayRealSolutionType.h @@ -28,12 +28,13 @@ * Class representing the solution type of solutions composed of an ArrayReal * variable */ -class ArrayRealSolutionType : public SolutionType { +class ArrayRealSolutionType : public SolutionType +{ public: - ArrayRealSolutionType(Problem *problem); - Variable **createVariables(); - Variable **copyVariables(Variable ** vars); + ArrayRealSolutionType(Problem *problem); + Variable **createVariables(); + Variable **copyVariables(Variable ** vars); }; diff --git a/src/encodings/solutionType/BinaryRealSolutionType.cpp b/src/encodings/solutionType/BinaryRealSolutionType.cpp index ac07d72..48e6f40 100644 --- a/src/encodings/solutionType/BinaryRealSolutionType.cpp +++ b/src/encodings/solutionType/BinaryRealSolutionType.cpp @@ -28,29 +28,32 @@ * @param problem */ BinaryRealSolutionType::BinaryRealSolutionType(Problem *problem) -: SolutionType(problem) { } + : SolutionType(problem) { } /** * Creates the variables of the solution * @param decisionVariables */ -Variable ** BinaryRealSolutionType::createVariables() { - - Variable **variables = new Variable*[problem_->getNumberOfVariables()]; //malloc(sizeof(Real) * problem->getNumberOfVariables()); - - for (int var = 0; var < problem_->getNumberOfVariables(); var++) { - if (problem_->getPrecision() == NULL) { - int * precision = new int[problem_->getNumberOfVariables()] ; - for (int i = 0; i < problem_->getNumberOfVariables(); i++) - precision[i] = BinaryReal::DEFAULT_PRECISION ; - problem_->setPrecision(precision) ; - } // if - variables[var] = new BinaryReal(problem_->getPrecision(var), - problem_->getLowerLimit(var), - problem_->getUpperLimit(var)); - } // for - - return variables; +Variable ** BinaryRealSolutionType::createVariables() +{ + + Variable **variables = new Variable*[problem_->getNumberOfVariables()]; //malloc(sizeof(Real) * problem->getNumberOfVariables()); + + for (int var = 0; var < problem_->getNumberOfVariables(); var++) + { + if (problem_->getPrecision() == NULL) + { + int * precision = new int[problem_->getNumberOfVariables()] ; + for (int i = 0; i < problem_->getNumberOfVariables(); i++) + precision[i] = BinaryReal::DEFAULT_PRECISION ; + problem_->setPrecision(precision) ; + } // if + variables[var] = new BinaryReal(problem_->getPrecision(var), + problem_->getLowerLimit(var), + problem_->getUpperLimit(var)); + } // for + + return variables; } // createVariables diff --git a/src/encodings/solutionType/BinaryRealSolutionType.h b/src/encodings/solutionType/BinaryRealSolutionType.h index 6e063e9..047815e 100644 --- a/src/encodings/solutionType/BinaryRealSolutionType.h +++ b/src/encodings/solutionType/BinaryRealSolutionType.h @@ -27,11 +27,12 @@ /** * This class is aimed at defining a Type encoding a Real solution **/ -class BinaryRealSolutionType : public SolutionType { +class BinaryRealSolutionType : public SolutionType +{ public: - BinaryRealSolutionType(Problem * problem); - Variable ** createVariables(); + BinaryRealSolutionType(Problem * problem); + Variable ** createVariables(); }; diff --git a/src/encodings/solutionType/BinarySolutionType.cpp b/src/encodings/solutionType/BinarySolutionType.cpp index 56c32bd..beaf90e 100644 --- a/src/encodings/solutionType/BinarySolutionType.cpp +++ b/src/encodings/solutionType/BinarySolutionType.cpp @@ -28,44 +28,45 @@ * @param problem */ BinarySolutionType::BinarySolutionType(Problem *problem) -: SolutionType(problem) { } + : SolutionType(problem) { } /** * Creates the variables of the solution * @param decisionVariables */ -Variable **BinarySolutionType::createVariables() { - //BinaryReal * binaryReal; +Variable **BinarySolutionType::createVariables() +{ + //BinaryReal * binaryReal; - Variable **variables = new Variable*[problem_->getNumberOfVariables()]; //malloc(sizeof(Real) * problem->getNumberOfVariables()); + Variable **variables = new Variable*[problem_->getNumberOfVariables()]; //malloc(sizeof(Real) * problem->getNumberOfVariables()); // if (problem_->variableType_ == NULL) { // cout << "Error grave: Impossible to reserve memory for variable type" << endl; // exit(-1); // } - - for (int var = 0; var < problem_->getNumberOfVariables(); var++) - variables[var] = new Binary(problem_->getLength(var)); - /* - for (int var = 0; var < problem_->getNumberOfVariables(); var++) { - if (problem_->getPrecision() == NULL) { - int * precision = new int[problem_->getNumberOfVariables()] ; - for (int i = 0; i < problem_->getNumberOfVariables(); i++) - precision[i] = BinaryReal::DEFAULT_PRECISION ; - problem_->setPrecision(precision) ; - } // if - variables[var] = new BinaryReal(problem_->getPrecision(var), - problem_->getLowerLimit(var), - problem_->getUpperLimit(var)); - } - */ -/* - Variable[] variables = new Variable[problem_.getNumberOfVariables()]; - for (int var = 0; var < problem_.getNumberOfVariables(); var++) - variables[var] = new Binary(problem_.getLength(var)); + for (int var = 0; var < problem_->getNumberOfVariables(); var++) + variables[var] = new Binary(problem_->getLength(var)); + /* + for (int var = 0; var < problem_->getNumberOfVariables(); var++) { + if (problem_->getPrecision() == NULL) { + int * precision = new int[problem_->getNumberOfVariables()] ; + for (int i = 0; i < problem_->getNumberOfVariables(); i++) + precision[i] = BinaryReal::DEFAULT_PRECISION ; + problem_->setPrecision(precision) ; + } // if + variables[var] = new BinaryReal(problem_->getPrecision(var), + problem_->getLowerLimit(var), + problem_->getUpperLimit(var)); + } + */ + /* + Variable[] variables = new Variable[problem_.getNumberOfVariables()]; - return variables ; -*/ - return variables; + for (int var = 0; var < problem_.getNumberOfVariables(); var++) + variables[var] = new Binary(problem_.getLength(var)); + + return variables ; + */ + return variables; } // createVariables diff --git a/src/encodings/solutionType/BinarySolutionType.h b/src/encodings/solutionType/BinarySolutionType.h index 5cc68bd..6f66bb1 100644 --- a/src/encodings/solutionType/BinarySolutionType.h +++ b/src/encodings/solutionType/BinarySolutionType.h @@ -27,12 +27,13 @@ /** * This class is aimed at defining a Type encoding a Real solution **/ -class BinarySolutionType : public SolutionType { +class BinarySolutionType : public SolutionType +{ public: - BinarySolutionType(Problem *problem); - Variable **createVariables(); - + BinarySolutionType(Problem *problem); + Variable **createVariables(); + }; #endif diff --git a/src/encodings/solutionType/RealSolutionType.cpp b/src/encodings/solutionType/RealSolutionType.cpp index d0e3590..b2fff6f 100644 --- a/src/encodings/solutionType/RealSolutionType.cpp +++ b/src/encodings/solutionType/RealSolutionType.cpp @@ -29,25 +29,28 @@ * @param problem */ RealSolutionType::RealSolutionType(Problem *problem) -: SolutionType(problem) { } + : SolutionType(problem) { } /** * Creates the variables of the solution * @param decisionVariables */ -Variable **RealSolutionType::createVariables() { - int i; - - Variable **variables = new Variable*[problem_->getNumberOfVariables()]; //malloc(sizeof(Real) * problem->getNumberOfVariables()); - if (variables == NULL) { - cout << "Error grave: Impossible to reserve memory for variable type" << endl; - exit(-1); - } - - for (i = 0; i < problem_->getNumberOfVariables(); i++) { - variables[i] = new Real(problem_->getLowerLimit(i),problem_->getUpperLimit(i)); - } - - return variables; +Variable **RealSolutionType::createVariables() +{ + int i; + + Variable **variables = new Variable*[problem_->getNumberOfVariables()]; //malloc(sizeof(Real) * problem->getNumberOfVariables()); + if (variables == NULL) + { + cout << "Error grave: Impossible to reserve memory for variable type" << endl; + exit(-1); + } + + for (i = 0; i < problem_->getNumberOfVariables(); i++) + { + variables[i] = new Real(problem_->getLowerLimit(i),problem_->getUpperLimit(i)); + } + + return variables; } // createVariables diff --git a/src/encodings/solutionType/RealSolutionType.h b/src/encodings/solutionType/RealSolutionType.h index ecc9a22..1a0023e 100644 --- a/src/encodings/solutionType/RealSolutionType.h +++ b/src/encodings/solutionType/RealSolutionType.h @@ -29,11 +29,12 @@ /** * This class is aimed at defining a Type encoding a Real solution **/ -class RealSolutionType : public SolutionType { +class RealSolutionType : public SolutionType +{ public: - RealSolutionType(Problem *problem); - Variable **createVariables(); + RealSolutionType(Problem *problem); + Variable **createVariables(); }; diff --git a/src/encodings/variable/ArrayReal.cpp b/src/encodings/variable/ArrayReal.cpp index b0a0786..61ec172 100644 --- a/src/encodings/variable/ArrayReal.cpp +++ b/src/encodings/variable/ArrayReal.cpp @@ -25,10 +25,11 @@ /** * Constructor */ -ArrayReal::ArrayReal() { - problem_ = NULL; - size_ = 0; - array_ = NULL; +ArrayReal::ArrayReal() +{ + problem_ = NULL; + size_ = 0; + array_ = NULL; } // Constructor @@ -36,16 +37,18 @@ ArrayReal::ArrayReal() { * Constructor * @param size Size of the array */ -ArrayReal::ArrayReal(int size, Problem * problem) { - problem_ = problem; - size_ = size; - array_ = new double[size_]; - - for (int i = 0; i < size_ ; i++) { - array_[i] = PseudoRandom::randDouble()*(problem_->getUpperLimit(i)- - problem_->getLowerLimit(i))+ - problem_->getLowerLimit(i); - } // for +ArrayReal::ArrayReal(int size, Problem * problem) +{ + problem_ = problem; + size_ = size; + array_ = new double[size_]; + + for (int i = 0; i < size_ ; i++) + { + array_[i] = PseudoRandom::randDouble()*(problem_->getUpperLimit(i)- + problem_->getLowerLimit(i))+ + problem_->getLowerLimit(i); + } // for } // Constructor @@ -53,22 +56,25 @@ ArrayReal::ArrayReal(int size, Problem * problem) { * Copy Constructor * @param arrayReal The arrayDouble to copy */ -ArrayReal::ArrayReal(ArrayReal * arrayReal) { - problem_ = arrayReal->problem_ ; - size_ = arrayReal->size_; - array_ = new double[size_]; - - for (int i = 0; i < size_; i++) { - array_[i] = arrayReal->array_[i]; - } // for +ArrayReal::ArrayReal(ArrayReal * arrayReal) +{ + problem_ = arrayReal->problem_ ; + size_ = arrayReal->size_; + array_ = new double[size_]; + + for (int i = 0; i < size_; i++) + { + array_[i] = arrayReal->array_[i]; + } // for } // Copy Constructor /** * Destructor */ -ArrayReal::~ArrayReal() { - delete [] array_; +ArrayReal::~ArrayReal() +{ + delete [] array_; } // ~ArrayReal @@ -76,8 +82,9 @@ ArrayReal::~ArrayReal() { * Creates an exact copy of a BinaryReal object. * @return The copy of the object */ -Variable * ArrayReal::deepCopy() { - return new ArrayReal(this); +Variable * ArrayReal::deepCopy() +{ + return new ArrayReal(this); } // deepCopy @@ -85,8 +92,9 @@ Variable * ArrayReal::deepCopy() { * Returns the length of the arrayReal. * @return The length */ -int ArrayReal::getLength(){ - return size_; +int ArrayReal::getLength() +{ + return size_; } // getLength @@ -95,18 +103,21 @@ int ArrayReal::getLength(){ * @param index Index of value to be returned * @return the value in position index */ -double ArrayReal::getValue(int index) { - if ((index >= 0) && (index < size_)) - return array_[index] ; - else { - cerr << "ArrayReal.getValue: index value (" << index << ") invalid" << endl; - exit(-1); - } // if +double ArrayReal::getValue(int index) +{ + if ((index >= 0) && (index < size_)) + return array_[index] ; + else + { + cerr << "ArrayReal.getValue: index value (" << index << ") invalid" << endl; + exit(-1); + } // if } // getValue -double ArrayReal::getValue() { - cerr << "ERROR: ArrayReal::getValue() without index" << endl; - exit(-1); +double ArrayReal::getValue() +{ + cerr << "ERROR: ArrayReal::getValue() without index" << endl; + exit(-1); } // getValue @@ -115,16 +126,19 @@ double ArrayReal::getValue() { * @param index Index of value to be returned * @param value The value to be set in position index */ -void ArrayReal::setValue(int index, double value) { - if ((index >= 0) && (index < size_)) - array_[index] = value; - else { - cout << "ArrayReal.getValue: index value (" << index << ") invalid" << endl; - } // if +void ArrayReal::setValue(int index, double value) +{ + if ((index >= 0) && (index < size_)) + array_[index] = value; + else + { + cout << "ArrayReal.getValue: index value (" << index << ") invalid" << endl; + } // if } // setValue -void ArrayReal::setValue(double value) { - cout << "ERROR: ArrayReal::setValue(value) without index" << endl; +void ArrayReal::setValue(double value) +{ + cout << "ERROR: ArrayReal::setValue(value) without index" << endl; } // setValue @@ -133,18 +147,21 @@ void ArrayReal::setValue(double value) { * @param index The index of the value * @return the lower bound */ -double ArrayReal::getLowerBound(int index) { - if ((index >= 0) && (index < size_)) - return problem_->getLowerLimit(index) ; - else { - cerr << "ArrayReal.getValue: index value (" << index << ") invalid" << endl; - exit(-1); - } // if +double ArrayReal::getLowerBound(int index) +{ + if ((index >= 0) && (index < size_)) + return problem_->getLowerLimit(index) ; + else + { + cerr << "ArrayReal.getValue: index value (" << index << ") invalid" << endl; + exit(-1); + } // if } // getLowerBound -double ArrayReal::getLowerBound() { - cerr << "ERROR: ArrayReal::getLowerBound() without index" << endl; - exit(-1); +double ArrayReal::getLowerBound() +{ + cerr << "ERROR: ArrayReal::getLowerBound() without index" << endl; + exit(-1); } // getLowerBound @@ -153,18 +170,21 @@ double ArrayReal::getLowerBound() { * @param index The index of the value * @return the upper bound */ -double ArrayReal::getUpperBound(int index) { - if ((index >= 0) && (index < size_)) - return problem_->getUpperLimit(index); - else { - cerr << "ArrayReal.getValue: index value (" << index << ") invalid" << endl; - exit(-1); - } // if +double ArrayReal::getUpperBound(int index) +{ + if ((index >= 0) && (index < size_)) + return problem_->getUpperLimit(index); + else + { + cerr << "ArrayReal.getValue: index value (" << index << ") invalid" << endl; + exit(-1); + } // if } // getLowerBound -double ArrayReal::getUpperBound() { - cerr << "ERROR: ArrayReal::getUpperBound() without index" << endl; - exit(-1); +double ArrayReal::getUpperBound() +{ + cerr << "ERROR: ArrayReal::getUpperBound() without index" << endl; + exit(-1); } // getUpperBound @@ -172,11 +192,13 @@ double ArrayReal::getUpperBound() { * Returns a string representing the object * @return The string */ -string ArrayReal::toString(){ - std::ostringstream ss; - for (int i = 0; i < (size_ - 1); i ++) { - ss << array_[i] << " "; - } - ss << array_[size_ -1]; - return ss.str(); +string ArrayReal::toString() +{ + std::ostringstream ss; + for (int i = 0; i < (size_ - 1); i ++) + { + ss << array_[i] << " "; + } + ss << array_[size_ -1]; + return ss.str(); } // toString diff --git a/src/encodings/variable/ArrayReal.h b/src/encodings/variable/ArrayReal.h index 83e11ef..87c5b35 100644 --- a/src/encodings/variable/ArrayReal.h +++ b/src/encodings/variable/ArrayReal.h @@ -30,31 +30,32 @@ * Class implementing a decision variable representing an array of real values. * The real values of the array have their own bounds. */ -class ArrayReal : public Variable { +class ArrayReal : public Variable +{ public: - double * array_; - Problem * problem_; - int size_; - - ArrayReal(); - ArrayReal(int size, Problem * problem); - ArrayReal(ArrayReal * arrayReal); - ~ArrayReal(); - - Variable * deepCopy(); - int getLength(); - double getValue(int index); - void setValue(int index, double value); - double getLowerBound(int index); - double getUpperBound(int index); - string toString(); - - void setValue(double value); - double getValue(); - double getLowerBound(); - double getUpperBound(); + double * array_; + Problem * problem_; + int size_; + + ArrayReal(); + ArrayReal(int size, Problem * problem); + ArrayReal(ArrayReal * arrayReal); + ~ArrayReal(); + + Variable * deepCopy(); + int getLength(); + double getValue(int index); + void setValue(int index, double value); + double getLowerBound(int index); + double getUpperBound(int index); + string toString(); + + void setValue(double value); + double getValue(); + double getLowerBound(); + double getUpperBound(); }; #endif diff --git a/src/encodings/variable/Binary.cpp b/src/encodings/variable/Binary.cpp index 899aeaa..b2c28b4 100644 --- a/src/encodings/variable/Binary.cpp +++ b/src/encodings/variable/Binary.cpp @@ -25,9 +25,10 @@ /** * Default constructor. */ -Binary::Binary() { - bits_ = NULL ; - numberOfBits_ = -1 ; +Binary::Binary() +{ + bits_ = NULL ; + numberOfBits_ = -1 ; } //Binary @@ -35,18 +36,23 @@ Binary::Binary() { * Constructor * @param numberOfBits Length of the bit string */ -Binary::Binary(int numberOfBits){ - numberOfBits_ = numberOfBits; - - bits_ = new vector(numberOfBits_, false) ; - - for (int i = 0; i < numberOfBits_; i++){ - if (PseudoRandom::randDouble() < 0.5) { - (*bits_)[i] = true ; - } else { - (*bits_)[i] = false ; +Binary::Binary(int numberOfBits) +{ + numberOfBits_ = numberOfBits; + + bits_ = new vector(numberOfBits_, false) ; + + for (int i = 0; i < numberOfBits_; i++) + { + if (PseudoRandom::randDouble() < 0.5) + { + (*bits_)[i] = true ; + } + else + { + (*bits_)[i] = false ; + } } - } } //Binary @@ -54,20 +60,23 @@ Binary::Binary(int numberOfBits){ * Copy constructor. * @param variable The Binary variable to copy. */ -Binary::Binary(Binary * variable){ - numberOfBits_ = variable->getNumberOfBits(); - bits_ = new vector(numberOfBits_, false) ; - for (int i = 0; i < numberOfBits_; i++) { - (*bits_)[i] = (*variable->bits_)[i] ; - } +Binary::Binary(Binary * variable) +{ + numberOfBits_ = variable->getNumberOfBits(); + bits_ = new vector(numberOfBits_, false) ; + for (int i = 0; i < numberOfBits_; i++) + { + (*bits_)[i] = (*variable->bits_)[i] ; + } } //Binary /** * Destructor */ -Binary::~Binary() { - delete bits_; +Binary::~Binary() +{ + delete bits_; } //~Binary @@ -78,8 +87,9 @@ Binary::~Binary() { * value encoded in the binary string. As generic variables do not encode any * value, this method do noting */ -void Binary::decode() { - //do nothing +void Binary::decode() +{ + //do nothing } //decode @@ -87,8 +97,9 @@ void Binary::decode() { * Creates an exact copy of a Binary object * @return An exact copy of the object. **/ -Variable * Binary::deepCopy() { - return new Binary(this); +Variable * Binary::deepCopy() +{ + return new Binary(this); } //deepCopy @@ -96,8 +107,9 @@ Variable * Binary::deepCopy() { * Returns the length of the binary string. * @return The length */ -int Binary::getNumberOfBits(){ - return numberOfBits_; +int Binary::getNumberOfBits() +{ + return numberOfBits_; } //getNumberOfBits @@ -106,8 +118,9 @@ int Binary::getNumberOfBits(){ * @param bit The bit to retrieve * @return The ith bit */ -bool Binary::getIth(int bit){ - return (*bits_)[bit]; +bool Binary::getIth(int bit) +{ + return (*bits_)[bit]; } //getIth /** @@ -115,16 +128,18 @@ bool Binary::getIth(int bit){ * @param bit The bit to flip */ -void Binary::flip(int bit){ - (*bits_)[bit].flip(); +void Binary::flip(int bit) +{ + (*bits_)[bit].flip(); } //blip /** * Sets the value of the ith bit. * @param bit The bit to set */ -void Binary::setIth(int bit, bool value){ - (*bits_)[bit] = value ; +void Binary::setIth(int bit, bool value) +{ + (*bits_)[bit] = value ; } //getNumberOfBits @@ -133,16 +148,19 @@ void Binary::setIth(int bit, bool value){ * @param other The binary string to compare * @return The hamming distance */ -int Binary::hammingDistance(Binary * other) { - int distance = 0; - int i = 0; - while (i < bits_->size()) { - if ((*bits_)[i] != (*other->bits_)[i]) { - distance++; +int Binary::hammingDistance(Binary * other) +{ + int distance = 0; + int i = 0; + while (i < bits_->size()) + { + if ((*bits_)[i] != (*other->bits_)[i]) + { + distance++; + } + i++; } - i++; - } - return distance; + return distance; } // hammingDistance @@ -150,44 +168,51 @@ int Binary::hammingDistance(Binary * other) { * Returns a string representing the object. * @return the string. */ -string Binary::toString() { - vector::iterator it; - string str = "" ; - for(it = bits_->begin(); it != bits_->end(); it++) { - if (*it == true) - str += "1" ; - else - str += "0" ; - } - return str ; +string Binary::toString() +{ + vector::iterator it; + string str = "" ; + for(it = bits_->begin(); it != bits_->end(); it++) + { + if (*it == true) + str += "1" ; + else + str += "0" ; + } + return str ; } // toString /* * Returns the number of 1's in the binary variable */ -int Binary::cardinality() { - int counter = 0 ; - vector::iterator it; - for(it = bits_->begin(); it != bits_->end(); it++) - if (*it == true) - counter ++ ; - return counter ; +int Binary::cardinality() +{ + int counter = 0 ; + vector::iterator it; + for(it = bits_->begin(); it != bits_->end(); it++) + if (*it == true) + counter ++ ; + return counter ; } -double Binary::getValue() { - return 0.0; +double Binary::getValue() +{ + return 0.0; } -void Binary::setValue(double value) { - //value_ = value; +void Binary::setValue(double value) +{ + //value_ = value; } -double Binary::getLowerBound() { - // return 0.0; - exit(-1); +double Binary::getLowerBound() +{ + // return 0.0; + exit(-1); } -double Binary::getUpperBound() { +double Binary::getUpperBound() +{ // return 0.0; - exit(-1); + exit(-1); } diff --git a/src/encodings/variable/Binary.h b/src/encodings/variable/Binary.h index 9c34140..e955354 100644 --- a/src/encodings/variable/Binary.h +++ b/src/encodings/variable/Binary.h @@ -33,33 +33,34 @@ * a base class other binary string based classes (e.g., binary coded integer * or real variables). */ -class Binary : public Variable { +class Binary : public Variable +{ public: - Binary(); - Binary(int numberOfBits); - Binary(Binary * variable); - ~Binary(); + Binary(); + Binary(int numberOfBits); + Binary(Binary * variable); + ~Binary(); - void decode(); - Variable * deepCopy(); - int getNumberOfBits(); - bool getIth(int bit); - void setIth(int bit, bool value); - void flip(int bit) ; - int hammingDistance(Binary * other); - string toString(); - int cardinality() ; + void decode(); + Variable * deepCopy(); + int getNumberOfBits(); + bool getIth(int bit); + void setIth(int bit, bool value); + void flip(int bit) ; + int hammingDistance(Binary * other); + string toString(); + int cardinality() ; - double getValue(); - void setValue(double value); - double getLowerBound(); - double getUpperBound(); + double getValue(); + void setValue(double value); + double getLowerBound(); + double getUpperBound(); protected: - vector * bits_; - int numberOfBits_; + vector * bits_; + int numberOfBits_; }; #endif diff --git a/src/encodings/variable/BinaryReal.cpp b/src/encodings/variable/BinaryReal.cpp index 1e9cc58..c6c5aba 100644 --- a/src/encodings/variable/BinaryReal.cpp +++ b/src/encodings/variable/BinaryReal.cpp @@ -41,10 +41,11 @@ BinaryReal::BinaryReal() : Binary() { } * @param upperBound The upper limit for the variable. */ BinaryReal::BinaryReal(int numberOfBits, double lowerBound, double upperBound) -: Binary(numberOfBits) { - lowerBound_ = lowerBound; - upperBound_ = upperBound; - this->decode(); + : Binary(numberOfBits) +{ + lowerBound_ = lowerBound; + upperBound_ = upperBound; + this->decode(); } //BinaryReal @@ -52,10 +53,11 @@ BinaryReal::BinaryReal(int numberOfBits, double lowerBound, double upperBound) * Copy constructor * @param variable The variable to copy */ -BinaryReal::BinaryReal(BinaryReal * variable) : Binary (variable) { - lowerBound_ = variable->lowerBound_; - upperBound_ = variable->upperBound_; - value_ = variable->value_; +BinaryReal::BinaryReal(BinaryReal * variable) : Binary (variable) +{ + lowerBound_ = variable->lowerBound_; + upperBound_ = variable->upperBound_; + value_ = variable->value_; } //BinaryReal @@ -71,16 +73,19 @@ BinaryReal::~BinaryReal() { /* do nothing */ } * value_ field and can be accessed by the method * getValue. */ -void BinaryReal::decode(){ - double value = 0.0; - for (int i = 0; i < numberOfBits_; i++) { - if ((*bits_)[i] == true) { - value += pow(2.0,i); +void BinaryReal::decode() +{ + double value = 0.0; + for (int i = 0; i < numberOfBits_; i++) + { + if ((*bits_)[i] == true) + { + value += pow(2.0,i); + } } - } - value_ = value * (upperBound_ - lowerBound_) / - (pow(2.0,numberOfBits_)-1.0); - value_ += lowerBound_; + value_ = value * (upperBound_ - lowerBound_) / + (pow(2.0,numberOfBits_)-1.0); + value_ += lowerBound_; } //decode @@ -88,13 +93,15 @@ void BinaryReal::decode(){ * Returns the double value of the variable. * @return the double value. */ -double BinaryReal::getValue() { - return value_; +double BinaryReal::getValue() +{ + return value_; } //getValue -void BinaryReal::setValue(double value) { - value_ = value; +void BinaryReal::setValue(double value) +{ + value_ = value; } @@ -102,8 +109,9 @@ void BinaryReal::setValue(double value) { * Creates an exact copy of a BinaryReal object. * @return The copy of the object */ -Variable * BinaryReal::deepCopy() { - return new BinaryReal(this); +Variable * BinaryReal::deepCopy() +{ + return new BinaryReal(this); } //deepCopy @@ -111,8 +119,9 @@ Variable * BinaryReal::deepCopy() { * Returns the lower bound of the variable. * @return the lower bound. */ -double BinaryReal::getLowerBound() { - return lowerBound_; +double BinaryReal::getLowerBound() +{ + return lowerBound_; } // getLowerBound @@ -120,8 +129,9 @@ double BinaryReal::getLowerBound() { * Returns the upper bound of the variable. * @return the upper bound. */ -double BinaryReal::getUpperBound() { - return upperBound_; +double BinaryReal::getUpperBound() +{ + return upperBound_; } // getUpperBound @@ -129,8 +139,9 @@ double BinaryReal::getUpperBound() { * Sets the lower bound of the variable. * @param lowerBound the lower bound. */ -void BinaryReal::setLowerBound(double lowerBound) { - lowerBound_ = lowerBound; +void BinaryReal::setLowerBound(double lowerBound) +{ + lowerBound_ = lowerBound; } // setLowerBound @@ -138,8 +149,9 @@ void BinaryReal::setLowerBound(double lowerBound) { * Sets the upper bound of the variable. * @param upperBound the upper bound. */ -void BinaryReal::setUpperBound(double upperBound) { - upperBound_ = upperBound; +void BinaryReal::setUpperBound(double upperBound) +{ + upperBound_ = upperBound; } // setUpperBound @@ -147,8 +159,9 @@ void BinaryReal::setUpperBound(double upperBound) { * Returns a string representing the object. * @return the string. */ -string BinaryReal::toString() { - std::ostringstream ss; - ss << value_; - return ss.str(); +string BinaryReal::toString() +{ + std::ostringstream ss; + ss << value_; + return ss.str(); } // toString diff --git a/src/encodings/variable/BinaryReal.h b/src/encodings/variable/BinaryReal.h index 3967975..c8aa5a9 100644 --- a/src/encodings/variable/BinaryReal.h +++ b/src/encodings/variable/BinaryReal.h @@ -31,32 +31,33 @@ * This class extends the Binary class to represent a Real variable encoded by * a binary string */ -class BinaryReal : public Binary { +class BinaryReal : public Binary +{ public: - static const int DEFAULT_PRECISION; + static const int DEFAULT_PRECISION; - BinaryReal(); - BinaryReal(int numberOfBits, double lowerBound, double upperBound); - BinaryReal(BinaryReal * variable); - ~BinaryReal(); + BinaryReal(); + BinaryReal(int numberOfBits, double lowerBound, double upperBound); + BinaryReal(BinaryReal * variable); + ~BinaryReal(); - void decode(); - double getValue(); - void setValue(double value); - Variable * deepCopy(); - double getLowerBound(); - double getUpperBound(); - void setLowerBound(double bound); - void setUpperBound(double bound); - string toString(); + void decode(); + double getValue(); + void setValue(double value); + Variable * deepCopy(); + double getLowerBound(); + double getUpperBound(); + void setLowerBound(double bound); + void setUpperBound(double bound); + string toString(); private: double value_; double lowerBound_ ; double upperBound_ ; - + }; // BinaryReal #endif diff --git a/src/encodings/variable/Real.cpp b/src/encodings/variable/Real.cpp index 1f60de7..fe8263e 100644 --- a/src/encodings/variable/Real.cpp +++ b/src/encodings/variable/Real.cpp @@ -23,35 +23,38 @@ #include -/** - * Empty constructor. +/** + * Empty constructor. * It will only initialize all the variables. **/ -Real::Real() { - value_ = 0.0; +Real::Real() +{ + value_ = 0.0; } // Real /** * Lower and Upper bounds based constructor. - * It will initialize the upper and lower bounds of the + * It will initialize the upper and lower bounds of the * variable and it will initialize its value to a random * value between those upper and lower bound values. **/ -Real::Real(double lowerBound, double upperBound) { - value_ = PseudoRandom::randDouble(lowerBound, upperBound); - lowerBound_ = lowerBound; - upperBound_ = upperBound; +Real::Real(double lowerBound, double upperBound) +{ + value_ = PseudoRandom::randDouble(lowerBound, upperBound); + lowerBound_ = lowerBound; + upperBound_ = upperBound; } // Real /** * Constructor */ -Real::Real(Variable * variable) { - lowerBound_ = variable->getLowerBound(); - upperBound_ = variable->getUpperBound(); - value_ = variable->getValue(); +Real::Real(Variable * variable) +{ + lowerBound_ = variable->getLowerBound(); + upperBound_ = variable->getUpperBound(); + value_ = variable->getValue(); } // Real @@ -65,8 +68,9 @@ Real::~Real() { /* do nothing */ } * Gets the value of the Real variable. * @return the value. */ -double Real::getValue() { - return value_; +double Real::getValue() +{ + return value_; } // getValue @@ -74,8 +78,9 @@ double Real::getValue() { * Sets the value of the variable. * @param value The value. */ -void Real::setValue(double value) { - value_ = value; +void Real::setValue(double value) +{ + value_ = value; } // setValue @@ -83,8 +88,9 @@ void Real::setValue(double value) { * Returns a exact copy of the Real variable * @return the copy */ -Variable *Real::deepCopy() { - return new Real(this); +Variable *Real::deepCopy() +{ + return new Real(this); } // deepCopy @@ -92,8 +98,9 @@ Variable *Real::deepCopy() { * Gets the lower bound of the variable. * @return the lower bound. */ -double Real::getLowerBound() { - return lowerBound_; +double Real::getLowerBound() +{ + return lowerBound_; } // getLowerBound @@ -101,8 +108,9 @@ double Real::getLowerBound() { * Gets the upper bound of the variable. * @return the upper bound. */ -double Real::getUpperBound() { - return upperBound_; +double Real::getUpperBound() +{ + return upperBound_; } // getUpperBound @@ -110,8 +118,9 @@ double Real::getUpperBound() { * Sets the lower bound of the variable. * @param lowerBound The lower bound. */ -void Real::setLowerBound(double bound) { - lowerBound_ = bound; +void Real::setLowerBound(double bound) +{ + lowerBound_ = bound; } // setLowerBound @@ -119,8 +128,9 @@ void Real::setLowerBound(double bound) { * Sets the upper bound of the variable. * @param upperBound The upper bound. */ -void Real::setUpperBound(double bound) { - upperBound_ = bound; +void Real::setUpperBound(double bound) +{ + upperBound_ = bound; } // setUpperBound @@ -128,10 +138,11 @@ void Real::setUpperBound(double bound) { * Returns a string representing the object * @return The string */ -string Real::toString(){ - std::ostringstream stringStream; - stringStream << value_ ; - string aux = stringStream.str() + " "; +string Real::toString() +{ + std::ostringstream stringStream; + stringStream << value_ ; + string aux = stringStream.str() + " "; - return aux ; + return aux ; } // toString diff --git a/src/encodings/variable/Real.h b/src/encodings/variable/Real.h index a67a076..c1e9ac2 100644 --- a/src/encodings/variable/Real.h +++ b/src/encodings/variable/Real.h @@ -29,28 +29,29 @@ /** * This class implements a Real value decision variable */ -class Real : public Variable { +class Real : public Variable +{ public: - Real(); - Real(double lowerBound, double upperBound); - Real(Variable * variable); - ~Real(); + Real(); + Real(double lowerBound, double upperBound); + Real(Variable * variable); + ~Real(); - double getValue(); - void setValue(double value); - Variable * deepCopy(); - double getLowerBound(); - double getUpperBound(); - void setLowerBound(double bound); - void setUpperBound(double bound); - string toString() ; + double getValue(); + void setValue(double value); + Variable * deepCopy(); + double getLowerBound(); + double getUpperBound(); + void setLowerBound(double bound); + void setUpperBound(double bound); + string toString() ; private: - double value_; - double lowerBound_ ; - double upperBound_ ; + double value_; + double lowerBound_ ; + double upperBound_ ; }; #endif diff --git a/src/experiments/Experiment.cpp b/src/experiments/Experiment.cpp index 3e07597..cc1c6c2 100644 --- a/src/experiments/Experiment.cpp +++ b/src/experiments/Experiment.cpp @@ -30,70 +30,85 @@ Experiment::Experiment() {} -void Experiment::checkExperimentDirectory() { - int res = FileUtils::existsPath(experimentBaseDirectory_.c_str()); - switch (res) { - case 0: - cout << "Experiment directory does NOT exist. Creating" << endl; - if (FileUtils::createDirectory(experimentBaseDirectory_) == -1) { - cout << "Error creating directory" << endl; - exit(-1); +void Experiment::checkExperimentDirectory() +{ + int res = FileUtils::existsPath(experimentBaseDirectory_.c_str()); + switch (res) + { + case 0: + cout << "Experiment directory does NOT exist. Creating" << endl; + if (FileUtils::createDirectory(experimentBaseDirectory_) == -1) + { + cout << "Error creating directory" << endl; + exit(-1); + } + break; + case 1: + cout << "Experiment directory exists." << endl; + cout << "Experiment directory is a directory" << endl; + break; + case 2: + cout << "Experiment directory exists." << endl; + cout << "Experiment directory is not a directory. Deleting file and creating directory" << endl; + if( remove(experimentBaseDirectory_.c_str()) != 0 ) + { + cout << "Error deleting file." << endl; + exit(-1); + } + else + { + cout << "File successfully deleted." << endl; + } + if (FileUtils::createDirectory(experimentBaseDirectory_) == -1) + { + cout << "Error creating directory" << endl; + exit(-1); + } + break; + case -1: + cout << "Error checking experiment directory" << endl; + exit(-1); } - break; - case 1: - cout << "Experiment directory exists." << endl; - cout << "Experiment directory is a directory" << endl; - break; - case 2: - cout << "Experiment directory exists." << endl; - cout << "Experiment directory is not a directory. Deleting file and creating directory" << endl; - if( remove(experimentBaseDirectory_.c_str()) != 0 ) { - cout << "Error deleting file." << endl; - exit(-1); - } else { - cout << "File successfully deleted." << endl; - } - if (FileUtils::createDirectory(experimentBaseDirectory_) == -1) { - cout << "Error creating directory" << endl; - exit(-1); - } - break; - case -1: - cout << "Error checking experiment directory" << endl; - exit(-1); - } } // checkExperimentDirectory -void Experiment::resetFile(string file) { - int res = FileUtils::existsPath(file.c_str()); - switch (res) { - case 0: - cout << "File (" << file << ") does NOT exist." << endl; - break; - case 1: - cout << "File (" << file << ") exists." << endl; - cout << "File (" << file << ") is a directory. Deleting directory." << endl; - if( remove(file.c_str()) != 0 ) { - cout << "Error deleting directory." << endl; - exit(-1); - } else { - cout << "Directory successfully deleted." << endl; - } - break; - case 2: - cout << "File (" << file << ") exists." << endl; - cout << "File (" << file << ") is a file. Deleting file." << endl; - if( remove(file.c_str()) != 0 ) { - cout << "Error deleting file." << endl; - exit(-1); - } else { - cout << "File successfully deleted." << endl; +void Experiment::resetFile(string file) +{ + int res = FileUtils::existsPath(file.c_str()); + switch (res) + { + case 0: + cout << "File (" << file << ") does NOT exist." << endl; + break; + case 1: + cout << "File (" << file << ") exists." << endl; + cout << "File (" << file << ") is a directory. Deleting directory." << endl; + if( remove(file.c_str()) != 0 ) + { + cout << "Error deleting directory." << endl; + exit(-1); + } + else + { + cout << "Directory successfully deleted." << endl; + } + break; + case 2: + cout << "File (" << file << ") exists." << endl; + cout << "File (" << file << ") is a file. Deleting file." << endl; + if( remove(file.c_str()) != 0 ) + { + cout << "Error deleting file." << endl; + exit(-1); + } + else + { + cout << "File successfully deleted." << endl; + } + break; + case -1: + cout << "Error checking file (" << file << ")" << endl; + exit(-1); } - break; - case -1: - cout << "Error checking file (" << file << ")" << endl; - exit(-1); - } } // resetFile diff --git a/src/experiments/Experiment.h b/src/experiments/Experiment.h index b4232eb..e1d415b 100644 --- a/src/experiments/Experiment.h +++ b/src/experiments/Experiment.h @@ -33,22 +33,23 @@ using namespace std; * Abstract class representing jMetal experiments */ -class Experiment { +class Experiment +{ public: - string experimentName_; - vector algorithmNameList_; // List of the names of the algorithms to - // be executed - vector problemList_; // List of problems to be solved - string experimentBaseDirectory_; // Directory to store the results - int independentRuns_; // Number of independent runs per algorithm - bool isSingleObjective_; // If this experiment is a singleObjective one or not + string experimentName_; + vector algorithmNameList_; // List of the names of the algorithms to + // be executed + vector problemList_; // List of problems to be solved + string experimentBaseDirectory_; // Directory to store the results + int independentRuns_; // Number of independent runs per algorithm + bool isSingleObjective_; // If this experiment is a singleObjective one or not - Experiment(); + Experiment(); - void checkExperimentDirectory(); - void resetFile(string file); + void checkExperimentDirectory(); + void resetFile(string file); }; diff --git a/src/experiments/ExperimentExecution.cpp b/src/experiments/ExperimentExecution.cpp index f33fd4e..fe2c0a7 100644 --- a/src/experiments/ExperimentExecution.cpp +++ b/src/experiments/ExperimentExecution.cpp @@ -22,10 +22,11 @@ #include -void* executeRun(void* ctx) { - RunExperiment* cptr = (RunExperiment*)ctx; - cptr->run(); - //pthread_exit(0); +void* executeRun(void* ctx) +{ + RunExperiment* cptr = (RunExperiment*)ctx; + cptr->run(); + //pthread_exit(0); } // executeRun @@ -34,21 +35,22 @@ void* executeRun(void* ctx) { * * Contains default settings */ -ExperimentExecution::ExperimentExecution() { +ExperimentExecution::ExperimentExecution() +{ - experimentName_ = "noName"; + experimentName_ = "noName"; - experimentBaseDirectory_ = ""; + experimentBaseDirectory_ = ""; - outputParetoFrontFile_ = "FUN"; - outputParetoSetFile_ = "VAR"; + outputParetoFrontFile_ = "FUN"; + outputParetoSetFile_ = "VAR"; - independentRuns_ = 0; + independentRuns_ = 0; - experimentIndividualListIndex_ = 0; - experimentIndividualListSize_ = -1; + experimentIndividualListIndex_ = 0; + experimentIndividualListSize_ = -1; - isSingleObjective_ = false; + isSingleObjective_ = false; } // ExperimentExecution @@ -56,41 +58,45 @@ ExperimentExecution::ExperimentExecution() { /** * Runs the experiment */ -void ExperimentExecution::runExperiment(int numberOfThreads) { - - checkExperimentDirectory(); - - map_["name"] = &experimentName_; - map_["experimentDirectory"] = &experimentBaseDirectory_; - map_["algorithmNameList"] = &algorithmNameList_; - map_["problemList"] = &problemList_; - map_["independentRuns"] = &independentRuns_; - map_["outputParetoFrontFile"] = &outputParetoFrontFile_; - map_["outputParetoSetFile"] = &outputParetoSetFile_; - - cout << "Initializing task list..." << endl; - //cout << "algorithmNameList_.size() = " << algorithmNameList_.size() << endl; - - experimentIndividualListSize_ = - problemList_.size() * algorithmNameList_.size() * independentRuns_; - for (int i=0; i threads; - RunExperiment ** experiments_ = new RunExperiment*[numberOfThreads]; - for (int i = 0; i < numberOfThreads; i++) { - experiments_[i] = new RunExperiment(this, map_, i, numberOfThreads, - problemList_.size(), i, &mtx); + //pthread_t * p = new pthread_t[numberOfThreads]; + //thread * p = new thread[numberOfThreads]; + vector threads; + RunExperiment ** experiments_ = new RunExperiment*[numberOfThreads]; + for (int i = 0; i < numberOfThreads; i++) + { + experiments_[i] = new RunExperiment(this, map_, i, numberOfThreads, + problemList_.size(), i, &mtx); // result = pthread_create(&p[i], NULL, executeRun, experiments_[i]); // if (result != 0) { // perror("ERROR WHILE CREATING THREADS"); // exit(-1) ; // } - threads.push_back(thread(executeRun, experiments_[i])); - } + threads.push_back(thread(executeRun, experiments_[i])); + } // for (int i = 0; i < numberOfThreads; i++) { // result = pthread_join(p[i], NULL) ; @@ -122,20 +129,21 @@ void ExperimentExecution::runExperiment(int numberOfThreads) { // } // p[i]->join(); // } - for (auto& th : threads) th.join(); + for (auto& th : threads) th.join(); - cout << "All the threads have finished." << endl; + cout << "All the threads have finished." << endl; - for (int i=0; i < experimentIndividualList_.size(); i++) { - delete experimentIndividualList_[i]; - } + for (int i=0; i < experimentIndividualList_.size(); i++) + { + delete experimentIndividualList_[i]; + } - delete [] algorithmSettingsList_; + delete [] algorithmSettingsList_; // delete [] p; - for (int i=0; i < numberOfThreads; i++) - delete experiments_[i]; - delete [] experiments_; + for (int i=0; i < numberOfThreads; i++) + delete experiments_[i]; + delete [] experiments_; } // runExperiment @@ -143,6 +151,7 @@ void ExperimentExecution::runExperiment(int numberOfThreads) { /** * Runs the experiment */ -void ExperimentExecution::runExperiment() { - runExperiment(1); +void ExperimentExecution::runExperiment() +{ + runExperiment(1); } // runExperiment diff --git a/src/experiments/ExperimentExecution.h b/src/experiments/ExperimentExecution.h index a209389..879675b 100644 --- a/src/experiments/ExperimentExecution.h +++ b/src/experiments/ExperimentExecution.h @@ -35,35 +35,36 @@ using namespace std; -class ExperimentExecution : public Experiment { +class ExperimentExecution : public Experiment +{ private: - map map_; // Map used to send experiment parameters to threads + map map_; // Map used to send experiment parameters to threads public: - string outputParetoFrontFile_; // Name of the file containing the output - // Pareto front - string outputParetoSetFile_; // Name of the file containing the output Pareto - // set + string outputParetoFrontFile_; // Name of the file containing the output + // Pareto front + string outputParetoSetFile_; // Name of the file containing the output Pareto + // set - vector experimentIndividualList_; - Settings ** algorithmSettingsList_; - int experimentIndividualListIndex_; - int experimentIndividualListSize_; + vector experimentIndividualList_; + Settings ** algorithmSettingsList_; + int experimentIndividualListIndex_; + int experimentIndividualListSize_; - ExperimentExecution(); + ExperimentExecution(); - void runExperiment(int numberOfThreads); - void runExperiment(); + void runExperiment(int numberOfThreads); + void runExperiment(); - // TODO: Check different algorithmSettings configurations - // virtual void algorithmSettings(string problemName, int problemId, - // Algorithm ** algorithm) = 0; - // virtual Algorithm * algorithmSettings(string problemName) = 0; - virtual Algorithm * algorithmSettings(string problemName, int algorithmId, - int experimentIndividiualId) = 0; + // TODO: Check different algorithmSettings configurations + // virtual void algorithmSettings(string problemName, int problemId, + // Algorithm ** algorithm) = 0; + // virtual Algorithm * algorithmSettings(string problemName) = 0; + virtual Algorithm * algorithmSettings(string problemName, int algorithmId, + int experimentIndividiualId) = 0; }; // ExperimentExecution diff --git a/src/experiments/ExperimentIndividual.cpp b/src/experiments/ExperimentIndividual.cpp index 68239de..22f29a8 100644 --- a/src/experiments/ExperimentIndividual.cpp +++ b/src/experiments/ExperimentIndividual.cpp @@ -23,29 +23,33 @@ /** * Constructor */ -ExperimentIndividual::ExperimentIndividual(int algorithmIndex, int problemIndex, int numRun) { - algorithmIndex_ = algorithmIndex; - problemIndex_ = problemIndex; - numRun_ = numRun; +ExperimentIndividual::ExperimentIndividual(int algorithmIndex, int problemIndex, int numRun) +{ + algorithmIndex_ = algorithmIndex; + problemIndex_ = problemIndex; + numRun_ = numRun; } /** * Return the algorithm index atribute */ -int ExperimentIndividual::getAlgorithmIndex() { - return algorithmIndex_; +int ExperimentIndividual::getAlgorithmIndex() +{ + return algorithmIndex_; } /** * Return the problem index atribute */ -int ExperimentIndividual::getProblemIndex() { - return problemIndex_; +int ExperimentIndividual::getProblemIndex() +{ + return problemIndex_; } /** * Return the algorithm index atribute */ -int ExperimentIndividual::getNumRun() { - return numRun_; +int ExperimentIndividual::getNumRun() +{ + return numRun_; } diff --git a/src/experiments/ExperimentIndividual.h b/src/experiments/ExperimentIndividual.h index 5f1b9e0..13c9879 100644 --- a/src/experiments/ExperimentIndividual.h +++ b/src/experiments/ExperimentIndividual.h @@ -21,18 +21,19 @@ #ifndef __EXPERIMENT_INDIVIDUAL__ #define __EXPERIMENT_INDIVIDUAL__ -class ExperimentIndividual { +class ExperimentIndividual +{ private: - int algorithmIndex_; - int problemIndex_; - int numRun_; + int algorithmIndex_; + int problemIndex_; + int numRun_; public: - ExperimentIndividual(int algorithmIndex, int problemIndex, int numRun); - int getAlgorithmIndex(); - int getProblemIndex(); - int getNumRun(); + ExperimentIndividual(int algorithmIndex, int problemIndex, int numRun); + int getAlgorithmIndex(); + int getProblemIndex(); + int getNumRun(); }; // ExperimentIndividual diff --git a/src/experiments/ExperimentReport.cpp b/src/experiments/ExperimentReport.cpp index 2e98688..ba9a8f3 100644 --- a/src/experiments/ExperimentReport.cpp +++ b/src/experiments/ExperimentReport.cpp @@ -27,357 +27,396 @@ * * Contains default settings */ -ExperimentReport::ExperimentReport() { +ExperimentReport::ExperimentReport() +{ - experimentName_ = "noName"; + experimentName_ = "noName"; - experimentBaseDirectory_ = ""; - paretoFrontDirectory_ = ""; - latexDirectory_ = "latex"; + experimentBaseDirectory_ = ""; + paretoFrontDirectory_ = ""; + latexDirectory_ = "latex"; - independentRuns_ = 0; + independentRuns_ = 0; - indicatorMinimize_["HV"] = false; - indicatorMinimize_["EPSILON"] = true; - indicatorMinimize_["SPREAD"] = true; - indicatorMinimize_["GD"] = true; - indicatorMinimize_["IGD"] = true; - indicatorMinimize_["FIT"] = true; + indicatorMinimize_["HV"] = false; + indicatorMinimize_["EPSILON"] = true; + indicatorMinimize_["SPREAD"] = true; + indicatorMinimize_["GD"] = true; + indicatorMinimize_["IGD"] = true; + indicatorMinimize_["FIT"] = true; - isSingleObjective_ = false; + isSingleObjective_ = false; } // ExperimentReport -void ExperimentReport::generateQualityIndicators() { +void ExperimentReport::generateQualityIndicators() +{ - if ((!isSingleObjective_) && (paretoFrontDirectory_.empty())) { - generateReferenceFronts(); - } - - // TODO: Check if it is possible to use QualityIndicator class instead each independent class. - // Problem: knowing number of objectives of each problem - - if (indicatorList_.size() > 0) { - - cout << "PF file: " << paretoFrontDirectory_ << endl; - - for (int algorithmIndex=0; algorithmIndex > solutionFront = - indicators->utils_->readFront(solutionFrontFile); - qualityIndicatorFile = qualityIndicatorFile + "/FIT"; - indicators->fitness(solutionFront, qualityIndicatorFile); - delete indicators; - - } else { - - for (int numRun=0; numRun > solutionFront = - indicators->utils_->readFront(solutionFrontFile); - vector< vector > trueFront = - indicators->utils_->readFront(paretoFrontPath); - value = indicators->hypervolume(solutionFront, trueFront, trueFront[0].size()); - delete indicators; - qualityIndicatorFile = qualityIndicatorFile + "/HV"; - } - if (indicatorList_[indicatorIndex].compare("SPREAD")==0) { - Spread * indicators = new Spread(); - vector< vector > solutionFront = - indicators->utils_->readFront(solutionFrontFile); - vector< vector > trueFront = - indicators->utils_->readFront(paretoFrontPath); - value = indicators->spread(solutionFront, trueFront, trueFront[0].size()); - delete indicators; - qualityIndicatorFile = qualityIndicatorFile + "/SPREAD"; - } - if (indicatorList_[indicatorIndex].compare("IGD")==0) { - InvertedGenerationalDistance * indicators = new InvertedGenerationalDistance(); - vector< vector > solutionFront = - indicators->utils_->readFront(solutionFrontFile); - vector< vector > trueFront = - indicators->utils_->readFront(paretoFrontPath); - value = indicators->invertedGenerationalDistance(solutionFront, trueFront, trueFront[0].size()); - delete indicators; - qualityIndicatorFile = qualityIndicatorFile + "/IGD"; - } - if (indicatorList_[indicatorIndex].compare("EPSILON")==0) { - Epsilon * indicators = new Epsilon(); - vector< vector > solutionFront = - indicators->utils_->readFront(solutionFrontFile); - vector< vector > trueFront = - indicators->utils_->readFront(paretoFrontPath); - value = indicators->epsilon(solutionFront, trueFront, trueFront[0].size()); - delete indicators; - qualityIndicatorFile = qualityIndicatorFile + "/EPSILON"; - } - - cout << "ExperimentReport: Quality indicator file: " << qualityIndicatorFile << endl; - - if (qualityIndicatorFile.compare(problemDirectory)!=0) { - std::fstream out(qualityIndicatorFile.c_str(), - std::ios::out | std::ios::app); - out << value << endl; - out.close(); - } // if + if ((!isSingleObjective_) && (paretoFrontDirectory_.empty())) + { + generateReferenceFronts(); + } + // TODO: Check if it is possible to use QualityIndicator class instead each independent class. + // Problem: knowing number of objectives of each problem + + if (indicatorList_.size() > 0) + { + + cout << "PF file: " << paretoFrontDirectory_ << endl; + + for (int algorithmIndex=0; algorithmIndex > solutionFront = + indicators->utils_->readFront(solutionFrontFile); + qualityIndicatorFile = qualityIndicatorFile + "/FIT"; + indicators->fitness(solutionFront, qualityIndicatorFile); + delete indicators; + + } + else + { + + for (int numRun=0; numRun > solutionFront = + indicators->utils_->readFront(solutionFrontFile); + vector< vector > trueFront = + indicators->utils_->readFront(paretoFrontPath); + value = indicators->hypervolume(solutionFront, trueFront, trueFront[0].size()); + delete indicators; + qualityIndicatorFile = qualityIndicatorFile + "/HV"; + } + if (indicatorList_[indicatorIndex].compare("SPREAD")==0) + { + Spread * indicators = new Spread(); + vector< vector > solutionFront = + indicators->utils_->readFront(solutionFrontFile); + vector< vector > trueFront = + indicators->utils_->readFront(paretoFrontPath); + value = indicators->spread(solutionFront, trueFront, trueFront[0].size()); + delete indicators; + qualityIndicatorFile = qualityIndicatorFile + "/SPREAD"; + } + if (indicatorList_[indicatorIndex].compare("IGD")==0) + { + InvertedGenerationalDistance * indicators = new InvertedGenerationalDistance(); + vector< vector > solutionFront = + indicators->utils_->readFront(solutionFrontFile); + vector< vector > trueFront = + indicators->utils_->readFront(paretoFrontPath); + value = indicators->invertedGenerationalDistance(solutionFront, trueFront, trueFront[0].size()); + delete indicators; + qualityIndicatorFile = qualityIndicatorFile + "/IGD"; + } + if (indicatorList_[indicatorIndex].compare("EPSILON")==0) + { + Epsilon * indicators = new Epsilon(); + vector< vector > solutionFront = + indicators->utils_->readFront(solutionFrontFile); + vector< vector > trueFront = + indicators->utils_->readFront(paretoFrontPath); + value = indicators->epsilon(solutionFront, trueFront, trueFront[0].size()); + delete indicators; + qualityIndicatorFile = qualityIndicatorFile + "/EPSILON"; + } + + cout << "ExperimentReport: Quality indicator file: " << qualityIndicatorFile << endl; + + if (qualityIndicatorFile.compare(problemDirectory)!=0) + { + std::fstream out(qualityIndicatorFile.c_str(), + std::ios::out | std::ios::app); + out << value << endl; + out.close(); + } // if + + } // for + + } // if + } // for } // for - - } // if } // for - } // for - } // for - } // if + } // if } // generateQualityIndicators -void ExperimentReport::generateReferenceFronts() { +void ExperimentReport::generateReferenceFronts() +{ - string referenceFrontDirectory = experimentBaseDirectory_ + "/referenceFronts"; + string referenceFrontDirectory = experimentBaseDirectory_ + "/referenceFronts"; - if (FileUtils::existsPath(referenceFrontDirectory.c_str()) != 1) { - FileUtils::createDirectory(referenceFrontDirectory); - cout << "Creating " << referenceFrontDirectory << endl; - } + if (FileUtils::existsPath(referenceFrontDirectory.c_str()) != 1) + { + FileUtils::createDirectory(referenceFrontDirectory); + cout << "Creating " << referenceFrontDirectory << endl; + } - for (int problemIndex=0; problemIndexreadNonDominatedSolutionSet(solutionFrontFile, solutionSet); + metricsUtils->readNonDominatedSolutionSet(solutionFrontFile, solutionSet); - } // for - } // for + } // for + } // for - solutionSet->printObjectivesToFile(paretoFrontPath); + solutionSet->printObjectivesToFile(paretoFrontPath); - delete solutionSet; - delete metricsUtils; + delete solutionSet; + delete metricsUtils; - } // for + } // for } // generateQualityIndicators -void ExperimentReport::generateLatexTables() { - latexDirectory_ = experimentBaseDirectory_ + "/" + latexDirectory_; - cout << "latex directory: " << latexDirectory_ << endl; - - vector *** data = new vector**[indicatorList_.size()]; - for (int indicator = 0; indicator < indicatorList_.size(); indicator++) { - // A data vector per problem - data[indicator] = new vector*[problemList_.size()]; - - for (int problem = 0; problem < problemList_.size(); problem++) { - data[indicator][problem] = new vector[algorithmNameList_.size()]; - - for (int algorithm = 0; algorithm < algorithmNameList_.size(); algorithm++) { - - string directory = experimentBaseDirectory_; - directory += "/data/"; - directory += "/" + algorithmNameList_[algorithm]; - directory += "/" + problemList_[problem]; - directory += "/" + indicatorList_[indicator]; - - // Read values from data files - std::ifstream in(directory.c_str()); - if( !in ) { - cout << "Error trying to read quality indicator file: " << directory << endl; - exit(-1); - } // if - string aux; - while( getline(in, aux ) ) { - data[indicator][problem][algorithm].push_back(atof(aux.c_str())); - } // while - } // for +void ExperimentReport::generateLatexTables() +{ + latexDirectory_ = experimentBaseDirectory_ + "/" + latexDirectory_; + cout << "latex directory: " << latexDirectory_ << endl; + + vector *** data = new vector**[indicatorList_.size()]; + for (int indicator = 0; indicator < indicatorList_.size(); indicator++) + { + // A data vector per problem + data[indicator] = new vector*[problemList_.size()]; + + for (int problem = 0; problem < problemList_.size(); problem++) + { + data[indicator][problem] = new vector[algorithmNameList_.size()]; + + for (int algorithm = 0; algorithm < algorithmNameList_.size(); algorithm++) + { + + string directory = experimentBaseDirectory_; + directory += "/data/"; + directory += "/" + algorithmNameList_[algorithm]; + directory += "/" + problemList_[problem]; + directory += "/" + indicatorList_[indicator]; + + // Read values from data files + std::ifstream in(directory.c_str()); + if( !in ) + { + cout << "Error trying to read quality indicator file: " << directory << endl; + exit(-1); + } // if + string aux; + while( getline(in, aux ) ) + { + data[indicator][problem][algorithm].push_back(atof(aux.c_str())); + } // while + } // for + } // for } // for - } // for - - double *** mean; - double *** median; - double *** stdDeviation; - double *** iqr; - double *** max; - double *** min; - int *** numberOfValues; - - map statValues; - - statValues["mean"] = 0.0; - statValues["median"] = 0.0; - statValues["stdDeviation"] = 0.0; - statValues["iqr"] = 0.0; - statValues["max"] = 0.0; - statValues["min"] = 0.0; - - mean = new double**[indicatorList_.size()]; - median = new double**[indicatorList_.size()]; - stdDeviation = new double**[indicatorList_.size()]; - iqr = new double**[indicatorList_.size()]; - min = new double**[indicatorList_.size()]; - max = new double**[indicatorList_.size()]; - numberOfValues = new int**[indicatorList_.size()]; - - for (int indicator = 0; indicator < indicatorList_.size(); indicator++) { - // A data vector per problem - mean[indicator] = new double*[problemList_.size()]; - median[indicator] = new double*[problemList_.size()]; - stdDeviation[indicator] = new double*[problemList_.size()]; - iqr[indicator] = new double*[problemList_.size()]; - min[indicator] = new double*[problemList_.size()]; - max[indicator] = new double*[problemList_.size()]; - numberOfValues[indicator] = new int*[problemList_.size()]; - - for (int problem = 0; problem < problemList_.size(); problem++) { - mean[indicator][problem] = new double[algorithmNameList_.size()]; - median[indicator][problem] = new double[algorithmNameList_.size()]; - stdDeviation[indicator][problem] = new double[algorithmNameList_.size()]; - iqr[indicator][problem] = new double[algorithmNameList_.size()]; - min[indicator][problem] = new double[algorithmNameList_.size()]; - max[indicator][problem] = new double[algorithmNameList_.size()]; - numberOfValues[indicator][problem] = new int[algorithmNameList_.size()]; - - for (int algorithm = 0; algorithm < algorithmNameList_.size(); algorithm++) { - sort(data[indicator][problem][algorithm].begin(), - data[indicator][problem][algorithm].end()); - - string directory = experimentBaseDirectory_; - directory += "/" + algorithmNameList_[algorithm]; - directory += "/" + problemList_[problem]; - directory += "/" + indicatorList_[indicator]; - - //cout << "----" << directory << "-----" << endl; - //calculateStatistics(data[indicator][problem][algorithm], meanV, medianV, minV, maxV, stdDeviationV, iqrV); - calculateStatistics(data[indicator][problem][algorithm], &statValues); - - /* - cout << "Mean: " << statValues["mean"] << endl; - cout << "Median : " << statValues["median"] << endl; - cout << "Std : " << statValues["stdDeviation"] << endl; - cout << "IQR : " << statValues["iqr"] << endl; - cout << "Min : " << statValues["min"] << endl; - cout << "Max : " << statValues["max"] << endl; - cout << "N_values: " << data[indicator][problem][algorithm].size() << endl; - */ - - mean[indicator][problem][algorithm] = statValues["mean"]; - median[indicator][problem][algorithm] = statValues["median"]; - stdDeviation[indicator][problem][algorithm] = statValues["stdDeviation"]; - iqr[indicator][problem][algorithm] = statValues["iqr"]; - min[indicator][problem][algorithm] = statValues["min"]; - max[indicator][problem][algorithm] = statValues["max"]; - numberOfValues[indicator][problem][algorithm] = data[indicator][problem][algorithm].size(); - } + + double *** mean; + double *** median; + double *** stdDeviation; + double *** iqr; + double *** max; + double *** min; + int *** numberOfValues; + + map statValues; + + statValues["mean"] = 0.0; + statValues["median"] = 0.0; + statValues["stdDeviation"] = 0.0; + statValues["iqr"] = 0.0; + statValues["max"] = 0.0; + statValues["min"] = 0.0; + + mean = new double**[indicatorList_.size()]; + median = new double**[indicatorList_.size()]; + stdDeviation = new double**[indicatorList_.size()]; + iqr = new double**[indicatorList_.size()]; + min = new double**[indicatorList_.size()]; + max = new double**[indicatorList_.size()]; + numberOfValues = new int**[indicatorList_.size()]; + + for (int indicator = 0; indicator < indicatorList_.size(); indicator++) + { + // A data vector per problem + mean[indicator] = new double*[problemList_.size()]; + median[indicator] = new double*[problemList_.size()]; + stdDeviation[indicator] = new double*[problemList_.size()]; + iqr[indicator] = new double*[problemList_.size()]; + min[indicator] = new double*[problemList_.size()]; + max[indicator] = new double*[problemList_.size()]; + numberOfValues[indicator] = new int*[problemList_.size()]; + + for (int problem = 0; problem < problemList_.size(); problem++) + { + mean[indicator][problem] = new double[algorithmNameList_.size()]; + median[indicator][problem] = new double[algorithmNameList_.size()]; + stdDeviation[indicator][problem] = new double[algorithmNameList_.size()]; + iqr[indicator][problem] = new double[algorithmNameList_.size()]; + min[indicator][problem] = new double[algorithmNameList_.size()]; + max[indicator][problem] = new double[algorithmNameList_.size()]; + numberOfValues[indicator][problem] = new int[algorithmNameList_.size()]; + + for (int algorithm = 0; algorithm < algorithmNameList_.size(); algorithm++) + { + sort(data[indicator][problem][algorithm].begin(), + data[indicator][problem][algorithm].end()); + + string directory = experimentBaseDirectory_; + directory += "/" + algorithmNameList_[algorithm]; + directory += "/" + problemList_[problem]; + directory += "/" + indicatorList_[indicator]; + + //cout << "----" << directory << "-----" << endl; + //calculateStatistics(data[indicator][problem][algorithm], meanV, medianV, minV, maxV, stdDeviationV, iqrV); + calculateStatistics(data[indicator][problem][algorithm], &statValues); + + /* + cout << "Mean: " << statValues["mean"] << endl; + cout << "Median : " << statValues["median"] << endl; + cout << "Std : " << statValues["stdDeviation"] << endl; + cout << "IQR : " << statValues["iqr"] << endl; + cout << "Min : " << statValues["min"] << endl; + cout << "Max : " << statValues["max"] << endl; + cout << "N_values: " << data[indicator][problem][algorithm].size() << endl; + */ + + mean[indicator][problem][algorithm] = statValues["mean"]; + median[indicator][problem][algorithm] = statValues["median"]; + stdDeviation[indicator][problem][algorithm] = statValues["stdDeviation"]; + iqr[indicator][problem][algorithm] = statValues["iqr"]; + min[indicator][problem][algorithm] = statValues["min"]; + max[indicator][problem][algorithm] = statValues["max"]; + numberOfValues[indicator][problem][algorithm] = data[indicator][problem][algorithm].size(); + } + } } - } - if (FileUtils::existsPath(latexDirectory_.c_str()) != 1) { - if (FileUtils::createDirectory(latexDirectory_) == -1) { - cout << "Error creating directory: " << latexDirectory_ << endl; - exit(-1); + if (FileUtils::existsPath(latexDirectory_.c_str()) != 1) + { + if (FileUtils::createDirectory(latexDirectory_) == -1) + { + cout << "Error creating directory: " << latexDirectory_ << endl; + exit(-1); + } // if + cout << "Creating " << latexDirectory_ << " directory" << endl; } // if - cout << "Creating " << latexDirectory_ << " directory" << endl; - } // if - cout << "Experiment name: " << experimentName_ << endl; - string latexFile = latexDirectory_ + "/" + experimentName_ + ".tex"; - printHeaderLatexCommands(latexFile); - for (int i = 0; i < indicatorList_.size(); i++) { - printMeanStdDev(latexFile, i, mean, stdDeviation); - printMedianIQR(latexFile, i, median, iqr); - } // for - printEndLatexCommands(latexFile); - - // Free memory: - for (int indicator = 0; indicator < indicatorList_.size(); indicator++) { - for (int problem = 0; problem < problemList_.size(); problem++) { - delete [] data[indicator][problem]; - delete [] mean[indicator][problem]; - delete [] median[indicator][problem]; - delete [] stdDeviation[indicator][problem]; - delete [] iqr[indicator][problem]; - delete [] max[indicator][problem]; - delete [] min[indicator][problem]; - delete [] numberOfValues[indicator][problem]; + cout << "Experiment name: " << experimentName_ << endl; + string latexFile = latexDirectory_ + "/" + experimentName_ + ".tex"; + printHeaderLatexCommands(latexFile); + for (int i = 0; i < indicatorList_.size(); i++) + { + printMeanStdDev(latexFile, i, mean, stdDeviation); + printMedianIQR(latexFile, i, median, iqr); + } // for + printEndLatexCommands(latexFile); + + // Free memory: + for (int indicator = 0; indicator < indicatorList_.size(); indicator++) + { + for (int problem = 0; problem < problemList_.size(); problem++) + { + delete [] data[indicator][problem]; + delete [] mean[indicator][problem]; + delete [] median[indicator][problem]; + delete [] stdDeviation[indicator][problem]; + delete [] iqr[indicator][problem]; + delete [] max[indicator][problem]; + delete [] min[indicator][problem]; + delete [] numberOfValues[indicator][problem]; + } + delete [] data[indicator]; + delete [] mean[indicator]; + delete [] median[indicator]; + delete [] stdDeviation[indicator]; + delete [] iqr[indicator]; + delete [] max[indicator]; + delete [] min[indicator]; + delete [] numberOfValues[indicator]; } - delete [] data[indicator]; - delete [] mean[indicator]; - delete [] median[indicator]; - delete [] stdDeviation[indicator]; - delete [] iqr[indicator]; - delete [] max[indicator]; - delete [] min[indicator]; - delete [] numberOfValues[indicator]; - } - delete [] data; - delete [] mean; - delete [] median; - delete [] stdDeviation; - delete [] iqr; - delete [] max; - delete [] min; - delete [] numberOfValues; + delete [] data; + delete [] mean; + delete [] median; + delete [] stdDeviation; + delete [] iqr; + delete [] max; + delete [] min; + delete [] numberOfValues; } // generateLatexTables @@ -385,310 +424,363 @@ void ExperimentReport::generateLatexTables() { /** * Calculates statistical values from a vector of Double objects */ -void ExperimentReport::calculateStatistics(vector vector, map * values) { - if (vector.size() > 0) { - double sum, minimum, maximum, sqsum, min, max, median, mean, iqr, stdDeviation; - - sqsum = 0.0; - sum = 0.0; - min = 1E300; - max = -1E300; - median = 0; - - for (int i = 0; i < vector.size(); i++) { - double val = vector[i]; - sqsum += val * val; - sum += val; - if (val < min) { - min = val; - } - if (val > max) { - max = val; - } // if - } // for +void ExperimentReport::calculateStatistics(vector vector, map * values) +{ + if (vector.size() > 0) + { + double sum, minimum, maximum, sqsum, min, max, median, mean, iqr, stdDeviation; + + sqsum = 0.0; + sum = 0.0; + min = 1E300; + max = -1E300; + median = 0; + + for (int i = 0; i < vector.size(); i++) + { + double val = vector[i]; + sqsum += val * val; + sum += val; + if (val < min) + { + min = val; + } + if (val > max) + { + max = val; + } // if + } // for - // Mean - mean = sum / vector.size(); + // Mean + mean = sum / vector.size(); - // Standard deviation - if (sqsum / vector.size() - mean * mean < 0.0) { - stdDeviation = 0.0; - } else { - stdDeviation = sqrt(sqsum / vector.size() - mean * mean); - } // if + // Standard deviation + if (sqsum / vector.size() - mean * mean < 0.0) + { + stdDeviation = 0.0; + } + else + { + stdDeviation = sqrt(sqsum / vector.size() - mean * mean); + } // if - (*values)["mean"] = mean; - (*values)["median"] = Statistics::calculateMedian(vector, 0, vector.size() - 1); - (*values)["iqr"] = Statistics::calculateIQR(vector); - (*values)["stdDeviation"] = stdDeviation; - (*values)["min"] = min; - (*values)["max"] = max; - } // if - else { - (*values)["mean"] = std::numeric_limits::quiet_NaN(); - (*values)["median"] = std::numeric_limits::quiet_NaN(); - (*values)["iqr"] = std::numeric_limits::quiet_NaN(); - (*values)["stdDeviation"] = std::numeric_limits::quiet_NaN(); - (*values)["min"] = std::numeric_limits::quiet_NaN(); - (*values)["max"] = std::numeric_limits::quiet_NaN(); - } // else + (*values)["mean"] = mean; + (*values)["median"] = Statistics::calculateMedian(vector, 0, vector.size() - 1); + (*values)["iqr"] = Statistics::calculateIQR(vector); + (*values)["stdDeviation"] = stdDeviation; + (*values)["min"] = min; + (*values)["max"] = max; + } // if + else + { + (*values)["mean"] = std::numeric_limits::quiet_NaN(); + (*values)["median"] = std::numeric_limits::quiet_NaN(); + (*values)["iqr"] = std::numeric_limits::quiet_NaN(); + (*values)["stdDeviation"] = std::numeric_limits::quiet_NaN(); + (*values)["min"] = std::numeric_limits::quiet_NaN(); + (*values)["max"] = std::numeric_limits::quiet_NaN(); + } // else } // calculateStatistics -void ExperimentReport::printHeaderLatexCommands(string fileName) { - std::ofstream out(fileName.c_str()); - out << "\\documentclass{article}" << endl; - out << "\\title{" << experimentName_ << "}" << endl; - out << "\\usepackage{colortbl}" << endl; - out << "\\usepackage[table*]{xcolor}" << endl; - out << "\\xdefinecolor{gray95}{gray}{0.65}" << endl; - out << "\\xdefinecolor{gray25}{gray}{0.8}" << endl; - out << "\\author{}" << endl; - out << "\\begin{document}" << endl; - out << "\\maketitle" << endl; - out << "\\section{Tables}" << endl; - out.close(); +void ExperimentReport::printHeaderLatexCommands(string fileName) +{ + std::ofstream out(fileName.c_str()); + out << "\\documentclass{article}" << endl; + out << "\\title{" << experimentName_ << "}" << endl; + out << "\\usepackage{colortbl}" << endl; + out << "\\usepackage[table*]{xcolor}" << endl; + out << "\\xdefinecolor{gray95}{gray}{0.65}" << endl; + out << "\\xdefinecolor{gray25}{gray}{0.8}" << endl; + out << "\\author{}" << endl; + out << "\\begin{document}" << endl; + out << "\\maketitle" << endl; + out << "\\section{Tables}" << endl; + out.close(); } // printHeaderLatexCommands -void ExperimentReport::printEndLatexCommands(string fileName) { - std::fstream out(fileName.c_str(), std::ios::out | std::ios::app); - out << "\\end{document}" << endl; - out.close(); +void ExperimentReport::printEndLatexCommands(string fileName) +{ + std::fstream out(fileName.c_str(), std::ios::out | std::ios::app); + out << "\\end{document}" << endl; + out.close(); } //printEndLatexCommands void ExperimentReport::printMeanStdDev(string fileName, int indicator, double *** mean, - double *** stdDev) { - std::fstream out(fileName.c_str(), std::ios::out | std::ios::app); - out << "\\" << endl; - out << "\\begin{table}" << endl; - out << "\\caption{" << indicatorList_[indicator] << ". Mean and standard deviation}" << endl; - out << "\\label{table:mean." << indicatorList_[indicator] << "}" << endl; - out << "\\centering" << endl; - out << "\\begin{scriptsize}" << endl; - out << "\\begin{tabular}{l"; - - // calculate the number of columns - for (int i = 0; i < algorithmNameList_.size(); i++) { - out << "l"; - } - out << "}" << endl; - - out << "\\hline"; - // write table head - for (int i = -1; i < (int) (algorithmNameList_.size()); i++) { - if (i == -1) { - out << " & "; - } else if (i == (algorithmNameList_.size() - 1)) { - out << " " << algorithmNameList_[i] << "\\\\" << endl; - } else { - out << "" << algorithmNameList_[i] << " & "; + double *** stdDev) +{ + std::fstream out(fileName.c_str(), std::ios::out | std::ios::app); + out << "\\" << endl; + out << "\\begin{table}" << endl; + out << "\\caption{" << indicatorList_[indicator] << ". Mean and standard deviation}" << endl; + out << "\\label{table:mean." << indicatorList_[indicator] << "}" << endl; + out << "\\centering" << endl; + out << "\\begin{scriptsize}" << endl; + out << "\\begin{tabular}{l"; + + // calculate the number of columns + for (int i = 0; i < algorithmNameList_.size(); i++) + { + out << "l"; } - } - out << "\\hline" << endl; - - char m[20], s[20]; - // write lines - for (int i = 0; i < problemList_.size(); i++) { - // find the best value and second best value - double bestValue ; - double bestValueIQR ; - double secondBestValue ; - double secondBestValueIQR ; - int bestIndex = -1 ; - int secondBestIndex = -1 ; - if (indicatorMinimize_[indicatorList_[indicator]] == true) {// minimize by default - bestValue = std::numeric_limits::max(); - bestValueIQR = std::numeric_limits::max(); - secondBestValue = std::numeric_limits::max(); - secondBestValueIQR = std::numeric_limits::max(); - for (int j = 0; j < (algorithmNameList_.size()); j++) { - if ((mean[indicator][i][j] < bestValue) || - ((mean[indicator][i][j] == bestValue) && (stdDev[indicator][i][j] < bestValueIQR))) { - secondBestIndex = bestIndex ; - secondBestValue = bestValue ; - secondBestValueIQR = bestValueIQR ; - bestValue = mean[indicator][i][j]; - bestValueIQR = stdDev[indicator][i][j]; - bestIndex = j; + out << "}" << endl; + + out << "\\hline"; + // write table head + for (int i = -1; i < (int) (algorithmNameList_.size()); i++) + { + if (i == -1) + { + out << " & "; } - else if ((mean[indicator][i][j] < secondBestValue) || - ((mean[indicator][i][j] == secondBestValue) && (stdDev[indicator][i][j] < secondBestValueIQR))) { - secondBestIndex = j ; - secondBestValue = mean[indicator][i][j] ; - secondBestValueIQR = stdDev[indicator][i][j] ; - } // else if - } - } // if - else { // indicator to maximize e.g., the HV - bestValue = -std::numeric_limits::max(); - bestValueIQR = -std::numeric_limits::max(); - secondBestValue = -std::numeric_limits::max(); - secondBestValueIQR = -std::numeric_limits::max(); - for (int j = 0; j < (algorithmNameList_.size()); j++) { - if ((mean[indicator][i][j] > bestValue) || - ((mean[indicator][i][j] == bestValue) && (stdDev[indicator][i][j] < bestValueIQR))) { - secondBestIndex = bestIndex ; - secondBestValue = bestValue ; - secondBestValueIQR = bestValueIQR ; - bestValue = mean[indicator][i][j]; - bestValueIQR = stdDev[indicator][i][j]; - bestIndex = j; + else if (i == (algorithmNameList_.size() - 1)) + { + out << " " << algorithmNameList_[i] << "\\\\" << endl; + } + else + { + out << "" << algorithmNameList_[i] << " & "; } - else if ((mean[indicator][i][j] > secondBestValue) || - ((mean[indicator][i][j] == secondBestValue) && (stdDev[indicator][i][j] < secondBestValueIQR))) { - secondBestIndex = j ; - secondBestValue = mean[indicator][i][j] ; - secondBestValueIQR = stdDev[indicator][i][j] ; - } // else if - } // for - } // else - - out << problemList_[i] << " & "; - for (int j = 0; j < (algorithmNameList_.size() - 1); j++) { - if (j == bestIndex) { - out << "\\cellcolor{gray95}"; - } - if (j == secondBestIndex) { - out << "\\cellcolor{gray25}"; - } - - sprintf(m, "%10.2e", mean[indicator][i][j]); - sprintf(s, "%8.1e", stdDev[indicator][i][j]); - out << "$" << m << "_{" << s << "}$ & "; - } - if (bestIndex == (algorithmNameList_.size() - 1)) { - out << "\\cellcolor{gray95}"; } - sprintf(m, "%10.2e", mean[indicator][i][algorithmNameList_.size() - 1]); - sprintf(s, "%8.1e", stdDev[indicator][i][algorithmNameList_.size() - 1]); - out << "$" << m << "_{" << s << "}$ \\\\" << endl; - } // for - //out << "" + mean[0][problemList_.length-1][algorithmNameList_.length-1] + "\\\\"+ "\n" ) ; - - out << "\\hline" << endl; - out << "\\end{tabular}" << endl; - out << "\\end{scriptsize}" << endl; - out << "\\end{table}" << endl; - out.close(); + out << "\\hline" << endl; + + char m[20], s[20]; + // write lines + for (int i = 0; i < problemList_.size(); i++) + { + // find the best value and second best value + double bestValue ; + double bestValueIQR ; + double secondBestValue ; + double secondBestValueIQR ; + int bestIndex = -1 ; + int secondBestIndex = -1 ; + if (indicatorMinimize_[indicatorList_[indicator]] == true) // minimize by default + { + bestValue = std::numeric_limits::max(); + bestValueIQR = std::numeric_limits::max(); + secondBestValue = std::numeric_limits::max(); + secondBestValueIQR = std::numeric_limits::max(); + for (int j = 0; j < (algorithmNameList_.size()); j++) + { + if ((mean[indicator][i][j] < bestValue) || + ((mean[indicator][i][j] == bestValue) && (stdDev[indicator][i][j] < bestValueIQR))) + { + secondBestIndex = bestIndex ; + secondBestValue = bestValue ; + secondBestValueIQR = bestValueIQR ; + bestValue = mean[indicator][i][j]; + bestValueIQR = stdDev[indicator][i][j]; + bestIndex = j; + } + else if ((mean[indicator][i][j] < secondBestValue) || + ((mean[indicator][i][j] == secondBestValue) && (stdDev[indicator][i][j] < secondBestValueIQR))) + { + secondBestIndex = j ; + secondBestValue = mean[indicator][i][j] ; + secondBestValueIQR = stdDev[indicator][i][j] ; + } // else if + } + } // if + else // indicator to maximize e.g., the HV + { + bestValue = -std::numeric_limits::max(); + bestValueIQR = -std::numeric_limits::max(); + secondBestValue = -std::numeric_limits::max(); + secondBestValueIQR = -std::numeric_limits::max(); + for (int j = 0; j < (algorithmNameList_.size()); j++) + { + if ((mean[indicator][i][j] > bestValue) || + ((mean[indicator][i][j] == bestValue) && (stdDev[indicator][i][j] < bestValueIQR))) + { + secondBestIndex = bestIndex ; + secondBestValue = bestValue ; + secondBestValueIQR = bestValueIQR ; + bestValue = mean[indicator][i][j]; + bestValueIQR = stdDev[indicator][i][j]; + bestIndex = j; + } + else if ((mean[indicator][i][j] > secondBestValue) || + ((mean[indicator][i][j] == secondBestValue) && (stdDev[indicator][i][j] < secondBestValueIQR))) + { + secondBestIndex = j ; + secondBestValue = mean[indicator][i][j] ; + secondBestValueIQR = stdDev[indicator][i][j] ; + } // else if + } // for + } // else + + out << problemList_[i] << " & "; + for (int j = 0; j < (algorithmNameList_.size() - 1); j++) + { + if (j == bestIndex) + { + out << "\\cellcolor{gray95}"; + } + if (j == secondBestIndex) + { + out << "\\cellcolor{gray25}"; + } + + sprintf(m, "%10.2e", mean[indicator][i][j]); + sprintf(s, "%8.1e", stdDev[indicator][i][j]); + out << "$" << m << "_{" << s << "}$ & "; + } + if (bestIndex == (algorithmNameList_.size() - 1)) + { + out << "\\cellcolor{gray95}"; + } + sprintf(m, "%10.2e", mean[indicator][i][algorithmNameList_.size() - 1]); + sprintf(s, "%8.1e", stdDev[indicator][i][algorithmNameList_.size() - 1]); + out << "$" << m << "_{" << s << "}$ \\\\" << endl; + } // for + //out << "" + mean[0][problemList_.length-1][algorithmNameList_.length-1] + "\\\\"+ "\n" ) ; + + out << "\\hline" << endl; + out << "\\end{tabular}" << endl; + out << "\\end{scriptsize}" << endl; + out << "\\end{table}" << endl; + out.close(); } // printMeanStdDev void ExperimentReport::printMedianIQR(string fileName, int indicator, double *** median, - double *** IQR) { - std::fstream out(fileName.c_str(), std::ios::out | std::ios::app); - out << "\\" << endl; - out << "\\begin{table}" << endl; - out << "\\caption{" << indicatorList_[indicator] << ". Median and IQR}" << endl; - out << "\\label{table:median." << indicatorList_[indicator] << "}" << endl; - out << "\\begin{scriptsize}" << endl; - out << "\\centering" << endl; - out << "\\begin{tabular}{l"; - - // calculate the number of columns - for (int i = 0; i < algorithmNameList_.size(); i++) { - out << "l"; - } - out << "}" << endl; - - out << "\\hline"; - // write table head - for (int i = -1; i < (int) (algorithmNameList_.size()); i++) { - if (i == -1) { - out << " & "; - } else if (i == (algorithmNameList_.size() - 1)) { - out << " " << algorithmNameList_[i] << "\\\\" << endl; - } else { - out << "" << algorithmNameList_[i] << " & "; + double *** IQR) +{ + std::fstream out(fileName.c_str(), std::ios::out | std::ios::app); + out << "\\" << endl; + out << "\\begin{table}" << endl; + out << "\\caption{" << indicatorList_[indicator] << ". Median and IQR}" << endl; + out << "\\label{table:median." << indicatorList_[indicator] << "}" << endl; + out << "\\begin{scriptsize}" << endl; + out << "\\centering" << endl; + out << "\\begin{tabular}{l"; + + // calculate the number of columns + for (int i = 0; i < algorithmNameList_.size(); i++) + { + out << "l"; } - } - out << "\\hline" << endl; - - char m[20], s[20]; - // write lines - for (int i = 0; i < problemList_.size(); i++) { - // find the best value and second best value - double bestValue ; - double bestValueIQR ; - double secondBestValue ; - double secondBestValueIQR ; - int bestIndex = -1 ; - int secondBestIndex = -1 ; - if (indicatorMinimize_[indicatorList_[indicator]] == true) {// minimize by default - bestValue = std::numeric_limits::max(); - bestValueIQR = std::numeric_limits::max(); - secondBestValue = std::numeric_limits::max(); - secondBestValueIQR = std::numeric_limits::max(); - for (int j = 0; j < (algorithmNameList_.size()); j++) { - if ((median[indicator][i][j] < bestValue) || - ((median[indicator][i][j] == bestValue) && (IQR[indicator][i][j] < bestValueIQR))) { - secondBestIndex = bestIndex ; - secondBestValue = bestValue ; - secondBestValueIQR = bestValueIQR ; - bestValue = median[indicator][i][j]; - bestValueIQR = IQR[indicator][i][j]; - bestIndex = j; + out << "}" << endl; + + out << "\\hline"; + // write table head + for (int i = -1; i < (int) (algorithmNameList_.size()); i++) + { + if (i == -1) + { + out << " & "; } - else if ((median[indicator][i][j] < secondBestValue) || - ((median[indicator][i][j] == secondBestValue) && (IQR[indicator][i][j] < secondBestValueIQR))) { - secondBestIndex = j ; - secondBestValue = median[indicator][i][j] ; - secondBestValueIQR = IQR[indicator][i][j] ; - } // else if - } // for - } // if - else { // indicator to maximize e.g., the HV - bestValue = -std::numeric_limits::max(); - bestValueIQR = -std::numeric_limits::max(); - secondBestValue = -std::numeric_limits::max(); - secondBestValueIQR = -std::numeric_limits::max(); - for (int j = 0; j < (algorithmNameList_.size()); j++) { - if ((median[indicator][i][j] > bestValue) || - ((median[indicator][i][j] == bestValue) && (IQR[indicator][i][j] < bestValueIQR))) { - secondBestIndex = bestIndex ; - secondBestValue = bestValue ; - secondBestValueIQR = bestValueIQR ; - bestValue = median[indicator][i][j]; - bestValueIQR = IQR[indicator][i][j]; - bestIndex = j; + else if (i == (algorithmNameList_.size() - 1)) + { + out << " " << algorithmNameList_[i] << "\\\\" << endl; + } + else + { + out << "" << algorithmNameList_[i] << " & "; } - else if ((median[indicator][i][j] > secondBestValue) || - ((median[indicator][i][j] == secondBestValue) && (IQR[indicator][i][j] < secondBestValueIQR))) { - secondBestIndex = j ; - secondBestValue = median[indicator][i][j] ; - secondBestValueIQR = IQR[indicator][i][j] ; - } // else if - } // for - } // else - - - out << problemList_[i] + " & "; - for (int j = 0; j < (algorithmNameList_.size() - 1); j++) { - if (j == bestIndex) { - out << "\\cellcolor{gray95}"; - } - if (j == secondBestIndex) { - out << "\\cellcolor{gray25}"; - } - sprintf(m, "%10.2e", median[indicator][i][j]); - sprintf(s, "%8.1e", IQR[indicator][i][j]); - out << "$" << m << "_{" << s << "}$ & "; - } - if (bestIndex == (algorithmNameList_.size() - 1)) { - out << "\\cellcolor{gray95}"; } - sprintf(m, "%10.2e", median[indicator][i][algorithmNameList_.size() - 1]); - sprintf(s, "%8.1e", IQR[indicator][i][algorithmNameList_.size() - 1]); - out << "$" << m << "_{" << s << "}$ \\\\" << endl; - } // for - //out << "" << mean[0][problemList_.size()-1][algorithmNameList_.size()-1] << "\\\\" << endl; - - out << "\\hline" << endl; - out << "\\end{tabular}" << endl; - out << "\\end{scriptsize}" << endl; - out << "\\end{table}" << endl; - out.close(); + out << "\\hline" << endl; + + char m[20], s[20]; + // write lines + for (int i = 0; i < problemList_.size(); i++) + { + // find the best value and second best value + double bestValue ; + double bestValueIQR ; + double secondBestValue ; + double secondBestValueIQR ; + int bestIndex = -1 ; + int secondBestIndex = -1 ; + if (indicatorMinimize_[indicatorList_[indicator]] == true) // minimize by default + { + bestValue = std::numeric_limits::max(); + bestValueIQR = std::numeric_limits::max(); + secondBestValue = std::numeric_limits::max(); + secondBestValueIQR = std::numeric_limits::max(); + for (int j = 0; j < (algorithmNameList_.size()); j++) + { + if ((median[indicator][i][j] < bestValue) || + ((median[indicator][i][j] == bestValue) && (IQR[indicator][i][j] < bestValueIQR))) + { + secondBestIndex = bestIndex ; + secondBestValue = bestValue ; + secondBestValueIQR = bestValueIQR ; + bestValue = median[indicator][i][j]; + bestValueIQR = IQR[indicator][i][j]; + bestIndex = j; + } + else if ((median[indicator][i][j] < secondBestValue) || + ((median[indicator][i][j] == secondBestValue) && (IQR[indicator][i][j] < secondBestValueIQR))) + { + secondBestIndex = j ; + secondBestValue = median[indicator][i][j] ; + secondBestValueIQR = IQR[indicator][i][j] ; + } // else if + } // for + } // if + else // indicator to maximize e.g., the HV + { + bestValue = -std::numeric_limits::max(); + bestValueIQR = -std::numeric_limits::max(); + secondBestValue = -std::numeric_limits::max(); + secondBestValueIQR = -std::numeric_limits::max(); + for (int j = 0; j < (algorithmNameList_.size()); j++) + { + if ((median[indicator][i][j] > bestValue) || + ((median[indicator][i][j] == bestValue) && (IQR[indicator][i][j] < bestValueIQR))) + { + secondBestIndex = bestIndex ; + secondBestValue = bestValue ; + secondBestValueIQR = bestValueIQR ; + bestValue = median[indicator][i][j]; + bestValueIQR = IQR[indicator][i][j]; + bestIndex = j; + } + else if ((median[indicator][i][j] > secondBestValue) || + ((median[indicator][i][j] == secondBestValue) && (IQR[indicator][i][j] < secondBestValueIQR))) + { + secondBestIndex = j ; + secondBestValue = median[indicator][i][j] ; + secondBestValueIQR = IQR[indicator][i][j] ; + } // else if + } // for + } // else + + + out << problemList_[i] + " & "; + for (int j = 0; j < (algorithmNameList_.size() - 1); j++) + { + if (j == bestIndex) + { + out << "\\cellcolor{gray95}"; + } + if (j == secondBestIndex) + { + out << "\\cellcolor{gray25}"; + } + sprintf(m, "%10.2e", median[indicator][i][j]); + sprintf(s, "%8.1e", IQR[indicator][i][j]); + out << "$" << m << "_{" << s << "}$ & "; + } + if (bestIndex == (algorithmNameList_.size() - 1)) + { + out << "\\cellcolor{gray95}"; + } + sprintf(m, "%10.2e", median[indicator][i][algorithmNameList_.size() - 1]); + sprintf(s, "%8.1e", IQR[indicator][i][algorithmNameList_.size() - 1]); + out << "$" << m << "_{" << s << "}$ \\\\" << endl; + } // for + //out << "" << mean[0][problemList_.size()-1][algorithmNameList_.size()-1] << "\\\\" << endl; + + out << "\\hline" << endl; + out << "\\end{tabular}" << endl; + out << "\\end{scriptsize}" << endl; + out << "\\end{table}" << endl; + out.close(); } // printMedianIQR @@ -696,8 +788,9 @@ void ExperimentReport::printMedianIQR(string fileName, int indicator, double *** * Invoking the generateScripts method on the RBoxplot class */ void ExperimentReport::generateRBoxplotScripts (int rows, int cols, vector problems, - string prefix, bool notch, ExperimentReport * experiment) { - RBoxplot::generateScripts(rows, cols, problems, prefix, notch, this); + string prefix, bool notch, ExperimentReport * experiment) +{ + RBoxplot::generateScripts(rows, cols, problems, prefix, notch, this); } // generateRBoxplotScripts @@ -705,6 +798,7 @@ void ExperimentReport::generateRBoxplotScripts (int rows, int cols, vector problems, string prefix, - ExperimentReport * experiment) { - RWilcoxon::generateScripts(problems, prefix, this); + ExperimentReport * experiment) +{ + RWilcoxon::generateScripts(problems, prefix, this); } //generateRWilcoxonScripts diff --git a/src/experiments/ExperimentReport.h b/src/experiments/ExperimentReport.h index f58bf0d..7d5d126 100644 --- a/src/experiments/ExperimentReport.h +++ b/src/experiments/ExperimentReport.h @@ -51,39 +51,40 @@ using namespace std; * Abstract class generating jMetal experiments reports */ -class ExperimentReport : public Experiment { +class ExperimentReport : public Experiment +{ private: - void generateReferenceFronts(); - void calculateStatistics(vector vector_, map * values); - void printHeaderLatexCommands(string fileName); - void printEndLatexCommands(string fileName); - void printMeanStdDev(string fileName, int indicator, double*** mean, - double*** stdDev); - void printMedianIQR(string fileName, int indicator, double*** median, - double*** IQR); + void generateReferenceFronts(); + void calculateStatistics(vector vector_, map * values); + void printHeaderLatexCommands(string fileName); + void printEndLatexCommands(string fileName); + void printMeanStdDev(string fileName, int indicator, double*** mean, + double*** stdDev); + void printMedianIQR(string fileName, int indicator, double*** median, + double*** IQR); public: - vector paretoFrontFile_; // List of the files containing the pareto - // fronts corresponding to the problems in - // problemList_ - vector indicatorList_; // List of the quality indicators to be applied - string latexDirectory_; // Directory to store the latex files - string paretoFrontDirectory_; // Directory containing the Pareto front files - map indicatorMinimize_; // To indicate whether an indicator - // is to be minimized. Hard-coded - // in the constructor + vector paretoFrontFile_; // List of the files containing the pareto + // fronts corresponding to the problems in + // problemList_ + vector indicatorList_; // List of the quality indicators to be applied + string latexDirectory_; // Directory to store the latex files + string paretoFrontDirectory_; // Directory containing the Pareto front files + map indicatorMinimize_; // To indicate whether an indicator + // is to be minimized. Hard-coded + // in the constructor - ExperimentReport(); + ExperimentReport(); - void generateQualityIndicators(); - void generateLatexTables(); - void generateRBoxplotScripts(int rows, int cols, vector problems, - string prefix, bool notch, ExperimentReport * experiment); - void generateRWilcoxonScripts(vector problems, string prefix, - ExperimentReport * experiment); + void generateQualityIndicators(); + void generateLatexTables(); + void generateRBoxplotScripts(int rows, int cols, vector problems, + string prefix, bool notch, ExperimentReport * experiment); + void generateRWilcoxonScripts(vector problems, string prefix, + ExperimentReport * experiment); }; // ExperimentReport diff --git a/src/experiments/Settings.cpp b/src/experiments/Settings.cpp index ef2686d..a258788 100644 --- a/src/experiments/Settings.cpp +++ b/src/experiments/Settings.cpp @@ -23,14 +23,16 @@ /** * Default constructor */ -Settings::Settings () { +Settings::Settings () +{ } // Settings /** * Constructor */ -Settings::Settings(char * problemName) { - problemName_ = problemName; +Settings::Settings(char * problemName) +{ + problemName_ = problemName; } // Settings /** @@ -43,7 +45,8 @@ Settings::~Settings() { /* do nothing */ } * * To be implemented. Missing the reflection features of Java here */ -Algorithm * Settings::configure(map settings) { - return NULL ; +Algorithm * Settings::configure(map settings) +{ + return NULL ; } // configure diff --git a/src/experiments/Settings.h b/src/experiments/Settings.h index 02e00e8..730431b 100644 --- a/src/experiments/Settings.h +++ b/src/experiments/Settings.h @@ -26,19 +26,20 @@ #include #include -class Settings { +class Settings +{ protected: - Problem * problem_ ; - string problemName_ ; - string paretoFrontFile_ ; + Problem * problem_ ; + string problemName_ ; + string paretoFrontFile_ ; public: - Settings() ; - Settings(char * problemName) ; - virtual ~Settings() = 0; + Settings() ; + Settings(char * problemName) ; + virtual ~Settings() = 0; - virtual Algorithm * configure() = 0 ; - Algorithm * configure(map settings) ; + virtual Algorithm * configure() = 0 ; + Algorithm * configure(map settings) ; }; // Settings #endif //__SETTINGS__ diff --git a/src/experiments/main/StandardStudyExecution.cpp b/src/experiments/main/StandardStudyExecution.cpp index 7f12743..26edbb9 100644 --- a/src/experiments/main/StandardStudyExecution.cpp +++ b/src/experiments/main/StandardStudyExecution.cpp @@ -36,72 +36,77 @@ * @param experimentIndividualId Index of the experiment individual */ Algorithm * StandardStudyExecution::algorithmSettings(string problemName, - int algorithmId, int experimentIndividualId) { - - Algorithm * alg; - - switch (algorithmId) { - case 0: - algorithmSettingsList_[experimentIndividualId] = - new NSGAII_Settings(problemName); - alg = (algorithmSettingsList_[experimentIndividualId])->configure(); - break; - case 1: - algorithmSettingsList_[experimentIndividualId] = - new SMPSO_Settings(problemName); - alg = (algorithmSettingsList_[experimentIndividualId])->configure(); - break; - case 2: - algorithmSettingsList_[experimentIndividualId] = - new GDE3_Settings(problemName); - alg = (algorithmSettingsList_[experimentIndividualId])->configure(); - break; - } - - return alg; + int algorithmId, int experimentIndividualId) +{ + + Algorithm * alg; + + switch (algorithmId) + { + case 0: + algorithmSettingsList_[experimentIndividualId] = + new NSGAII_Settings(problemName); + alg = (algorithmSettingsList_[experimentIndividualId])->configure(); + break; + case 1: + algorithmSettingsList_[experimentIndividualId] = + new SMPSO_Settings(problemName); + alg = (algorithmSettingsList_[experimentIndividualId])->configure(); + break; + case 2: + algorithmSettingsList_[experimentIndividualId] = + new GDE3_Settings(problemName); + alg = (algorithmSettingsList_[experimentIndividualId])->configure(); + break; + } + + return alg; } // algorithmSettings -int main(int argc, char ** argv) { +int main(int argc, char ** argv) +{ - StandardStudyExecution * exp = new StandardStudyExecution() ; + StandardStudyExecution * exp = new StandardStudyExecution() ; - // Name of the experiment: - exp->experimentName_ = "StandardStudy"; + // Name of the experiment: + exp->experimentName_ = "StandardStudy"; - // List of algorithm names to be used in the experiment - // (please, refer to the README to check the possible values): - vector algorithmNameList_ { - "NSGAII", "SMPSO", "GDE3"}; + // List of algorithm names to be used in the experiment + // (please, refer to the README to check the possible values): + vector algorithmNameList_ + { + "NSGAII", "SMPSO", "GDE3"}; - // List of problem names to be used in the experiment - // (please, refer to the README to check the possible values): - vector problemList_ { - "ZDT1", "ZDT2", "ZDT3", "ZDT4", "ZDT6"}; + // List of problem names to be used in the experiment + // (please, refer to the README to check the possible values): + vector problemList_ + { + "ZDT1", "ZDT2", "ZDT3", "ZDT4", "ZDT6"}; - // Directory where the execution results will be stored: - //exp->experimentBaseDirectory_ = "C:/jMetal/pruebas/jmetal-cpp/" + - exp->experimentBaseDirectory_ = "jMetal/pruebas/jmetal-cpp/" + - exp->experimentName_; + // Directory where the execution results will be stored: + //exp->experimentBaseDirectory_ = "C:/jMetal/pruebas/jmetal-cpp/" + + exp->experimentBaseDirectory_ = "jMetal/pruebas/jmetal-cpp/" + + exp->experimentName_; - // Number of independent runs of each algorithm for each problem: - exp->independentRuns_ = 20; + // Number of independent runs of each algorithm for each problem: + exp->independentRuns_ = 20; - // Number of threads to be used to execute the experiment - int numberOfThreads = 8; - - exp->algorithmNameList_ = algorithmNameList_; - exp->problemList_ = problemList_; - int numberOfAlgorithms = exp->algorithmNameList_.size(); + // Number of threads to be used to execute the experiment + int numberOfThreads = 8; - cout << "Experiment (" << exp->experimentName_ << ") is starting." << endl; + exp->algorithmNameList_ = algorithmNameList_; + exp->problemList_ = problemList_; + int numberOfAlgorithms = exp->algorithmNameList_.size(); - exp->runExperiment(numberOfThreads); + cout << "Experiment (" << exp->experimentName_ << ") is starting." << endl; - cout << "Experiment (" << exp->experimentName_ << ") has finished." << endl; + exp->runExperiment(numberOfThreads); - delete exp; + cout << "Experiment (" << exp->experimentName_ << ") has finished." << endl; + + delete exp; } // main diff --git a/src/experiments/main/StandardStudyExecution.h b/src/experiments/main/StandardStudyExecution.h index c15197c..c69fe70 100644 --- a/src/experiments/main/StandardStudyExecution.h +++ b/src/experiments/main/StandardStudyExecution.h @@ -33,11 +33,12 @@ * spread and additive epsilon indicators are used for performance assessment. */ -class StandardStudyExecution : public ExperimentExecution { +class StandardStudyExecution : public ExperimentExecution +{ public: - Algorithm * algorithmSettings(string problemName, int algorithmId, - int experimentIndividualId); + Algorithm * algorithmSettings(string problemName, int algorithmId, + int experimentIndividualId); }; diff --git a/src/experiments/main/StandardStudyExecutionSO.cpp b/src/experiments/main/StandardStudyExecutionSO.cpp index c0b2cfa..450e9fc 100644 --- a/src/experiments/main/StandardStudyExecutionSO.cpp +++ b/src/experiments/main/StandardStudyExecutionSO.cpp @@ -36,77 +36,82 @@ * @param experimentIndividualId Index of the experiment individual */ Algorithm * StandardStudyExecutionSO::algorithmSettings(string problemName, - int algorithmId, int experimentIndividualId) { - - Algorithm * alg; - - switch (algorithmId) { - case 0: - algorithmSettingsList_[experimentIndividualId] = - new gGA_Settings(problemName); - alg = (algorithmSettingsList_[experimentIndividualId])->configure(); - break; - case 1: - algorithmSettingsList_[experimentIndividualId] = - new ssGA_Settings(problemName); - alg = (algorithmSettingsList_[experimentIndividualId])->configure(); - break; - case 2: - algorithmSettingsList_[experimentIndividualId] = - new DE_Settings(problemName); - alg = (algorithmSettingsList_[experimentIndividualId])->configure(); - break; - case 3: - algorithmSettingsList_[experimentIndividualId] = - new PSO_Settings(problemName); - alg = (algorithmSettingsList_[experimentIndividualId])->configure(); - break; - } - - return alg; + int algorithmId, int experimentIndividualId) +{ + + Algorithm * alg; + + switch (algorithmId) + { + case 0: + algorithmSettingsList_[experimentIndividualId] = + new gGA_Settings(problemName); + alg = (algorithmSettingsList_[experimentIndividualId])->configure(); + break; + case 1: + algorithmSettingsList_[experimentIndividualId] = + new ssGA_Settings(problemName); + alg = (algorithmSettingsList_[experimentIndividualId])->configure(); + break; + case 2: + algorithmSettingsList_[experimentIndividualId] = + new DE_Settings(problemName); + alg = (algorithmSettingsList_[experimentIndividualId])->configure(); + break; + case 3: + algorithmSettingsList_[experimentIndividualId] = + new PSO_Settings(problemName); + alg = (algorithmSettingsList_[experimentIndividualId])->configure(); + break; + } + + return alg; } // algorithmSettings -int main(int argc, char ** argv) { +int main(int argc, char ** argv) +{ - StandardStudyExecutionSO * exp = new StandardStudyExecutionSO() ; + StandardStudyExecutionSO * exp = new StandardStudyExecutionSO() ; - // Name of the experiment: - exp->experimentName_ = "StandardStudySO"; + // Name of the experiment: + exp->experimentName_ = "StandardStudySO"; - // List of algorithm names to be used in the experiment - // (please, refer to the README to check the possible values): - vector algorithmNameList_ { - "gGA", "ssGA", "DE", "PSO"}; + // List of algorithm names to be used in the experiment + // (please, refer to the README to check the possible values): + vector algorithmNameList_ + { + "gGA", "ssGA", "DE", "PSO"}; - // List of problem names to be used in the experiment - // (please, refer to the README to check the possible values): - vector problemList_ { - "Sphere", "Griewank"}; + // List of problem names to be used in the experiment + // (please, refer to the README to check the possible values): + vector problemList_ + { + "Sphere", "Griewank"}; - // Directory where the execution results will be stored: - exp->experimentBaseDirectory_ = "C:/jMetal/pruebas/jmetal-cpp/" + - exp->experimentName_; + // Directory where the execution results will be stored: + exp->experimentBaseDirectory_ = "C:/jMetal/pruebas/jmetal-cpp/" + + exp->experimentName_; - // Number of independent runs of each algorithm for each problem: - exp->independentRuns_ = 20; + // Number of independent runs of each algorithm for each problem: + exp->independentRuns_ = 20; - // Number of threads to be used to execute the experiment - int numberOfThreads = 3; + // Number of threads to be used to execute the experiment + int numberOfThreads = 3; - exp->algorithmNameList_ = algorithmNameList_; - exp->problemList_ = problemList_; - int numberOfAlgorithms = exp->algorithmNameList_.size(); - exp->isSingleObjective_ = true; + exp->algorithmNameList_ = algorithmNameList_; + exp->problemList_ = problemList_; + int numberOfAlgorithms = exp->algorithmNameList_.size(); + exp->isSingleObjective_ = true; - cout << "Experiment (" << exp->experimentName_ << ") is starting." << endl; + cout << "Experiment (" << exp->experimentName_ << ") is starting." << endl; - exp->runExperiment(numberOfThreads); + exp->runExperiment(numberOfThreads); - cout << "Experiment (" << exp->experimentName_ << ") has finished." << endl; + cout << "Experiment (" << exp->experimentName_ << ") has finished." << endl; - delete exp; + delete exp; } // main diff --git a/src/experiments/main/StandardStudyExecutionSO.h b/src/experiments/main/StandardStudyExecutionSO.h index c9766a4..f5cd012 100644 --- a/src/experiments/main/StandardStudyExecutionSO.h +++ b/src/experiments/main/StandardStudyExecutionSO.h @@ -34,11 +34,12 @@ * spread and additive epsilon indicators are used for performance assessment. */ -class StandardStudyExecutionSO : public ExperimentExecution { +class StandardStudyExecutionSO : public ExperimentExecution +{ public: - Algorithm * algorithmSettings(string problemName, int algorithmId, - int experimentIndividualId); + Algorithm * algorithmSettings(string problemName, int algorithmId, + int experimentIndividualId); }; diff --git a/src/experiments/main/StandardStudyReportPF.cpp b/src/experiments/main/StandardStudyReportPF.cpp index 2ca2d9a..6cd00a6 100644 --- a/src/experiments/main/StandardStudyReportPF.cpp +++ b/src/experiments/main/StandardStudyReportPF.cpp @@ -29,74 +29,80 @@ */ -int main(int argc, char ** argv) { - StandardStudyReportPF * exp = new StandardStudyReportPF() ; - - // Name of the experiment: - exp->experimentName_ = "StandardStudy"; - - // List of algorithm names to be analyzed in the experiment - // (please, refer to the README to check the possible values): - vector algorithmNameList_ { - "NSGAII", "SMPSO", "GDE3"}; - exp->algorithmNameList_ = algorithmNameList_; - - // List of problem names to be analyzed in the experiment - // (please, refer to the README to check the possible values): - vector problemList_ { - "ZDT1", "ZDT2", "ZDT3", "ZDT4", "ZDT6"}; - exp->problemList_ = problemList_; - - // List of optimal pareto front files to be used when calculating quality - // indicators. It's not necessary to define this variable when not knowing - // or not wanting to use optimal pareto fronts. - vector paretoFrontFile_ { - "ZDT1.pf", "ZDT2.pf", "ZDT3.pf", "ZDT4.pf", "ZDT6.pf"}; - exp->paretoFrontFile_ = paretoFrontFile_; - - // List of quality indicator names to be calculated in the reports - // (please, refer to the README to check the possible values): - vector indicatorList_ { - "HV", "SPREAD", "EPSILON"}; - exp->indicatorList_ = indicatorList_; - - // Directory from where the execution results will be readed: - exp->experimentBaseDirectory_ = "C:/jMetal/pruebas/jmetal-cpp/" + - exp->experimentName_; - - // Directory from where the optimal pareto front files will be readed. - // Comment this following line to not use pareto fronts in order to - // calculate reference fronts. - exp->paretoFrontDirectory_ = "C:/jMetal/pruebas/data/paretoFronts"; +int main(int argc, char ** argv) +{ + StandardStudyReportPF * exp = new StandardStudyReportPF() ; + + // Name of the experiment: + exp->experimentName_ = "StandardStudy"; + + // List of algorithm names to be analyzed in the experiment + // (please, refer to the README to check the possible values): + vector algorithmNameList_ + { + "NSGAII", "SMPSO", "GDE3"}; + exp->algorithmNameList_ = algorithmNameList_; + + // List of problem names to be analyzed in the experiment + // (please, refer to the README to check the possible values): + vector problemList_ + { + "ZDT1", "ZDT2", "ZDT3", "ZDT4", "ZDT6"}; + exp->problemList_ = problemList_; + + // List of optimal pareto front files to be used when calculating quality + // indicators. It's not necessary to define this variable when not knowing + // or not wanting to use optimal pareto fronts. + vector paretoFrontFile_ + { + "ZDT1.pf", "ZDT2.pf", "ZDT3.pf", "ZDT4.pf", "ZDT6.pf"}; + exp->paretoFrontFile_ = paretoFrontFile_; + + // List of quality indicator names to be calculated in the reports + // (please, refer to the README to check the possible values): + vector indicatorList_ + { + "HV", "SPREAD", "EPSILON"}; + exp->indicatorList_ = indicatorList_; + + // Directory from where the execution results will be readed: + exp->experimentBaseDirectory_ = "C:/jMetal/pruebas/jmetal-cpp/" + + exp->experimentName_; + + // Directory from where the optimal pareto front files will be readed. + // Comment this following line to not use pareto fronts in order to + // calculate reference fronts. + exp->paretoFrontDirectory_ = "C:/jMetal/pruebas/data/paretoFronts"; // // Directory where the calculated references front files will be stored. // // This line is not needed when you are using existing optimal pareto fronts. // exp->referenceFrontDirectory_= "C:/antonio/Softw/pruebas/data/referenceFronts"; - // Number of independent runs of each algorithm for each problem: - exp->independentRuns_ = 20; + // Number of independent runs of each algorithm for each problem: + exp->independentRuns_ = 20; - int numberOfAlgorithms = exp->algorithmNameList_.size(); + int numberOfAlgorithms = exp->algorithmNameList_.size(); - // Generate quality indicators - exp->generateQualityIndicators(); + // Generate quality indicators + exp->generateQualityIndicators(); - // Generate latex tables (comment this sentence is not desired) - exp->generateLatexTables(); + // Generate latex tables (comment this sentence is not desired) + exp->generateLatexTables(); - // Configure the R scripts to be generated - int rows = 3 ; - int columns = 2 ; - string prefix = "ZDT"; - vector problemsValues { - "ZDT1", "ZDT2", "ZDT3", "ZDT4", "ZDT6"}; - vector problems = problemsValues; + // Configure the R scripts to be generated + int rows = 3 ; + int columns = 2 ; + string prefix = "ZDT"; + vector problemsValues + { + "ZDT1", "ZDT2", "ZDT3", "ZDT4", "ZDT6"}; + vector problems = problemsValues; - bool notch; - exp->generateRBoxplotScripts(rows, columns, problems, prefix, notch = false, exp); - exp->generateRWilcoxonScripts(problems, prefix, exp); + bool notch; + exp->generateRBoxplotScripts(rows, columns, problems, prefix, notch = false, exp); + exp->generateRWilcoxonScripts(problems, prefix, exp); - delete exp; + delete exp; } // main diff --git a/src/experiments/main/StandardStudyReportRF.cpp b/src/experiments/main/StandardStudyReportRF.cpp index e6a57fe..1b4e566 100644 --- a/src/experiments/main/StandardStudyReportRF.cpp +++ b/src/experiments/main/StandardStudyReportRF.cpp @@ -29,23 +29,26 @@ */ -int main(int argc, char ** argv) { - StandardStudyReportRF * exp = new StandardStudyReportRF() ; - - // Name of the experiment: - exp->experimentName_ = "StandardStudy"; - - // List of algorithm names to be analyzed in the experiment - // (please, refer to the README to check the possible values): - vector algorithmNameList_ { - "NSGAII", "SMPSO", "GDE3"}; - exp->algorithmNameList_ = algorithmNameList_; - - // List of problem names to be analyzed in the experiment - // (please, refer to the README to check the possible values): - vector problemList_ { - "ZDT1", "ZDT2", "ZDT3", "ZDT4", "ZDT6"}; - exp->problemList_ = problemList_; +int main(int argc, char ** argv) +{ + StandardStudyReportRF * exp = new StandardStudyReportRF() ; + + // Name of the experiment: + exp->experimentName_ = "StandardStudy"; + + // List of algorithm names to be analyzed in the experiment + // (please, refer to the README to check the possible values): + vector algorithmNameList_ + { + "NSGAII", "SMPSO", "GDE3"}; + exp->algorithmNameList_ = algorithmNameList_; + + // List of problem names to be analyzed in the experiment + // (please, refer to the README to check the possible values): + vector problemList_ + { + "ZDT1", "ZDT2", "ZDT3", "ZDT4", "ZDT6"}; + exp->problemList_ = problemList_; // // List of optimal pareto front files to be used when calculating quality // // indicators. It's not necessary to define this variable when not knowing @@ -54,15 +57,16 @@ int main(int argc, char ** argv) { // "ZDT1.pf", "ZDT2.pf", "ZDT3.pf", "ZDT4.pf", "ZDT6.pf"}; // exp->paretoFrontFile_.assign(paretoFrontFile_, end(paretoFrontFile_)); - // List of quality indicator names to be calculated in the reports - // (please, refer to the README to check the possible values): - vector indicatorList_ { - "HV", "SPREAD", "EPSILON"}; - exp->indicatorList_ = indicatorList_; + // List of quality indicator names to be calculated in the reports + // (please, refer to the README to check the possible values): + vector indicatorList_ + { + "HV", "SPREAD", "EPSILON"}; + exp->indicatorList_ = indicatorList_; - // Directory from where the execution results will be readed: - exp->experimentBaseDirectory_ = "C:/jMetal/pruebas/jmetal-cpp/" + - exp->experimentName_; + // Directory from where the execution results will be readed: + exp->experimentBaseDirectory_ = "C:/jMetal/pruebas/jmetal-cpp/" + + exp->experimentName_; // // Directory from where the optimal pareto front files will be readed. // // Comment this following line to not use pareto fronts in order to @@ -73,30 +77,31 @@ int main(int argc, char ** argv) { // // This line is not needed when you are using existing optimal pareto fronts. // exp->referenceFrontDirectory_= "C:/antonio/Softw/pruebas/data/referenceFronts"; - // Number of independent runs of each algorithm for each problem: - exp->independentRuns_ = 20; + // Number of independent runs of each algorithm for each problem: + exp->independentRuns_ = 20; - int numberOfAlgorithms = exp->algorithmNameList_.size(); + int numberOfAlgorithms = exp->algorithmNameList_.size(); - // Generate quality indicators - exp->generateQualityIndicators(); + // Generate quality indicators + exp->generateQualityIndicators(); - // Generate latex tables (comment this sentence is not desired) - exp->generateLatexTables(); + // Generate latex tables (comment this sentence is not desired) + exp->generateLatexTables(); - // Configure the R scripts to be generated - int rows = 3 ; - int columns = 2 ; - string prefix = "ZDT"; - vector problemsValues { - "ZDT1", "ZDT2", "ZDT3", "ZDT4", "ZDT6"}; - vector problems = problemsValues; + // Configure the R scripts to be generated + int rows = 3 ; + int columns = 2 ; + string prefix = "ZDT"; + vector problemsValues + { + "ZDT1", "ZDT2", "ZDT3", "ZDT4", "ZDT6"}; + vector problems = problemsValues; - bool notch; - exp->generateRBoxplotScripts(rows, columns, problems, prefix, notch = false, exp); - exp->generateRWilcoxonScripts(problems, prefix, exp); + bool notch; + exp->generateRBoxplotScripts(rows, columns, problems, prefix, notch = false, exp); + exp->generateRWilcoxonScripts(problems, prefix, exp); - delete exp; + delete exp; } // main diff --git a/src/experiments/main/StandardStudyReportSO.cpp b/src/experiments/main/StandardStudyReportSO.cpp index a49251b..bd2c343 100644 --- a/src/experiments/main/StandardStudyReportSO.cpp +++ b/src/experiments/main/StandardStudyReportSO.cpp @@ -29,23 +29,26 @@ */ -int main(int argc, char ** argv) { - StandardStudyReportSO * exp = new StandardStudyReportSO() ; - - // Name of the experiment: - exp->experimentName_ = "StandardStudySO"; - - // List of algorithm names to be analyzed in the experiment - // (please, refer to the README to check the possible values): - vector algorithmNameList_ { - "gGA", "ssGA", "DE", "PSO"}; - exp->algorithmNameList_ = algorithmNameList_; - - // List of problem names to be analyzed in the experiment - // (please, refer to the README to check the possible values): - vector problemList_ { - "Sphere", "Griewank"}; - exp->problemList_ = problemList_; +int main(int argc, char ** argv) +{ + StandardStudyReportSO * exp = new StandardStudyReportSO() ; + + // Name of the experiment: + exp->experimentName_ = "StandardStudySO"; + + // List of algorithm names to be analyzed in the experiment + // (please, refer to the README to check the possible values): + vector algorithmNameList_ + { + "gGA", "ssGA", "DE", "PSO"}; + exp->algorithmNameList_ = algorithmNameList_; + + // List of problem names to be analyzed in the experiment + // (please, refer to the README to check the possible values): + vector problemList_ + { + "Sphere", "Griewank"}; + exp->problemList_ = problemList_; // // List of optimal pareto front files to be used when calculating quality // // indicators. It's not necessary to define this variable when not knowing @@ -54,15 +57,16 @@ int main(int argc, char ** argv) { // "ZDT1.pf", "ZDT2.pf", "ZDT3.pf", "ZDT4.pf", "ZDT6.pf"}; // exp->paretoFrontFile_.assign(paretoFrontFile_, end(paretoFrontFile_)); - // List of quality indicator names to be calculated in the reports - // (please, refer to the README to check the possible values): - vector indicatorList_ { - "FIT"}; - exp->indicatorList_ = indicatorList_; + // List of quality indicator names to be calculated in the reports + // (please, refer to the README to check the possible values): + vector indicatorList_ + { + "FIT"}; + exp->indicatorList_ = indicatorList_; - // Directory from where the execution results will be readed: - exp->experimentBaseDirectory_ = "C:/jMetal/pruebas/jmetal-cpp/" + - exp->experimentName_; + // Directory from where the execution results will be readed: + exp->experimentBaseDirectory_ = "C:/jMetal/pruebas/jmetal-cpp/" + + exp->experimentName_; // // Directory from where the optimal pareto front files will be readed. // // Comment this following line to not use pareto fronts in order to @@ -73,31 +77,32 @@ int main(int argc, char ** argv) { // // This line is not needed when you are using existing optimal pareto fronts. // exp->referenceFrontDirectory_= "C:/antonio/Softw/pruebas/data/referenceFronts"; - // Number of independent runs of each algorithm for each problem: - exp->independentRuns_ = 20; + // Number of independent runs of each algorithm for each problem: + exp->independentRuns_ = 20; - int numberOfAlgorithms = exp->algorithmNameList_.size(); - exp->isSingleObjective_ = true; + int numberOfAlgorithms = exp->algorithmNameList_.size(); + exp->isSingleObjective_ = true; - // Generate quality indicators - exp->generateQualityIndicators(); + // Generate quality indicators + exp->generateQualityIndicators(); - // Generate latex tables (comment this sentence is not desired) - exp->generateLatexTables(); + // Generate latex tables (comment this sentence is not desired) + exp->generateLatexTables(); - // Configure the R scripts to be generated - int rows = 3 ; - int columns = 2 ; - string prefix = "SO"; - vector problemsValues { - "Sphere", "Griewank"}; - vector problems = problemsValues; + // Configure the R scripts to be generated + int rows = 3 ; + int columns = 2 ; + string prefix = "SO"; + vector problemsValues + { + "Sphere", "Griewank"}; + vector problems = problemsValues; - bool notch; - exp->generateRBoxplotScripts(rows, columns, problems, prefix, notch = false, exp); - exp->generateRWilcoxonScripts(problems, prefix, exp); + bool notch; + exp->generateRBoxplotScripts(rows, columns, problems, prefix, notch = false, exp); + exp->generateRWilcoxonScripts(problems, prefix, exp); - delete exp; + delete exp; } // main diff --git a/src/experiments/settings/DE_Settings.cpp b/src/experiments/settings/DE_Settings.cpp index 04a5ef2..9a61715 100644 --- a/src/experiments/settings/DE_Settings.cpp +++ b/src/experiments/settings/DE_Settings.cpp @@ -23,65 +23,69 @@ /** * Default constructor */ -DE_Settings::DE_Settings () : Settings() { +DE_Settings::DE_Settings () : Settings() +{ } // DE_Settings /** * Destructor */ -DE_Settings::~DE_Settings () { - delete algorithm ; - delete crossover ; // Crossover operator - delete selection ; // Selection operator +DE_Settings::~DE_Settings () +{ + delete algorithm ; + delete crossover ; // Crossover operator + delete selection ; // Selection operator } // ~DE_Settings /** * Constructor */ -DE_Settings::DE_Settings(string problemName) { - problemName_ = problemName ; +DE_Settings::DE_Settings(string problemName) +{ + problemName_ = problemName ; - problem_ = ProblemFactory::getProblem((char *) problemName_.c_str()); + problem_ = ProblemFactory::getProblem((char *) problemName_.c_str()); - // Algorithm parameters - populationSize_ = 100; - maxEvaluations_ = 25000; - crParameter_ = 0.5; - fParameter_ = 0.5; - deVariantParameter_ = "rand/1/bin"; + // Algorithm parameters + populationSize_ = 100; + maxEvaluations_ = 25000; + crParameter_ = 0.5; + fParameter_ = 0.5; + deVariantParameter_ = "rand/1/bin"; } // DE_Settings /** * Configure method */ -Algorithm * DE_Settings::configure() { +Algorithm * DE_Settings::configure() +{ - algorithm = new DE(problem_); - algorithm->setInputParameter("populationSize",&populationSize_); - algorithm->setInputParameter("maxEvaluations",&maxEvaluations_); + algorithm = new DE(problem_); + algorithm->setInputParameter("populationSize",&populationSize_); + algorithm->setInputParameter("maxEvaluations",&maxEvaluations_); - map parameters; + map parameters; - // Crossover operator - double crParameter = crParameter_; - double fParameter = fParameter_; - parameters["CR"] = &crParameter; - parameters["F"] = &fParameter; - string deVariantParameter = deVariantParameter_; - parameters["DE_VARIANT"] = &deVariantParameter; - crossover = new DifferentialEvolutionCrossover(parameters); + // Crossover operator + double crParameter = crParameter_; + double fParameter = fParameter_; + parameters["CR"] = &crParameter; + parameters["F"] = &fParameter; + string deVariantParameter = deVariantParameter_; + parameters["DE_VARIANT"] = &deVariantParameter; + crossover = new DifferentialEvolutionCrossover(parameters); - // Selection operator - parameters.clear(); - selection = new DifferentialEvolutionSelection(parameters) ; + // Selection operator + parameters.clear(); + selection = new DifferentialEvolutionSelection(parameters) ; - // Add the operators to the algorithm - algorithm->addOperator("crossover",crossover); - algorithm->addOperator("selection",selection); + // Add the operators to the algorithm + algorithm->addOperator("crossover",crossover); + algorithm->addOperator("selection",selection); - cout << "DE algorithm initialized." << endl; + cout << "DE algorithm initialized." << endl; - return algorithm ; + return algorithm ; } // configure diff --git a/src/experiments/settings/DE_Settings.h b/src/experiments/settings/DE_Settings.h index f3d224e..a0eec58 100644 --- a/src/experiments/settings/DE_Settings.h +++ b/src/experiments/settings/DE_Settings.h @@ -26,24 +26,25 @@ #include #include -class DE_Settings : public Settings { +class DE_Settings : public Settings +{ private: - int populationSize_ ; - int maxEvaluations_ ; - double crParameter_ ; - double fParameter_ ; - string deVariantParameter_ ; + int populationSize_ ; + int maxEvaluations_ ; + double crParameter_ ; + double fParameter_ ; + string deVariantParameter_ ; - Algorithm * algorithm ; - Operator * crossover ; // Crossover operator - Operator * selection ; // Selection operator + Algorithm * algorithm ; + Operator * crossover ; // Crossover operator + Operator * selection ; // Selection operator public: - DE_Settings() ; - DE_Settings(string problemName) ; - ~DE_Settings() ; + DE_Settings() ; + DE_Settings(string problemName) ; + ~DE_Settings() ; - Algorithm * configure() ; + Algorithm * configure() ; }; // DE_Settings #endif // __DE_SETTINGS__ diff --git a/src/experiments/settings/GDE3_Settings.cpp b/src/experiments/settings/GDE3_Settings.cpp index e7920f6..639540d 100644 --- a/src/experiments/settings/GDE3_Settings.cpp +++ b/src/experiments/settings/GDE3_Settings.cpp @@ -25,34 +25,37 @@ /** * Default constructor */ -GDE3_Settings::GDE3_Settings () : Settings() { +GDE3_Settings::GDE3_Settings () : Settings() +{ } // GDE3_Settings /** * Destructor */ -GDE3_Settings::~GDE3_Settings () { - delete algorithm ; - delete crossover ; // Crossover operator - delete selection ; // Selection operator +GDE3_Settings::~GDE3_Settings () +{ + delete algorithm ; + delete crossover ; // Crossover operator + delete selection ; // Selection operator } // ~GDE3_Settings /** * Constructor */ -GDE3_Settings::GDE3_Settings(string problemName) { +GDE3_Settings::GDE3_Settings(string problemName) +{ - problemName_ = problemName ; + problemName_ = problemName ; - problem_ = ProblemFactory::getProblem((char *) problemName_.c_str()); + problem_ = ProblemFactory::getProblem((char *) problemName_.c_str()); - // Default settings - CR_ = 0.5; - F_ = 0.5; - populationSize_ = 100; - maxIterations_ = 250; + // Default settings + CR_ = 0.5; + F_ = 0.5; + populationSize_ = 100; + maxIterations_ = 250; } // GDE3_Settings @@ -60,32 +63,33 @@ GDE3_Settings::GDE3_Settings(string problemName) { /** * Configure method */ -Algorithm * GDE3_Settings::configure() { +Algorithm * GDE3_Settings::configure() +{ - algorithm = new GDE3(problem_); - algorithm->setInputParameter("populationSize",&populationSize_); - algorithm->setInputParameter("maxIterations",&maxIterations_); + algorithm = new GDE3(problem_); + algorithm->setInputParameter("populationSize",&populationSize_); + algorithm->setInputParameter("maxIterations",&maxIterations_); - // Mutation and Crossover for Real codification - map parameters; + // Mutation and Crossover for Real codification + map parameters; - double CR = CR_; - double F = F_; - parameters["CR"] = &CR; - parameters["F"] = &F; - crossover = new DifferentialEvolutionCrossover(parameters); + double CR = CR_; + double F = F_; + parameters["CR"] = &CR; + parameters["F"] = &F; + crossover = new DifferentialEvolutionCrossover(parameters); - // Selection Operator - parameters.clear(); - selection = new DifferentialEvolutionSelection(parameters); + // Selection Operator + parameters.clear(); + selection = new DifferentialEvolutionSelection(parameters); - // Add the operators to the algorithm - algorithm->addOperator("crossover",crossover); - algorithm->addOperator("selection",selection); + // Add the operators to the algorithm + algorithm->addOperator("crossover",crossover); + algorithm->addOperator("selection",selection); - cout << "GDE3 algorithm initialized." << endl; + cout << "GDE3 algorithm initialized." << endl; - return algorithm ; + return algorithm ; } // configure diff --git a/src/experiments/settings/GDE3_Settings.h b/src/experiments/settings/GDE3_Settings.h index b501788..c06c62b 100644 --- a/src/experiments/settings/GDE3_Settings.h +++ b/src/experiments/settings/GDE3_Settings.h @@ -26,25 +26,26 @@ #include #include -class GDE3_Settings : public Settings{ +class GDE3_Settings : public Settings +{ private: - double CR_ ; - double F_ ; - int populationSize_ ; - int maxIterations_ ; + double CR_ ; + double F_ ; + int populationSize_ ; + int maxIterations_ ; - Algorithm * algorithm ; - Operator * crossover ; // Crossover operator - Operator * selection ; // Selection operator + Algorithm * algorithm ; + Operator * crossover ; // Crossover operator + Operator * selection ; // Selection operator public: - GDE3_Settings() ; - GDE3_Settings(string problemName) ; - ~GDE3_Settings() ; + GDE3_Settings() ; + GDE3_Settings(string problemName) ; + ~GDE3_Settings() ; - Algorithm * configure() ; + Algorithm * configure() ; }; // GDE3_Settings diff --git a/src/experiments/settings/NSGAII_Settings.cpp b/src/experiments/settings/NSGAII_Settings.cpp index 4bbb008..6273faa 100644 --- a/src/experiments/settings/NSGAII_Settings.cpp +++ b/src/experiments/settings/NSGAII_Settings.cpp @@ -24,72 +24,76 @@ /** * Default constructor */ -NSGAII_Settings::NSGAII_Settings () : Settings() { +NSGAII_Settings::NSGAII_Settings () : Settings() +{ } // NSGAII_Settings /** * Destructor */ -NSGAII_Settings::~NSGAII_Settings () { - delete algorithm ; - delete crossover ; // Crossover operator - delete mutation ; // Mutation operator - delete selection ; // Selection operator +NSGAII_Settings::~NSGAII_Settings () +{ + delete algorithm ; + delete crossover ; // Crossover operator + delete mutation ; // Mutation operator + delete selection ; // Selection operator } // ~NSGAII_Settings /** * Constructor */ -NSGAII_Settings::NSGAII_Settings(string problemName) { - problemName_ = problemName ; - - problem_ = ProblemFactory::getProblem((char *) problemName_.c_str()); - - // Algorithm parameters - populationSize_ = 100; - maxEvaluations_ = 25000; - mutationProbability_ = 1.0/problem_->getNumberOfVariables() ; - crossoverProbability_ = 0.9 ; - mutationDistributionIndex_ = 20.0 ; - crossoverDistributionIndex_ = 20.0 ; +NSGAII_Settings::NSGAII_Settings(string problemName) +{ + problemName_ = problemName ; + + problem_ = ProblemFactory::getProblem((char *) problemName_.c_str()); + + // Algorithm parameters + populationSize_ = 100; + maxEvaluations_ = 25000; + mutationProbability_ = 1.0/problem_->getNumberOfVariables() ; + crossoverProbability_ = 0.9 ; + mutationDistributionIndex_ = 20.0 ; + crossoverDistributionIndex_ = 20.0 ; } // NSGAII_Settings /** * Configure method */ -Algorithm * NSGAII_Settings::configure() { +Algorithm * NSGAII_Settings::configure() +{ - algorithm = new NSGAII(problem_); - algorithm->setInputParameter("populationSize",&populationSize_); - algorithm->setInputParameter("maxEvaluations",&maxEvaluations_); + algorithm = new NSGAII(problem_); + algorithm->setInputParameter("populationSize",&populationSize_); + algorithm->setInputParameter("maxEvaluations",&maxEvaluations_); - // Mutation and Crossover for Real codification - map parameters; + // Mutation and Crossover for Real codification + map parameters; - double crossoverProbability = crossoverProbability_; - double crossoverDistributionIndex = crossoverDistributionIndex_ ; - parameters["probability"] = &crossoverProbability; - parameters["distributionIndex"] = &crossoverDistributionIndex; - crossover = new SBXCrossover(parameters); + double crossoverProbability = crossoverProbability_; + double crossoverDistributionIndex = crossoverDistributionIndex_ ; + parameters["probability"] = &crossoverProbability; + parameters["distributionIndex"] = &crossoverDistributionIndex; + crossover = new SBXCrossover(parameters); - parameters.clear(); - double mutationProbability = mutationProbability_; - double mutationDistributionIndex = mutationDistributionIndex_; - parameters["probability"] = &mutationProbability; - parameters["distributionIndex"] = &mutationDistributionIndex; - mutation = new PolynomialMutation(parameters); + parameters.clear(); + double mutationProbability = mutationProbability_; + double mutationDistributionIndex = mutationDistributionIndex_; + parameters["probability"] = &mutationProbability; + parameters["distributionIndex"] = &mutationDistributionIndex; + mutation = new PolynomialMutation(parameters); - // Selection Operator - parameters.clear(); - selection = new BinaryTournament2(parameters); + // Selection Operator + parameters.clear(); + selection = new BinaryTournament2(parameters); - // Add the operators to the algorithm - algorithm->addOperator("crossover",crossover); - algorithm->addOperator("mutation",mutation); - algorithm->addOperator("selection",selection); + // Add the operators to the algorithm + algorithm->addOperator("crossover",crossover); + algorithm->addOperator("mutation",mutation); + algorithm->addOperator("selection",selection); - cout << "NGSAII algorithm initialized." << endl; + cout << "NGSAII algorithm initialized." << endl; - return algorithm ; + return algorithm ; } // configure diff --git a/src/experiments/settings/NSGAII_Settings.h b/src/experiments/settings/NSGAII_Settings.h index 35183cd..e6d96d9 100644 --- a/src/experiments/settings/NSGAII_Settings.h +++ b/src/experiments/settings/NSGAII_Settings.h @@ -28,26 +28,27 @@ #include #include -class NSGAII_Settings : public Settings{ +class NSGAII_Settings : public Settings +{ private: - int populationSize_ ; - int maxEvaluations_ ; - double mutationProbability_ ; - double crossoverProbability_ ; - double mutationDistributionIndex_ ; - double crossoverDistributionIndex_ ; + int populationSize_ ; + int maxEvaluations_ ; + double mutationProbability_ ; + double crossoverProbability_ ; + double mutationDistributionIndex_ ; + double crossoverDistributionIndex_ ; - Algorithm * algorithm ; - Operator * crossover ; // Crossover operator - Operator * mutation ; // Mutation operator - Operator * selection ; // Selection operator + Algorithm * algorithm ; + Operator * crossover ; // Crossover operator + Operator * mutation ; // Mutation operator + Operator * selection ; // Selection operator public: - NSGAII_Settings() ; - NSGAII_Settings(string problemName) ; - ~NSGAII_Settings() ; + NSGAII_Settings() ; + NSGAII_Settings(string problemName) ; + ~NSGAII_Settings() ; - Algorithm * configure() ; + Algorithm * configure() ; }; // NSGAII_Settings #endif // __NSGAII_SETTINGS__ diff --git a/src/experiments/settings/PSO_Settings.cpp b/src/experiments/settings/PSO_Settings.cpp index 89e70c5..e6438f5 100644 --- a/src/experiments/settings/PSO_Settings.cpp +++ b/src/experiments/settings/PSO_Settings.cpp @@ -25,33 +25,36 @@ /** * Default constructor */ -PSO_Settings::PSO_Settings () : Settings() { +PSO_Settings::PSO_Settings () : Settings() +{ } // PSO_Settings /** * Destructor */ -PSO_Settings::~PSO_Settings () { - delete algorithm ; - delete mutation ; // Mutation operator +PSO_Settings::~PSO_Settings () +{ + delete algorithm ; + delete mutation ; // Mutation operator } // ~PSO_Settings /** * Constructor */ -PSO_Settings::PSO_Settings(string problemName) { +PSO_Settings::PSO_Settings(string problemName) +{ - problemName_ = problemName ; + problemName_ = problemName ; - problem_ = ProblemFactory::getProblem((char *) problemName_.c_str()); + problem_ = ProblemFactory::getProblem((char *) problemName_.c_str()); - // Default settings - swarmSize_ = 50 ; - maxIterations_ = 5000 ; - mutationDistributionIndex_ = 20.0 ; - mutationProbability_ = 1.0/problem_->getNumberOfVariables() ; + // Default settings + swarmSize_ = 50 ; + maxIterations_ = 5000 ; + mutationDistributionIndex_ = 20.0 ; + mutationProbability_ = 1.0/problem_->getNumberOfVariables() ; } // PSO_Settings @@ -59,27 +62,28 @@ PSO_Settings::PSO_Settings(string problemName) { /** * Configure method */ -Algorithm * PSO_Settings::configure() { +Algorithm * PSO_Settings::configure() +{ - algorithm = new PSO(problem_); - algorithm->setInputParameter("swarmSize", &swarmSize_); - algorithm->setInputParameter("maxIterations", &maxIterations_); + algorithm = new PSO(problem_); + algorithm->setInputParameter("swarmSize", &swarmSize_); + algorithm->setInputParameter("maxIterations", &maxIterations_); - map parameters; + map parameters; - // Mutation operator - double mutationProbability = mutationProbability_; - double mutationDistributionIndex = mutationDistributionIndex_; - parameters["probability"] = &mutationProbability; - parameters["distributionIndex"] = &mutationDistributionIndex; - mutation = new PolynomialMutation(parameters); + // Mutation operator + double mutationProbability = mutationProbability_; + double mutationDistributionIndex = mutationDistributionIndex_; + parameters["probability"] = &mutationProbability; + parameters["distributionIndex"] = &mutationDistributionIndex; + mutation = new PolynomialMutation(parameters); - // Add the operators to the algorithm - algorithm->addOperator("mutation",mutation); + // Add the operators to the algorithm + algorithm->addOperator("mutation",mutation); - cout << "PSO algorithm initialized." << endl; + cout << "PSO algorithm initialized." << endl; - return algorithm ; + return algorithm ; } // configure diff --git a/src/experiments/settings/PSO_Settings.h b/src/experiments/settings/PSO_Settings.h index ac1ac8f..5f70482 100644 --- a/src/experiments/settings/PSO_Settings.h +++ b/src/experiments/settings/PSO_Settings.h @@ -25,23 +25,24 @@ #include #include -class PSO_Settings : public Settings { +class PSO_Settings : public Settings +{ private: - int swarmSize_ ; - int maxIterations_ ; - double mutationDistributionIndex_ ; - double mutationProbability_ ; + int swarmSize_ ; + int maxIterations_ ; + double mutationDistributionIndex_ ; + double mutationProbability_ ; - Algorithm * algorithm ; - Operator * mutation ; // Mutation operator + Algorithm * algorithm ; + Operator * mutation ; // Mutation operator public: - PSO_Settings() ; - PSO_Settings(string problemName) ; - ~PSO_Settings() ; + PSO_Settings() ; + PSO_Settings(string problemName) ; + ~PSO_Settings() ; - Algorithm * configure() ; + Algorithm * configure() ; }; // PSO_Settings #endif // __PSO_SETTINGS__ diff --git a/src/experiments/settings/SMPSO_Settings.cpp b/src/experiments/settings/SMPSO_Settings.cpp index d862f05..b9f2662 100644 --- a/src/experiments/settings/SMPSO_Settings.cpp +++ b/src/experiments/settings/SMPSO_Settings.cpp @@ -25,34 +25,37 @@ /** * Default constructor */ -SMPSO_Settings::SMPSO_Settings () : Settings() { +SMPSO_Settings::SMPSO_Settings () : Settings() +{ } // SMPSO_Settings /** * Destructor */ -SMPSO_Settings::~SMPSO_Settings () { - delete algorithm ; - delete mutation ; // Mutation operator +SMPSO_Settings::~SMPSO_Settings () +{ + delete algorithm ; + delete mutation ; // Mutation operator } // ~SMPSO_Settings /** * Constructor */ -SMPSO_Settings::SMPSO_Settings(string problemName) { +SMPSO_Settings::SMPSO_Settings(string problemName) +{ - problemName_ = problemName ; + problemName_ = problemName ; - problem_ = ProblemFactory::getProblem((char *) problemName_.c_str()); + problem_ = ProblemFactory::getProblem((char *) problemName_.c_str()); - // Default settings - swarmSize_ = 100 ; - maxIterations_ = 250 ; - archiveSize_ = 100 ; - mutationDistributionIndex_ = 20.0 ; - mutationProbability_ = 1.0/problem_->getNumberOfVariables() ; + // Default settings + swarmSize_ = 100 ; + maxIterations_ = 250 ; + archiveSize_ = 100 ; + mutationDistributionIndex_ = 20.0 ; + mutationProbability_ = 1.0/problem_->getNumberOfVariables() ; } // SMPSO_Settings @@ -60,27 +63,28 @@ SMPSO_Settings::SMPSO_Settings(string problemName) { /** * Configure method */ -Algorithm * SMPSO_Settings::configure() { +Algorithm * SMPSO_Settings::configure() +{ - algorithm = new SMPSO(problem_); - algorithm->setInputParameter("swarmSize", &swarmSize_); - algorithm->setInputParameter("maxIterations", &maxIterations_); - algorithm->setInputParameter("archiveSize", &archiveSize_); + algorithm = new SMPSO(problem_); + algorithm->setInputParameter("swarmSize", &swarmSize_); + algorithm->setInputParameter("maxIterations", &maxIterations_); + algorithm->setInputParameter("archiveSize", &archiveSize_); - map parameters; + map parameters; - double mutationProbability = mutationProbability_; - double mutationDistributionIndex = mutationDistributionIndex_; - parameters["probability"] = &mutationProbability; - parameters["distributionIndex"] = &mutationDistributionIndex; - mutation = new PolynomialMutation(parameters); + double mutationProbability = mutationProbability_; + double mutationDistributionIndex = mutationDistributionIndex_; + parameters["probability"] = &mutationProbability; + parameters["distributionIndex"] = &mutationDistributionIndex; + mutation = new PolynomialMutation(parameters); - // Add the operators to the algorithm - algorithm->addOperator("mutation",mutation); + // Add the operators to the algorithm + algorithm->addOperator("mutation",mutation); - cout << "SMPSO algorithm initialized." << endl; + cout << "SMPSO algorithm initialized." << endl; - return algorithm ; + return algorithm ; } // configure diff --git a/src/experiments/settings/SMPSO_Settings.h b/src/experiments/settings/SMPSO_Settings.h index b656e0c..a803b37 100644 --- a/src/experiments/settings/SMPSO_Settings.h +++ b/src/experiments/settings/SMPSO_Settings.h @@ -25,24 +25,25 @@ #include #include -class SMPSO_Settings : public Settings{ +class SMPSO_Settings : public Settings +{ private: - int swarmSize_ ; - int maxIterations_ ; - int archiveSize_ ; - double mutationDistributionIndex_ ; - double mutationProbability_ ; + int swarmSize_ ; + int maxIterations_ ; + int archiveSize_ ; + double mutationDistributionIndex_ ; + double mutationProbability_ ; - Algorithm * algorithm ; - Operator * mutation ; // Mutation operator + Algorithm * algorithm ; + Operator * mutation ; // Mutation operator public: - SMPSO_Settings() ; - SMPSO_Settings(string problemName) ; - ~SMPSO_Settings() ; + SMPSO_Settings() ; + SMPSO_Settings(string problemName) ; + ~SMPSO_Settings() ; - Algorithm * configure() ; + Algorithm * configure() ; }; // SMPSO_Settings #endif // __SMPSO_SETTINGS__ diff --git a/src/experiments/settings/gGA_Settings.cpp b/src/experiments/settings/gGA_Settings.cpp index 4ccec2f..71d4139 100644 --- a/src/experiments/settings/gGA_Settings.cpp +++ b/src/experiments/settings/gGA_Settings.cpp @@ -23,72 +23,76 @@ /** * Default constructor */ -gGA_Settings::gGA_Settings () : Settings() { +gGA_Settings::gGA_Settings () : Settings() +{ } // gGA_Settings /** * Destructor */ -gGA_Settings::~gGA_Settings () { - delete algorithm ; - delete crossover ; // Crossover operator - delete mutation ; // Mutation operator - delete selection ; // Selection operator +gGA_Settings::~gGA_Settings () +{ + delete algorithm ; + delete crossover ; // Crossover operator + delete mutation ; // Mutation operator + delete selection ; // Selection operator } // ~gGA_Settings /** * Constructor */ -gGA_Settings::gGA_Settings(string problemName) { - problemName_ = problemName ; - - problem_ = ProblemFactory::getProblem((char *) problemName_.c_str()); - - // Algorithm parameters - populationSize_ = 100; - maxEvaluations_ = 25000; - mutationProbability_ = 1.0/problem_->getNumberOfVariables() ; - crossoverProbability_ = 0.9 ; - mutationDistributionIndex_ = 20.0 ; - crossoverDistributionIndex_ = 20.0 ; +gGA_Settings::gGA_Settings(string problemName) +{ + problemName_ = problemName ; + + problem_ = ProblemFactory::getProblem((char *) problemName_.c_str()); + + // Algorithm parameters + populationSize_ = 100; + maxEvaluations_ = 25000; + mutationProbability_ = 1.0/problem_->getNumberOfVariables() ; + crossoverProbability_ = 0.9 ; + mutationDistributionIndex_ = 20.0 ; + crossoverDistributionIndex_ = 20.0 ; } // gGA_Settings /** * Configure method */ -Algorithm * gGA_Settings::configure() { +Algorithm * gGA_Settings::configure() +{ - algorithm = new gGA(problem_); - algorithm->setInputParameter("populationSize",&populationSize_); - algorithm->setInputParameter("maxEvaluations",&maxEvaluations_); + algorithm = new gGA(problem_); + algorithm->setInputParameter("populationSize",&populationSize_); + algorithm->setInputParameter("maxEvaluations",&maxEvaluations_); - // Mutation and Crossover for Real codification - map parameters; + // Mutation and Crossover for Real codification + map parameters; - double crossoverProbability = crossoverProbability_; - double crossoverDistributionIndex = crossoverDistributionIndex_ ; - parameters["probability"] = &crossoverProbability; - parameters["distributionIndex"] = &crossoverDistributionIndex; - crossover = new SBXCrossover(parameters); + double crossoverProbability = crossoverProbability_; + double crossoverDistributionIndex = crossoverDistributionIndex_ ; + parameters["probability"] = &crossoverProbability; + parameters["distributionIndex"] = &crossoverDistributionIndex; + crossover = new SBXCrossover(parameters); - parameters.clear(); - double mutationProbability = mutationProbability_; - double mutationDistributionIndex = mutationDistributionIndex_; - parameters["probability"] = &mutationProbability; - parameters["distributionIndex"] = &mutationDistributionIndex; - mutation = new PolynomialMutation(parameters); + parameters.clear(); + double mutationProbability = mutationProbability_; + double mutationDistributionIndex = mutationDistributionIndex_; + parameters["probability"] = &mutationProbability; + parameters["distributionIndex"] = &mutationDistributionIndex; + mutation = new PolynomialMutation(parameters); - // Selection Operator - parameters.clear(); - selection = new BinaryTournament2(parameters); + // Selection Operator + parameters.clear(); + selection = new BinaryTournament2(parameters); - // Add the operators to the algorithm - algorithm->addOperator("crossover",crossover); - algorithm->addOperator("mutation",mutation); - algorithm->addOperator("selection",selection); + // Add the operators to the algorithm + algorithm->addOperator("crossover",crossover); + algorithm->addOperator("mutation",mutation); + algorithm->addOperator("selection",selection); - cout << "gGA algorithm initialized." << endl; + cout << "gGA algorithm initialized." << endl; - return algorithm ; + return algorithm ; } // configure diff --git a/src/experiments/settings/gGA_Settings.h b/src/experiments/settings/gGA_Settings.h index 76c16cf..5ba385f 100644 --- a/src/experiments/settings/gGA_Settings.h +++ b/src/experiments/settings/gGA_Settings.h @@ -27,26 +27,27 @@ #include #include -class gGA_Settings : public Settings { +class gGA_Settings : public Settings +{ private: - int populationSize_ ; - int maxEvaluations_ ; - double mutationProbability_ ; - double crossoverProbability_ ; - double mutationDistributionIndex_ ; - double crossoverDistributionIndex_ ; + int populationSize_ ; + int maxEvaluations_ ; + double mutationProbability_ ; + double crossoverProbability_ ; + double mutationDistributionIndex_ ; + double crossoverDistributionIndex_ ; - Algorithm * algorithm ; - Operator * crossover ; // Crossover operator - Operator * mutation ; // Mutation operator - Operator * selection ; // Selection operator + Algorithm * algorithm ; + Operator * crossover ; // Crossover operator + Operator * mutation ; // Mutation operator + Operator * selection ; // Selection operator public: - gGA_Settings() ; - gGA_Settings(string problemName) ; - ~gGA_Settings() ; + gGA_Settings() ; + gGA_Settings(string problemName) ; + ~gGA_Settings() ; - Algorithm * configure() ; + Algorithm * configure() ; }; // gGA_Settings #endif // __GGA_SETTINGS__ diff --git a/src/experiments/settings/ssGA_Settings.cpp b/src/experiments/settings/ssGA_Settings.cpp index ed1117f..8956718 100644 --- a/src/experiments/settings/ssGA_Settings.cpp +++ b/src/experiments/settings/ssGA_Settings.cpp @@ -23,72 +23,76 @@ /** * Default constructor */ -ssGA_Settings::ssGA_Settings () : Settings() { +ssGA_Settings::ssGA_Settings () : Settings() +{ } // ssGA_Settings /** * Destructor */ -ssGA_Settings::~ssGA_Settings () { - delete algorithm ; - delete crossover ; // Crossover operator - delete mutation ; // Mutation operator - delete selection ; // Selection operator +ssGA_Settings::~ssGA_Settings () +{ + delete algorithm ; + delete crossover ; // Crossover operator + delete mutation ; // Mutation operator + delete selection ; // Selection operator } // ~ssGA_Settings /** * Constructor */ -ssGA_Settings::ssGA_Settings(string problemName) { - problemName_ = problemName ; - - problem_ = ProblemFactory::getProblem((char *) problemName_.c_str()); - - // Algorithm parameters - populationSize_ = 100; - maxEvaluations_ = 25000; - mutationProbability_ = 1.0/problem_->getNumberOfVariables() ; - crossoverProbability_ = 0.9 ; - mutationDistributionIndex_ = 20.0 ; - crossoverDistributionIndex_ = 20.0 ; +ssGA_Settings::ssGA_Settings(string problemName) +{ + problemName_ = problemName ; + + problem_ = ProblemFactory::getProblem((char *) problemName_.c_str()); + + // Algorithm parameters + populationSize_ = 100; + maxEvaluations_ = 25000; + mutationProbability_ = 1.0/problem_->getNumberOfVariables() ; + crossoverProbability_ = 0.9 ; + mutationDistributionIndex_ = 20.0 ; + crossoverDistributionIndex_ = 20.0 ; } // ssGA_Settings /** * Configure method */ -Algorithm * ssGA_Settings::configure() { +Algorithm * ssGA_Settings::configure() +{ - algorithm = new ssGA(problem_); - algorithm->setInputParameter("populationSize",&populationSize_); - algorithm->setInputParameter("maxEvaluations",&maxEvaluations_); + algorithm = new ssGA(problem_); + algorithm->setInputParameter("populationSize",&populationSize_); + algorithm->setInputParameter("maxEvaluations",&maxEvaluations_); - // Mutation and Crossover for Real codification - map parameters; + // Mutation and Crossover for Real codification + map parameters; - double crossoverProbability = crossoverProbability_; - double crossoverDistributionIndex = crossoverDistributionIndex_ ; - parameters["probability"] = &crossoverProbability; - parameters["distributionIndex"] = &crossoverDistributionIndex; - crossover = new SBXCrossover(parameters); + double crossoverProbability = crossoverProbability_; + double crossoverDistributionIndex = crossoverDistributionIndex_ ; + parameters["probability"] = &crossoverProbability; + parameters["distributionIndex"] = &crossoverDistributionIndex; + crossover = new SBXCrossover(parameters); - parameters.clear(); - double mutationProbability = mutationProbability_; - double mutationDistributionIndex = mutationDistributionIndex_; - parameters["probability"] = &mutationProbability; - parameters["distributionIndex"] = &mutationDistributionIndex; - mutation = new PolynomialMutation(parameters); + parameters.clear(); + double mutationProbability = mutationProbability_; + double mutationDistributionIndex = mutationDistributionIndex_; + parameters["probability"] = &mutationProbability; + parameters["distributionIndex"] = &mutationDistributionIndex; + mutation = new PolynomialMutation(parameters); - // Selection Operator - parameters.clear(); - selection = new BinaryTournament(parameters); + // Selection Operator + parameters.clear(); + selection = new BinaryTournament(parameters); - // Add the operators to the algorithm - algorithm->addOperator("crossover",crossover); - algorithm->addOperator("mutation",mutation); - algorithm->addOperator("selection",selection); + // Add the operators to the algorithm + algorithm->addOperator("crossover",crossover); + algorithm->addOperator("mutation",mutation); + algorithm->addOperator("selection",selection); - cout << "ssGA algorithm initialized." << endl; + cout << "ssGA algorithm initialized." << endl; - return algorithm ; + return algorithm ; } // configure diff --git a/src/experiments/settings/ssGA_Settings.h b/src/experiments/settings/ssGA_Settings.h index 1a1c3a7..ff2cc4a 100644 --- a/src/experiments/settings/ssGA_Settings.h +++ b/src/experiments/settings/ssGA_Settings.h @@ -27,26 +27,27 @@ #include #include -class ssGA_Settings : public Settings { +class ssGA_Settings : public Settings +{ private: - int populationSize_ ; - int maxEvaluations_ ; - double mutationProbability_ ; - double crossoverProbability_ ; - double mutationDistributionIndex_ ; - double crossoverDistributionIndex_ ; + int populationSize_ ; + int maxEvaluations_ ; + double mutationProbability_ ; + double crossoverProbability_ ; + double mutationDistributionIndex_ ; + double crossoverDistributionIndex_ ; - Algorithm * algorithm ; - Operator * crossover ; // Crossover operator - Operator * mutation ; // Mutation operator - Operator * selection ; // Selection operator + Algorithm * algorithm ; + Operator * crossover ; // Crossover operator + Operator * mutation ; // Mutation operator + Operator * selection ; // Selection operator public: - ssGA_Settings() ; - ssGA_Settings(string problemName) ; - ~ssGA_Settings() ; + ssGA_Settings() ; + ssGA_Settings(string problemName) ; + ~ssGA_Settings() ; - Algorithm * configure() ; + Algorithm * configure() ; }; // ssGA_Settings #endif // __SSGA_SETTINGS__ diff --git a/src/experiments/util/FileUtils.cpp b/src/experiments/util/FileUtils.cpp index 3a6ebd3..fa44032 100644 --- a/src/experiments/util/FileUtils.cpp +++ b/src/experiments/util/FileUtils.cpp @@ -30,44 +30,56 @@ * 1: path is a folder * 2: path is a file */ -int FileUtils::existsPath(const char* path) { - int res = -1; - struct stat statbuf; - if (stat(path, &statbuf) != -1) { - if (S_ISDIR(statbuf.st_mode)) { - return 1; - } else { - return 2; +int FileUtils::existsPath(const char* path) +{ + int res = -1; + struct stat statbuf; + if (stat(path, &statbuf) != -1) + { + /* + if (S_ISDIR(statbuf.st_mode)) + { + return 1; + } + else + { + return 2; + } + */ } - } else { - return 0; - } - return res; + else + { + return 0; + } + return res; } // existsPath /** * Creates a directory in the specified path */ -int FileUtils::createDirectory(string path) { - int res; - cout << "Creating directory: " << path << endl; +int FileUtils::createDirectory(string path) +{ + int res; + cout << "Creating directory: " << path << endl; + + if (path.size() > 512) + res = 1; + else + { + for (int i = 0; i < path.size(); i++) + if (path[i] == '/' || i == path.size()-1) + { + string path2 = path.substr(0, i+1); - if (path.size() > 512) - res = 1; - else { - for (int i = 0; i <= path.size(); i++) - if (path[i] == '/' || i == path.size()-1) { - string path2 = path.substr(0, i+1); +#ifdef WINDOWS + //res = mkdir(path2.c_str()); +#else + res = mkdir(path2.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); +#endif - #ifdef WINDOWS - res = mkdir(path2.c_str()); - #else - res = mkdir(path2.c_str() , S_IRWXU | S_IRWXG | S_IRWXO); - #endif + } + } - } - } - - return res; + return res; } // createDirectory diff --git a/src/experiments/util/FileUtils.h b/src/experiments/util/FileUtils.h index 3977fe8..270c7f8 100644 --- a/src/experiments/util/FileUtils.h +++ b/src/experiments/util/FileUtils.h @@ -19,9 +19,9 @@ // along with this program. If not, see . #ifdef WIN32 - #define WINDOWS +#define WINDOWS #elif WIN64 - #define WINDOWS +#define WINDOWS #endif #ifndef __FILEUTILS__ @@ -32,17 +32,18 @@ #include #ifdef WINDOWS - #include +//#include #endif using namespace std; -class FileUtils { +class FileUtils +{ public: - static int existsPath(const char* path); - static int createDirectory(string path); + static int existsPath(const char* path); + static int createDirectory(string path); }; //FileUtils diff --git a/src/experiments/util/RBoxplot.cpp b/src/experiments/util/RBoxplot.cpp index 689d8f0..ed1c8e5 100644 --- a/src/experiments/util/RBoxplot.cpp +++ b/src/experiments/util/RBoxplot.cpp @@ -22,73 +22,83 @@ #include void RBoxplot::generateScripts(int rows, int cols, vector problems, string prefix, - bool notch, ExperimentReport * experiment) { - - // STEP 1. Creating R output directory - - string rDirectory = "R"; - rDirectory = experiment->experimentBaseDirectory_ + "/" + rDirectory; - cout << "R : " << rDirectory << endl; - if (FileUtils::existsPath(rDirectory.c_str()) == 0) { - FileUtils::createDirectory(rDirectory); - cout << "Creating " << rDirectory << " directory" << endl; - } - - for (int indicator = 0; indicator < experiment->indicatorList_.size(); indicator++) { - cout << "Indicator: " << experiment->indicatorList_[indicator] << endl; - string rFile = rDirectory + "/" + prefix + "." + experiment->indicatorList_[indicator] + ".Boxplot.R"; - - std::ofstream out(rFile.c_str()); - out << "postscript(\"" << prefix << "." << experiment->indicatorList_[indicator] << - ".Boxplot.eps\", horizontal=FALSE, onefile=FALSE, height=8, width=12, pointsize=10)" << - endl; - //out << "resultDirectory<-\"../data/" << experimentName_ << "\"" << endl; - out << "resultDirectory<-\"../data/" << "\"" << endl; - out << "qIndicator <- function(indicator, problem)" << endl; - out << "{" << endl; - - for (int i = 0; i < experiment->algorithmNameList_.size(); i++) { - out << "file" << experiment->algorithmNameList_[i] << "<-paste(resultDirectory, \"" << - experiment->algorithmNameList_[i] << "\", sep=\"/\")" << endl; - out << "file" << experiment->algorithmNameList_[i] << "<-paste(file" << - experiment->algorithmNameList_[i] << ", " << "problem, sep=\"/\")" << endl; - out << "file" << experiment->algorithmNameList_[i] << "<-paste(file" << - experiment->algorithmNameList_[i] << ", " << "indicator, sep=\"/\")" << endl; - out << experiment->algorithmNameList_[i] << "<-scan(" << "file" << - experiment->algorithmNameList_[i] << ")" << endl; - out << endl; - } // for - - out << "algs<-c("; - for (int i = 0; i < experiment->algorithmNameList_.size() - 1; i++) { - out << "\"" << experiment->algorithmNameList_[i] << "\","; - } // for - out << "\"" << experiment->algorithmNameList_[ experiment->algorithmNameList_.size() - 1] << - "\")" << endl; - - out << "boxplot("; - for (int i = 0; i < experiment->algorithmNameList_.size(); i++) { - out << experiment->algorithmNameList_[i] << ","; - } // for - if (notch) { - out << "names=algs, notch = TRUE)" << endl; - } else { - out << "names=algs, notch = FALSE)" << endl; + bool notch, ExperimentReport * experiment) +{ + + // STEP 1. Creating R output directory + + string rDirectory = "R"; + rDirectory = experiment->experimentBaseDirectory_ + "/" + rDirectory; + cout << "R : " << rDirectory << endl; + if (FileUtils::existsPath(rDirectory.c_str()) == 0) + { + FileUtils::createDirectory(rDirectory); + cout << "Creating " << rDirectory << " directory" << endl; } - out << "titulo <-paste(indicator, problem, sep=\":\")" << endl; - out << "title(main=titulo)" << endl; - - out << "}" << endl; - out << "par(mfrow=c(" << rows << "," << cols << "))" << endl; - - out << "indicator<-\"" << experiment->indicatorList_[indicator] << "\"" << endl; - - for (int i = 0; i < problems.size(); i++) { - out << "qIndicator(indicator, \"" << problems[i] << "\")" << endl; - } - - out.close(); - } // for + for (int indicator = 0; indicator < experiment->indicatorList_.size(); indicator++) + { + cout << "Indicator: " << experiment->indicatorList_[indicator] << endl; + string rFile = rDirectory + "/" + prefix + "." + experiment->indicatorList_[indicator] + ".Boxplot.R"; + + std::ofstream out(rFile.c_str()); + out << "postscript(\"" << prefix << "." << experiment->indicatorList_[indicator] << + ".Boxplot.eps\", horizontal=FALSE, onefile=FALSE, height=8, width=12, pointsize=10)" << + endl; + //out << "resultDirectory<-\"../data/" << experimentName_ << "\"" << endl; + out << "resultDirectory<-\"../data/" << "\"" << endl; + out << "qIndicator <- function(indicator, problem)" << endl; + out << "{" << endl; + + for (int i = 0; i < experiment->algorithmNameList_.size(); i++) + { + out << "file" << experiment->algorithmNameList_[i] << "<-paste(resultDirectory, \"" << + experiment->algorithmNameList_[i] << "\", sep=\"/\")" << endl; + out << "file" << experiment->algorithmNameList_[i] << "<-paste(file" << + experiment->algorithmNameList_[i] << ", " << "problem, sep=\"/\")" << endl; + out << "file" << experiment->algorithmNameList_[i] << "<-paste(file" << + experiment->algorithmNameList_[i] << ", " << "indicator, sep=\"/\")" << endl; + out << experiment->algorithmNameList_[i] << "<-scan(" << "file" << + experiment->algorithmNameList_[i] << ")" << endl; + out << endl; + } // for + + out << "algs<-c("; + for (int i = 0; i < experiment->algorithmNameList_.size() - 1; i++) + { + out << "\"" << experiment->algorithmNameList_[i] << "\","; + } // for + out << "\"" << experiment->algorithmNameList_[ experiment->algorithmNameList_.size() - 1] << + "\")" << endl; + + out << "boxplot("; + for (int i = 0; i < experiment->algorithmNameList_.size(); i++) + { + out << experiment->algorithmNameList_[i] << ","; + } // for + if (notch) + { + out << "names=algs, notch = TRUE)" << endl; + } + else + { + out << "names=algs, notch = FALSE)" << endl; + } + out << "titulo <-paste(indicator, problem, sep=\":\")" << endl; + out << "title(main=titulo)" << endl; + + out << "}" << endl; + + out << "par(mfrow=c(" << rows << "," << cols << "))" << endl; + + out << "indicator<-\"" << experiment->indicatorList_[indicator] << "\"" << endl; + + for (int i = 0; i < problems.size(); i++) + { + out << "qIndicator(indicator, \"" << problems[i] << "\")" << endl; + } + + out.close(); + } // for } // generateScripts diff --git a/src/experiments/util/RBoxplot.h b/src/experiments/util/RBoxplot.h index e0c6fc2..9aa1e0b 100644 --- a/src/experiments/util/RBoxplot.h +++ b/src/experiments/util/RBoxplot.h @@ -31,10 +31,11 @@ class ExperimentReport; * Class for generating results in form of boxplots */ -class RBoxplot { +class RBoxplot +{ public: - static void generateScripts(int rows, int cols, vector problems, - string prefix, bool notch, ExperimentReport * experiment); + static void generateScripts(int rows, int cols, vector problems, + string prefix, bool notch, ExperimentReport * experiment); }; #endif /* __RBOXPLOT__ */ diff --git a/src/experiments/util/RWilcoxon.cpp b/src/experiments/util/RWilcoxon.cpp index 602b770..3ad707f 100644 --- a/src/experiments/util/RWilcoxon.cpp +++ b/src/experiments/util/RWilcoxon.cpp @@ -22,300 +22,312 @@ #include -void RWilcoxon::generateScripts(vector problems, string prefix, ExperimentReport * experiment) { +void RWilcoxon::generateScripts(vector problems, string prefix, ExperimentReport * experiment) +{ - // STEP 1. Creating R output directory + // STEP 1. Creating R output directory - string rDirectory = "R"; - rDirectory = experiment->experimentBaseDirectory_ + "/" + rDirectory; - cout << "R : " << rDirectory << endl; - if (FileUtils::existsPath(rDirectory.c_str()) == 0) { - FileUtils::createDirectory(rDirectory); - cout << "Creating " << rDirectory << " directory" << endl; - } + string rDirectory = "R"; + rDirectory = experiment->experimentBaseDirectory_ + "/" + rDirectory; + cout << "R : " << rDirectory << endl; + if (FileUtils::existsPath(rDirectory.c_str()) == 0) + { + FileUtils::createDirectory(rDirectory); + cout << "Creating " << rDirectory << " directory" << endl; + } - for (int indicator = 0; indicator < experiment->indicatorList_.size(); indicator++) { - cout << "Indicator: " << experiment->indicatorList_[indicator] << endl; - string rFile = rDirectory + "/" + prefix + "." + experiment->indicatorList_[indicator] + ".Wilcox.R"; - string texFile = rDirectory + "/" + prefix + "." + experiment->indicatorList_[indicator] + ".Wilcox.tex"; + for (int indicator = 0; indicator < experiment->indicatorList_.size(); indicator++) + { + cout << "Indicator: " << experiment->indicatorList_[indicator] << endl; + string rFile = rDirectory + "/" + prefix + "." + experiment->indicatorList_[indicator] + ".Wilcox.R"; + string texFile = rDirectory + "/" + prefix + "." + experiment->indicatorList_[indicator] + ".Wilcox.tex"; - std::ofstream out(rFile.c_str()); - string output = "write(\"\", \"" + texFile + "\",append=FALSE)"; - out << output << endl; + std::ofstream out(rFile.c_str()); + string output = "write(\"\", \"" + texFile + "\",append=FALSE)"; + out << output << endl; - // Generate function latexHeader() - string dataDirectory = experiment->experimentBaseDirectory_ + "/data"; - out << "resultDirectory<-\"" << dataDirectory << "\"" << endl; - out << "latexHeader <- function() {" << endl; - out << " write(\"\\\\documentclass{article}\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\title{StandardStudy}\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\usepackage{amssymb}\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\author{A.J.Nebro}\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\begin{document}\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\maketitle\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\section{Tables}\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\\", \"" + texFile + "\", append=TRUE)\n}" << endl; - //out << output << endl; + // Generate function latexHeader() + string dataDirectory = experiment->experimentBaseDirectory_ + "/data"; + out << "resultDirectory<-\"" << dataDirectory << "\"" << endl; + out << "latexHeader <- function() {" << endl; + out << " write(\"\\\\documentclass{article}\", \"" + texFile + "\", append=TRUE)" << endl; + out << " write(\"\\\\title{StandardStudy}\", \"" + texFile + "\", append=TRUE)" << endl; + out << " write(\"\\\\usepackage{amssymb}\", \"" + texFile + "\", append=TRUE)" << endl; + out << " write(\"\\\\author{A.J.Nebro}\", \"" + texFile + "\", append=TRUE)" << endl; + out << " write(\"\\\\begin{document}\", \"" + texFile + "\", append=TRUE)" << endl; + out << " write(\"\\\\maketitle\", \"" + texFile + "\", append=TRUE)" << endl; + out << " write(\"\\\\section{Tables}\", \"" + texFile + "\", append=TRUE)" << endl; + out << " write(\"\\\\\", \"" + texFile + "\", append=TRUE)\n}" << endl; + //out << output << endl; - // Write function latexTableHeader - string latexTableLabel = ""; - string latexTabularAlignment = ""; - string latexTableFirstLine = ""; - string latexTableCaption = ""; + // Write function latexTableHeader + string latexTableLabel = ""; + string latexTabularAlignment = ""; + string latexTableFirstLine = ""; + string latexTableCaption = ""; - latexTableCaption = " write(\"\\\\caption{\", \"" + texFile + "\", append=TRUE)" + "\n" + - " write(problem, \"" + texFile + "\", append=TRUE)" + "\n" + - " write(\"." + experiment->indicatorList_[indicator] + ".}\", \"" + texFile + "\", append=TRUE)" + "\n"; - latexTableLabel = " write(\"\\\\label{Table:\", \"" + texFile + "\", append=TRUE)" + "\n" + - " write(problem, \"" + texFile + "\", append=TRUE)" + "\n" + - " write(\"." + experiment->indicatorList_[indicator] + ".}\", \"" + texFile + "\", append=TRUE)" + "\n"; - latexTabularAlignment = "l"; - latexTableFirstLine = "\\\\hline "; + latexTableCaption = " write(\"\\\\caption{\", \"" + texFile + "\", append=TRUE)" + "\n" + + " write(problem, \"" + texFile + "\", append=TRUE)" + "\n" + + " write(\"." + experiment->indicatorList_[indicator] + ".}\", \"" + texFile + "\", append=TRUE)" + "\n"; + latexTableLabel = " write(\"\\\\label{Table:\", \"" + texFile + "\", append=TRUE)" + "\n" + + " write(problem, \"" + texFile + "\", append=TRUE)" + "\n" + + " write(\"." + experiment->indicatorList_[indicator] + ".}\", \"" + texFile + "\", append=TRUE)" + "\n"; + latexTabularAlignment = "l"; + latexTableFirstLine = "\\\\hline "; - for (int i = 1; i < experiment->algorithmNameList_.size(); i++) { - latexTabularAlignment += "c"; - latexTableFirstLine += " & " + experiment->algorithmNameList_[i]; - } // for - //latexTableFirstLine += "\\\\\\\\\",\"" + texFile + "\", append=TRUE)" + "\n"; - latexTableFirstLine += "\\\\\\\\ \""; + for (int i = 1; i < experiment->algorithmNameList_.size(); i++) + { + latexTabularAlignment += "c"; + latexTableFirstLine += " & " + experiment->algorithmNameList_[i]; + } // for + //latexTableFirstLine += "\\\\\\\\\",\"" + texFile + "\", append=TRUE)" + "\n"; + latexTableFirstLine += "\\\\\\\\ \""; - // Generate function latexTableHeader() - out << "latexTableHeader <- function(problem, tabularString, latexTableFirstLine) {" << endl; - out << " write(\"\\\\begin{table}\", \"" + texFile + "\", append=TRUE)" << endl; - out << latexTableCaption << endl; - out << latexTableLabel << endl; - out << " write(\"\\\\centering\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\begin{scriptsize}\", \"" + texFile + "\", append=TRUE)" << endl; - //out << " write(\"\\\\begin{tabular}{" + latexTabularAlignment + "}\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\begin{tabular}{\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(tabularString, \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"}\", \"" + texFile + "\", append=TRUE)" << endl; - //out << latexTableFirstLine + - out << " write(latexTableFirstLine, \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\hline \", \"" + texFile + "\", append=TRUE)" + "\n" + "}" << endl; - //out << output << endl; + // Generate function latexTableHeader() + out << "latexTableHeader <- function(problem, tabularString, latexTableFirstLine) {" << endl; + out << " write(\"\\\\begin{table}\", \"" + texFile + "\", append=TRUE)" << endl; + out << latexTableCaption << endl; + out << latexTableLabel << endl; + out << " write(\"\\\\centering\", \"" + texFile + "\", append=TRUE)" << endl; + out << " write(\"\\\\begin{scriptsize}\", \"" + texFile + "\", append=TRUE)" << endl; + //out << " write(\"\\\\begin{tabular}{" + latexTabularAlignment + "}\", \"" + texFile + "\", append=TRUE)" << endl; + out << " write(\"\\\\begin{tabular}{\", \"" + texFile + "\", append=TRUE)" << endl; + out << " write(tabularString, \"" + texFile + "\", append=TRUE)" << endl; + out << " write(\"}\", \"" + texFile + "\", append=TRUE)" << endl; + //out << latexTableFirstLine + + out << " write(latexTableFirstLine, \"" + texFile + "\", append=TRUE)" << endl; + out << " write(\"\\\\hline \", \"" + texFile + "\", append=TRUE)" + "\n" + "}" << endl; + //out << output << endl; - // Generate function latexTableTail() - out << "latexTableTail <- function() { " << endl; - out << " write(\"\\\\hline\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\end{tabular}\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\end{scriptsize}\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\end{table}\", \"" + texFile + "\", append=TRUE)" + "\n" + "}" << endl; - //out << output << endl; + // Generate function latexTableTail() + out << "latexTableTail <- function() { " << endl; + out << " write(\"\\\\hline\", \"" + texFile + "\", append=TRUE)" << endl; + out << " write(\"\\\\end{tabular}\", \"" + texFile + "\", append=TRUE)" << endl; + out << " write(\"\\\\end{scriptsize}\", \"" + texFile + "\", append=TRUE)" << endl; + out << " write(\"\\\\end{table}\", \"" + texFile + "\", append=TRUE)" + "\n" + "}" << endl; + //out << output << endl; - // Generate function latexTail() - out << "latexTail <- function() { " << endl; - out << " write(\"\\\\end{document}\", \"" + texFile + "\", append=TRUE)" + "\n" + "}" << endl; - //out << output << endl; + // Generate function latexTail() + out << "latexTail <- function() { " << endl; + out << " write(\"\\\\end{document}\", \"" + texFile + "\", append=TRUE)" + "\n" + "}" << endl; + //out << output << endl; - if ((bool) experiment->indicatorMinimize_[experiment->indicatorList_[indicator]] == true) {// minimize by default - // Generate function printTableLine() - out << "printTableLine <- function(indicator, algorithm1, algorithm2, i, j, problem) { " << endl; - out << " file1<-paste(resultDirectory, algorithm1, sep=\"/\")" << endl; - out << " file1<-paste(file1, problem, sep=\"/\")" << endl; - out << " file1<-paste(file1, indicator, sep=\"/\")" << endl; - out << " data1<-scan(file1)" << endl; - out << " file2<-paste(resultDirectory, algorithm2, sep=\"/\")" << endl; - out << " file2<-paste(file2, problem, sep=\"/\")" << endl; - out << " file2<-paste(file2, indicator, sep=\"/\")" << endl; - out << " data2<-scan(file2)" << endl; - out << " if (i == j) {" << endl; - out << " write(\"-- \", \"" + texFile + "\", append=TRUE)" << endl; - out << " }" << endl; - out << " else if (i < j) {" << endl; - out << " if (wilcox.test(data1, data2)$p.value <= 0.05) {" << endl; - out << " if (median(data1) <= median(data2)) {" << endl; - out << " write(\"$\\\\blacktriangle$\", \"" + texFile + "\", append=TRUE)" << endl; - out << " }" << endl; - out << " else {" << endl; - out << " write(\"$\\\\triangledown$\", \"" + texFile + "\", append=TRUE) " << endl; - out << " }" << endl; - out << " }" << endl; - out << " else {" << endl; - out << " write(\"--\", \"" + texFile + "\", append=TRUE) " << endl; - out << " }" << endl; - out << " }" << endl; - out << " else {" << endl; - out << " write(\" \", \"" + texFile + "\", append=TRUE)" << endl; - out << " }" << endl; - out << "}" << endl; - } // if - else { - // Generate function printTableLine() - out << "printTableLine <- function(indicator, algorithm1, algorithm2, i, j, problem) { " << endl; - out << " file1<-paste(resultDirectory, algorithm1, sep=\"/\")" << endl; - out << " file1<-paste(file1, problem, sep=\"/\")" << endl; - out << " file1<-paste(file1, indicator, sep=\"/\")" << endl; - out << " data1<-scan(file1)" << endl; - out << " file2<-paste(resultDirectory, algorithm2, sep=\"/\")" << endl; - out << " file2<-paste(file2, problem, sep=\"/\")" << endl; - out << " file2<-paste(file2, indicator, sep=\"/\")" << endl; - out << " data2<-scan(file2)" << endl; - out << " if (i == j) {" << endl; - out << " write(\"--\", \"" + texFile + "\", append=TRUE)" << endl; - out << " }" << endl; - out << " else if (i < j) {" << endl; - out << " if (wilcox.test(data1, data2)$p.value <= 0.05) {" << endl; - out << " if (median(data1) >= median(data2)) {" << endl; - out << " write(\"$\\\\blacktriangle$\", \"" + texFile + "\", append=TRUE)" << endl; - out << " }" << endl; - out << " else {" << endl; - out << " write(\"$\\\\triangledown$\", \"" + texFile + "\", append=TRUE) " << endl; - out << " }" << endl; - out << " }" << endl; - out << " else {" << endl; - out << " write(\"--\", \"" + texFile + "\", append=TRUE) " << endl; - out << " }" << endl; - out << " }" << endl; - out << " else {" << endl; - out << " write(\" \", \"" + texFile + "\", append=TRUE)" << endl; - out << " }" << endl; - out << "}" << endl; - } - //out << output << endl; + if ((bool) experiment->indicatorMinimize_[experiment->indicatorList_[indicator]] == true) // minimize by default + { + // Generate function printTableLine() + out << "printTableLine <- function(indicator, algorithm1, algorithm2, i, j, problem) { " << endl; + out << " file1<-paste(resultDirectory, algorithm1, sep=\"/\")" << endl; + out << " file1<-paste(file1, problem, sep=\"/\")" << endl; + out << " file1<-paste(file1, indicator, sep=\"/\")" << endl; + out << " data1<-scan(file1)" << endl; + out << " file2<-paste(resultDirectory, algorithm2, sep=\"/\")" << endl; + out << " file2<-paste(file2, problem, sep=\"/\")" << endl; + out << " file2<-paste(file2, indicator, sep=\"/\")" << endl; + out << " data2<-scan(file2)" << endl; + out << " if (i == j) {" << endl; + out << " write(\"-- \", \"" + texFile + "\", append=TRUE)" << endl; + out << " }" << endl; + out << " else if (i < j) {" << endl; + out << " if (wilcox.test(data1, data2)$p.value <= 0.05) {" << endl; + out << " if (median(data1) <= median(data2)) {" << endl; + out << " write(\"$\\\\blacktriangle$\", \"" + texFile + "\", append=TRUE)" << endl; + out << " }" << endl; + out << " else {" << endl; + out << " write(\"$\\\\triangledown$\", \"" + texFile + "\", append=TRUE) " << endl; + out << " }" << endl; + out << " }" << endl; + out << " else {" << endl; + out << " write(\"--\", \"" + texFile + "\", append=TRUE) " << endl; + out << " }" << endl; + out << " }" << endl; + out << " else {" << endl; + out << " write(\" \", \"" + texFile + "\", append=TRUE)" << endl; + out << " }" << endl; + out << "}" << endl; + } // if + else + { + // Generate function printTableLine() + out << "printTableLine <- function(indicator, algorithm1, algorithm2, i, j, problem) { " << endl; + out << " file1<-paste(resultDirectory, algorithm1, sep=\"/\")" << endl; + out << " file1<-paste(file1, problem, sep=\"/\")" << endl; + out << " file1<-paste(file1, indicator, sep=\"/\")" << endl; + out << " data1<-scan(file1)" << endl; + out << " file2<-paste(resultDirectory, algorithm2, sep=\"/\")" << endl; + out << " file2<-paste(file2, problem, sep=\"/\")" << endl; + out << " file2<-paste(file2, indicator, sep=\"/\")" << endl; + out << " data2<-scan(file2)" << endl; + out << " if (i == j) {" << endl; + out << " write(\"--\", \"" + texFile + "\", append=TRUE)" << endl; + out << " }" << endl; + out << " else if (i < j) {" << endl; + out << " if (wilcox.test(data1, data2)$p.value <= 0.05) {" << endl; + out << " if (median(data1) >= median(data2)) {" << endl; + out << " write(\"$\\\\blacktriangle$\", \"" + texFile + "\", append=TRUE)" << endl; + out << " }" << endl; + out << " else {" << endl; + out << " write(\"$\\\\triangledown$\", \"" + texFile + "\", append=TRUE) " << endl; + out << " }" << endl; + out << " }" << endl; + out << " else {" << endl; + out << " write(\"--\", \"" + texFile + "\", append=TRUE) " << endl; + out << " }" << endl; + out << " }" << endl; + out << " else {" << endl; + out << " write(\" \", \"" + texFile + "\", append=TRUE)" << endl; + out << " }" << endl; + out << "}" << endl; + } + //out << output << endl; - // Start of the R script - output = "### START OF SCRIPT "; - out << output << endl; + // Start of the R script + output = "### START OF SCRIPT "; + out << output << endl; - string problemList = "problemList <-c("; - string algorithmList = "algorithmList <-c("; + string problemList = "problemList <-c("; + string algorithmList = "algorithmList <-c("; - for (int i = 0; i < (problems.size() - 1); i++) { - problemList += "\"" + problems[i] + "\", "; - } - problemList += "\"" + problems[problems.size() - 1] + "\") "; + for (int i = 0; i < (problems.size() - 1); i++) + { + problemList += "\"" + problems[i] + "\", "; + } + problemList += "\"" + problems[problems.size() - 1] + "\") "; - for (int i = 0; i < (experiment->algorithmNameList_.size() - 1); i++) { - algorithmList += "\"" + experiment->algorithmNameList_[i] + "\", "; - } - algorithmList += "\"" + experiment->algorithmNameList_[experiment->algorithmNameList_.size() - 1] + "\") "; + for (int i = 0; i < (experiment->algorithmNameList_.size() - 1); i++) + { + algorithmList += "\"" + experiment->algorithmNameList_[i] + "\", "; + } + algorithmList += "\"" + experiment->algorithmNameList_[experiment->algorithmNameList_.size() - 1] + "\") "; - latexTabularAlignment = "l"; - for (int i = 1; i < experiment->algorithmNameList_.size(); i++) { - latexTabularAlignment += "c"; - } // for - string tabularString = "tabularString <-c(\""+ latexTabularAlignment + "\") "; - string tableFirstLine = "latexTableFirstLine <-c(\"" + latexTableFirstLine + ") "; + latexTabularAlignment = "l"; + for (int i = 1; i < experiment->algorithmNameList_.size(); i++) + { + latexTabularAlignment += "c"; + } // for + string tabularString = "tabularString <-c(\""+ latexTabularAlignment + "\") "; + string tableFirstLine = "latexTableFirstLine <-c(\"" + latexTableFirstLine + ") "; - output = "# Constants\n" + - problemList + "\n" + - algorithmList + "\n" + - tabularString + "\n" + - tableFirstLine + "\n" + - "indicator<-\"" + experiment->indicatorList_[indicator] + "\""; - out << output << endl; + output = "# Constants\n" + + problemList + "\n" + + algorithmList + "\n" + + tabularString + "\n" + + tableFirstLine + "\n" + + "indicator<-\"" + experiment->indicatorList_[indicator] + "\""; + out << output << endl; - out << "\n# Step 1. Writes the latex header" << endl; - out << "latexHeader()" << endl << endl;; - //out << output << endl; + out << "\n# Step 1. Writes the latex header" << endl; + out << "latexHeader()" << endl << endl;; + //out << output << endl; - // Generate tables per problem - out << "# Step 2. Problem loop" << endl; - out << "for (problem in problemList) {" << endl; - out << " latexTableHeader(problem, tabularString, latexTableFirstLine)" << endl << endl; - out << " indx = 0" << endl; - out << " for (i in algorithmList) {" << endl; - out << " if (i != \"" + experiment->algorithmNameList_[experiment->algorithmNameList_.size() - 1]+ "\") {" << endl; - out << " write(i , \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\" & \", \"" + texFile + "\", append=TRUE)" << endl; - out << " jndx = 0 " << endl; - out << " for (j in algorithmList) {" << endl; - out << " if (jndx != 0) {" << endl; - out << " if (indx != jndx) {" << endl; - out << " printTableLine(indicator, i, j, indx, jndx, problem)" << endl; - out << " }" << endl; - out << " else {" << endl; - out << " write(\" \", \"" + texFile + "\", append=TRUE)" << endl; - out << " }" << endl; - out << " if (j != \"" + experiment->algorithmNameList_[experiment->algorithmNameList_.size() - 1] + "\") {" << endl; - out << " write(\" & \", \"" + texFile + "\", append=TRUE)" << endl; - out << " }" << endl; - out << " else {" << endl; - out << " write(\" \\\\\\\\ \", \"" + texFile + "\", append=TRUE)" << endl; - out << " }" << endl; - out << " }" << endl; - out << " jndx = jndx + 1" << endl; - out << " }" << endl; - out << " indx = indx + 1" << endl; - out << " }" << endl; - out << " }" << endl << endl; - out << " latexTableTail()" << endl; - out << "} # for problem" << endl; - //out << output << endl; + // Generate tables per problem + out << "# Step 2. Problem loop" << endl; + out << "for (problem in problemList) {" << endl; + out << " latexTableHeader(problem, tabularString, latexTableFirstLine)" << endl << endl; + out << " indx = 0" << endl; + out << " for (i in algorithmList) {" << endl; + out << " if (i != \"" + experiment->algorithmNameList_[experiment->algorithmNameList_.size() - 1]+ "\") {" << endl; + out << " write(i , \"" + texFile + "\", append=TRUE)" << endl; + out << " write(\" & \", \"" + texFile + "\", append=TRUE)" << endl; + out << " jndx = 0 " << endl; + out << " for (j in algorithmList) {" << endl; + out << " if (jndx != 0) {" << endl; + out << " if (indx != jndx) {" << endl; + out << " printTableLine(indicator, i, j, indx, jndx, problem)" << endl; + out << " }" << endl; + out << " else {" << endl; + out << " write(\" \", \"" + texFile + "\", append=TRUE)" << endl; + out << " }" << endl; + out << " if (j != \"" + experiment->algorithmNameList_[experiment->algorithmNameList_.size() - 1] + "\") {" << endl; + out << " write(\" & \", \"" + texFile + "\", append=TRUE)" << endl; + out << " }" << endl; + out << " else {" << endl; + out << " write(\" \\\\\\\\ \", \"" + texFile + "\", append=TRUE)" << endl; + out << " }" << endl; + out << " }" << endl; + out << " jndx = jndx + 1" << endl; + out << " }" << endl; + out << " indx = indx + 1" << endl; + out << " }" << endl; + out << " }" << endl << endl; + out << " latexTableTail()" << endl; + out << "} # for problem" << endl; + //out << output << endl; - // Generate full table - problemList = ""; - for (int i = 0; i < problems.size(); i++) { - problemList += problems[i] + " "; - } - // The tabular environment and the latexTableFirstLine variable must be redefined - stringstream ssLatexTableFirstLine; - latexTabularAlignment = "| l | "; - ssLatexTableFirstLine << "\\\\hline \\\\multicolumn{1}{|c|}{}"; - for (int i = 1; i < experiment->algorithmNameList_.size(); i++) { - for (int j = 0; j < problems.size(); j++) { - latexTabularAlignment += "p{0.15cm} "; - //latexTabularAlignment += "c "; - } // for - ssLatexTableFirstLine << " & \\\\multicolumn{" << problems.size() << "}{c|}{" - << experiment->algorithmNameList_[i] << "}"; - latexTabularAlignment += " | " ; - } // for - ssLatexTableFirstLine << " \\\\\\\\"; - latexTableFirstLine = ssLatexTableFirstLine.str(); + // Generate full table + problemList = ""; + for (int i = 0; i < problems.size(); i++) + { + problemList += problems[i] + " "; + } + // The tabular environment and the latexTableFirstLine variable must be redefined + stringstream ssLatexTableFirstLine; + latexTabularAlignment = "| l | "; + ssLatexTableFirstLine << "\\\\hline \\\\multicolumn{1}{|c|}{}"; + for (int i = 1; i < experiment->algorithmNameList_.size(); i++) + { + for (int j = 0; j < problems.size(); j++) + { + latexTabularAlignment += "p{0.15cm} "; + //latexTabularAlignment += "c "; + } // for + ssLatexTableFirstLine << " & \\\\multicolumn{" << problems.size() << "}{c|}{" + << experiment->algorithmNameList_[i] << "}"; + latexTabularAlignment += " | " ; + } // for + ssLatexTableFirstLine << " \\\\\\\\"; + latexTableFirstLine = ssLatexTableFirstLine.str(); - tabularString = "tabularString <-c(\""+ latexTabularAlignment + "\") "; - latexTableFirstLine = "latexTableFirstLine <-c(\""+ latexTableFirstLine + "\") "; + tabularString = "tabularString <-c(\""+ latexTabularAlignment + "\") "; + latexTableFirstLine = "latexTableFirstLine <-c(\""+ latexTableFirstLine + "\") "; - output = tabularString; - out << output + "\n" << endl; - output = latexTableFirstLine ; - out << output + "\n" << endl; + output = tabularString; + out << output + "\n" << endl; + output = latexTableFirstLine ; + out << output + "\n" << endl; - out << "# Step 3. Problem loop" << endl; - out << "latexTableHeader(\"" + problemList + "\", tabularString, latexTableFirstLine)" << endl << endl; - out << "indx = 0" << endl; - out << "for (i in algorithmList) {" << endl; - out << " if (i != \"" + experiment->algorithmNameList_[experiment->algorithmNameList_.size() - 1]+ "\") {" << endl; - out << " write(i , \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\" & \", \"" + texFile + "\", append=TRUE)" << endl << endl; - out << " jndx = 0" << endl; - out << " for (j in algorithmList) {" << endl; - out << " for (problem in problemList) {" << endl; - out << " if (jndx != 0) {" << endl; - out << " if (i != j) {" << endl; - out << " printTableLine(indicator, i, j, indx, jndx, problem)" << endl; - out << " }" << endl; - out << " else {" << endl; - out << " write(\" \", \"" + texFile + "\", append=TRUE)" << endl; - out << " } " << endl; - out << " if (problem == \"" + problems[problems.size() - 1] + "\") {" << endl; - out << " if (j == \"" + experiment->algorithmNameList_[experiment->algorithmNameList_.size() - 1] + "\") {" << endl; - out << " write(\" \\\\\\\\ \", \"" + texFile + "\", append=TRUE)" << endl; - out << " } " << endl; - out << " else {" << endl; - out << " write(\" & \", \"" + texFile + "\", append=TRUE)" << endl; - out << " }" << endl; - out << " }" << endl; - out << " else {" << endl; - out << " write(\"&\", \"" + texFile + "\", append=TRUE)" << endl; - out << " }" << endl; - out << " }" << endl; - out << " }" << endl; - out << " jndx = jndx + 1" << endl; - out << " }" << endl; - out << " indx = indx + 1" << endl; - out << " }" << endl; - out << "} # for algorithm" << endl << endl; - out << "latexTableTail()" << endl; - //out << output << endl; + out << "# Step 3. Problem loop" << endl; + out << "latexTableHeader(\"" + problemList + "\", tabularString, latexTableFirstLine)" << endl << endl; + out << "indx = 0" << endl; + out << "for (i in algorithmList) {" << endl; + out << " if (i != \"" + experiment->algorithmNameList_[experiment->algorithmNameList_.size() - 1]+ "\") {" << endl; + out << " write(i , \"" + texFile + "\", append=TRUE)" << endl; + out << " write(\" & \", \"" + texFile + "\", append=TRUE)" << endl << endl; + out << " jndx = 0" << endl; + out << " for (j in algorithmList) {" << endl; + out << " for (problem in problemList) {" << endl; + out << " if (jndx != 0) {" << endl; + out << " if (i != j) {" << endl; + out << " printTableLine(indicator, i, j, indx, jndx, problem)" << endl; + out << " }" << endl; + out << " else {" << endl; + out << " write(\" \", \"" + texFile + "\", append=TRUE)" << endl; + out << " } " << endl; + out << " if (problem == \"" + problems[problems.size() - 1] + "\") {" << endl; + out << " if (j == \"" + experiment->algorithmNameList_[experiment->algorithmNameList_.size() - 1] + "\") {" << endl; + out << " write(\" \\\\\\\\ \", \"" + texFile + "\", append=TRUE)" << endl; + out << " } " << endl; + out << " else {" << endl; + out << " write(\" & \", \"" + texFile + "\", append=TRUE)" << endl; + out << " }" << endl; + out << " }" << endl; + out << " else {" << endl; + out << " write(\"&\", \"" + texFile + "\", append=TRUE)" << endl; + out << " }" << endl; + out << " }" << endl; + out << " }" << endl; + out << " jndx = jndx + 1" << endl; + out << " }" << endl; + out << " indx = indx + 1" << endl; + out << " }" << endl; + out << "} # for algorithm" << endl << endl; + out << "latexTableTail()" << endl; + //out << output << endl; - // Generate end of file - out << "#Step 4. Writes the end of latex file " << endl; - out << "latexTail()" << endl; + // Generate end of file + out << "#Step 4. Writes the end of latex file " << endl; + out << "latexTail()" << endl; - out.close(); - } // for + out.close(); + } // for } // generateScripts diff --git a/src/experiments/util/RWilcoxon.h b/src/experiments/util/RWilcoxon.h index 9ad64e8..4bc64c3 100644 --- a/src/experiments/util/RWilcoxon.h +++ b/src/experiments/util/RWilcoxon.h @@ -31,10 +31,11 @@ class ExperimentReport; * rank-sum test */ -class RWilcoxon { +class RWilcoxon +{ public: - static void generateScripts(vector problems, string prefix, - ExperimentReport * experiment); + static void generateScripts(vector problems, string prefix, + ExperimentReport * experiment); }; // RWilcoxon diff --git a/src/experiments/util/RunExperiment.cpp b/src/experiments/util/RunExperiment.cpp index 2b036b5..c650647 100644 --- a/src/experiments/util/RunExperiment.cpp +++ b/src/experiments/util/RunExperiment.cpp @@ -31,151 +31,162 @@ * Constructor */ RunExperiment::RunExperiment(ExperimentExecution * experiment, map map, - int id, int numberOfThreads, int numberOfProblems, int threadIndex, - mutex * mtx) { + int id, int numberOfThreads, int numberOfProblems, int threadIndex, + mutex * mtx) +{ - threadIndex_ = threadIndex; + threadIndex_ = threadIndex; - experiment_ = experiment; - id_ = id; - map_ = map; - numberOfThreads_ = numberOfThreads; - numberOfProblems_ = numberOfProblems; + experiment_ = experiment; + id_ = id; + map_ = map; + numberOfThreads_ = numberOfThreads; + numberOfProblems_ = numberOfProblems; - mutex_ = mtx; + mutex_ = mtx; - int partitions = numberOfProblems / numberOfThreads; + int partitions = numberOfProblems / numberOfThreads; } // RunExperiment -void RunExperiment::run() { +void RunExperiment::run() +{ - Algorithm * algorithm; // jMetal algorithm to be executed + Algorithm * algorithm; // jMetal algorithm to be executed - string experimentName = *(string*) map_["name"]; - cout << experimentName << endl; - experimentBaseDirectory_ = *(string*) map_["experimentDirectory"]; - cout << experimentBaseDirectory_ << endl; - algorithmNameList_ = *(vector*) map_["algorithmNameList"]; - problemList_ = *(vector*) map_["problemList"]; - independentRuns_ = *(int*) map_["independentRuns"]; - cout << independentRuns_ << endl; - outputParetoFrontFile_ = *(string*) map_["outputParetoFrontFile"]; - cout << outputParetoFrontFile_ << endl; - outputParetoSetFile_ = *(string*) map_["outputParetoSetFile"]; - cout << outputParetoSetFile_ << endl; + string experimentName = *(string*) map_["name"]; + cout << experimentName << endl; + experimentBaseDirectory_ = *(string*) map_["experimentDirectory"]; + cout << experimentBaseDirectory_ << endl; + algorithmNameList_ = *(vector*) map_["algorithmNameList"]; + problemList_ = *(vector*) map_["problemList"]; + independentRuns_ = *(int*) map_["independentRuns"]; + cout << independentRuns_ << endl; + outputParetoFrontFile_ = *(string*) map_["outputParetoFrontFile"]; + cout << outputParetoFrontFile_ << endl; + outputParetoSetFile_ = *(string*) map_["outputParetoSetFile"]; + cout << outputParetoSetFile_ << endl; - int numberOfAlgorithms = algorithmNameList_.size(); + int numberOfAlgorithms = algorithmNameList_.size(); - cout << "Experiment name: " << experimentName << endl; - cout << "Experiment directory: " << experimentBaseDirectory_ << endl; - cout << "Number of threads: " << numberOfThreads_ << endl; + cout << "Experiment name: " << experimentName << endl; + cout << "Experiment directory: " << experimentBaseDirectory_ << endl; + cout << "Number of threads: " << numberOfThreads_ << endl; - SolutionSet * resultFront = NULL; + SolutionSet * resultFront = NULL; - int problemIndex = -1; - int algorithmIndex = -1; - int numRun = -1; + int problemIndex = -1; + int algorithmIndex = -1; + int numRun = -1; - bool end = false; + bool end = false; - while (!end) { + while (!end) + { - // WAIT MUTEX + // WAIT MUTEX // int result = pthread_mutex_lock(mutex_) ; // if (result != 0) { // cerr << "RUNEXPERIMENT[" << threadIndex_ << "]: ERROR LOCKING THE MUTEX" << endl; // exit(-1) ; // } - mutex_->lock(); - - int experimentIndividualListIndex = experiment_->experimentIndividualListIndex_; - // cout << "Thread[" << threadIndex_ << "] experimentIndividualListIndex = " << - // experimentIndividualListIndex << endl; - // cout << "Thread[" << threadIndex_ << "] experiment_->experimentIndividualList_.size() = " << - // experiment_->experimentIndividualList_.size() << endl; - if (experimentIndividualListIndex < experiment_->experimentIndividualList_.size()) { - ExperimentIndividual * expIndv - = experiment_->experimentIndividualList_[experimentIndividualListIndex]; - problemIndex = expIndv->getProblemIndex(); - algorithmIndex = expIndv->getAlgorithmIndex(); - numRun = expIndv->getNumRun(); - experiment_->experimentIndividualListIndex_ = experimentIndividualListIndex + 1; - } else { - // cout << "Thread[" << threadIndex_ << "] is finishing." << endl; - end = true; - } - - // SIGNAL MUTEX + mutex_->lock(); + + int experimentIndividualListIndex = experiment_->experimentIndividualListIndex_; + // cout << "Thread[" << threadIndex_ << "] experimentIndividualListIndex = " << + // experimentIndividualListIndex << endl; + // cout << "Thread[" << threadIndex_ << "] experiment_->experimentIndividualList_.size() = " << + // experiment_->experimentIndividualList_.size() << endl; + if (experimentIndividualListIndex < experiment_->experimentIndividualList_.size()) + { + ExperimentIndividual * expIndv + = experiment_->experimentIndividualList_[experimentIndividualListIndex]; + problemIndex = expIndv->getProblemIndex(); + algorithmIndex = expIndv->getAlgorithmIndex(); + numRun = expIndv->getNumRun(); + experiment_->experimentIndividualListIndex_ = experimentIndividualListIndex + 1; + } + else + { + // cout << "Thread[" << threadIndex_ << "] is finishing." << endl; + end = true; + } + + // SIGNAL MUTEX // result = pthread_mutex_unlock(mutex_) ; // if (result != 0) { // cerr << "RUNEXPERIMENT[" << threadIndex_ << "]: ERROR UNLOCKING THE MUTEX" << endl; // exit(-1) ; // } - mutex_->unlock(); - - if (!end) { - - Problem * problem; // The problem to solve - string problemName; - string pfFilePath = ""; - - // Get the problem from the list - problemName = problemList_[problemIndex] ; - - char * problemName_ = (char *) problemName.c_str(); - // TODO: Improve Settings - algorithm = experiment_->algorithmSettings(problemName, algorithmIndex, - experimentIndividualListIndex); - - problem = algorithm->getProblem(); - - // Create output directories - string directory; - directory = experimentBaseDirectory_ + "/data/" + algorithmNameList_[algorithmIndex] + "/" + - problemList_[problemIndex]; - if (FileUtils::existsPath(directory.c_str()) != 1) { - FileUtils::createDirectory(directory); - cout << "Creating directory: " << directory << endl; - } - - // Run the algorithm - cout << "Thread[" << threadIndex_ << "]: Start of algorithm: " << - algorithmNameList_[algorithmIndex] << ", problem: " << - problemList_[problemIndex] << ", run: " << numRun << endl; - resultFront= algorithm->execute(); - - // Put the results in the output directory - stringstream outputParetoFrontFilePath; - stringstream outputParetoSetFilePath; - if (experiment_->isSingleObjective_) { - outputParetoFrontFilePath << directory << "/" << outputParetoFrontFile_; - outputParetoSetFilePath << directory << "/" << outputParetoSetFile_; - } else { - outputParetoFrontFilePath << directory << "/" << outputParetoFrontFile_ - << "." << numRun; - outputParetoSetFilePath << directory << "/" << outputParetoSetFile_ - << "." << numRun; - } - - resultFront->printObjectivesToFile(outputParetoFrontFilePath.str(), - experiment_->isSingleObjective_); - resultFront->printVariablesToFile(outputParetoSetFilePath.str(), - experiment_->isSingleObjective_); - - cout << "Thread[" << threadIndex_ << "]: End of algorithm: " << - algorithmNameList_[algorithmIndex] << ", problem: " << - problemList_[problemIndex] << ", run: " << numRun << endl; - - delete resultFront; - delete experiment_->algorithmSettingsList_[experimentIndividualListIndex]; - - } // if - - } // while - - cout << "Thread[" << threadIndex_ << "] has finished." << endl; + mutex_->unlock(); + + if (!end) + { + + Problem * problem; // The problem to solve + string problemName; + string pfFilePath = ""; + + // Get the problem from the list + problemName = problemList_[problemIndex] ; + + char * problemName_ = (char *) problemName.c_str(); + // TODO: Improve Settings + algorithm = experiment_->algorithmSettings(problemName, algorithmIndex, + experimentIndividualListIndex); + + problem = algorithm->getProblem(); + + // Create output directories + string directory; + directory = experimentBaseDirectory_ + "/data/" + algorithmNameList_[algorithmIndex] + "/" + + problemList_[problemIndex]; + if (FileUtils::existsPath(directory.c_str()) != 1) + { + FileUtils::createDirectory(directory); + cout << "Creating directory: " << directory << endl; + } + + // Run the algorithm + cout << "Thread[" << threadIndex_ << "]: Start of algorithm: " << + algorithmNameList_[algorithmIndex] << ", problem: " << + problemList_[problemIndex] << ", run: " << numRun << endl; + resultFront= algorithm->execute(); + + // Put the results in the output directory + stringstream outputParetoFrontFilePath; + stringstream outputParetoSetFilePath; + if (experiment_->isSingleObjective_) + { + outputParetoFrontFilePath << directory << "/" << outputParetoFrontFile_; + outputParetoSetFilePath << directory << "/" << outputParetoSetFile_; + } + else + { + outputParetoFrontFilePath << directory << "/" << outputParetoFrontFile_ + << "." << numRun; + outputParetoSetFilePath << directory << "/" << outputParetoSetFile_ + << "." << numRun; + } + + resultFront->printObjectivesToFile(outputParetoFrontFilePath.str(), + experiment_->isSingleObjective_); + resultFront->printVariablesToFile(outputParetoSetFilePath.str(), + experiment_->isSingleObjective_); + + cout << "Thread[" << threadIndex_ << "]: End of algorithm: " << + algorithmNameList_[algorithmIndex] << ", problem: " << + problemList_[problemIndex] << ", run: " << numRun << endl; + + delete resultFront; + delete experiment_->algorithmSettingsList_[experimentIndividualListIndex]; + + } // if + + } // while + + cout << "Thread[" << threadIndex_ << "] has finished." << endl; } // run diff --git a/src/experiments/util/RunExperiment.h b/src/experiments/util/RunExperiment.h index cd1291c..bdb89f8 100644 --- a/src/experiments/util/RunExperiment.h +++ b/src/experiments/util/RunExperiment.h @@ -39,41 +39,42 @@ using namespace std; class ExperimentExecution; -class RunExperiment { +class RunExperiment +{ public: - ExperimentExecution * experiment_; - int id_; - map map_; - int numberOfThreads_; - int numberOfProblems_; + ExperimentExecution * experiment_; + int id_; + map map_; + int numberOfThreads_; + int numberOfProblems_; - RunExperiment(ExperimentExecution * experiment, map map, int id, - int numberOfThreads, int numberOfProblems, int threadIndex, - mutex * mtx); - void run(); + RunExperiment(ExperimentExecution * experiment, map map, int id, + int numberOfThreads, int numberOfProblems, int threadIndex, + mutex * mtx); + void run(); private: - int threadIndex_; + int threadIndex_; - mutex * mutex_; + mutex * mutex_; - string experimentName_; - vector algorithmNameList_; // List of the names of the algorithms to - // be executed - vector problemList_; // List of problems to be solved - string experimentBaseDirectory_; // Directory to store the results - string latexDirectory_; // Directory to store the latex files - string rDirectory_; // Directory to store the generated R scripts - string paretoFrontDirectory_; // Directory containing the Pareto front files - string outputParetoFrontFile_; // Name of the file containing the output - // Pareto front - string outputParetoSetFile_; // Name of the file containing the output - // Pareto set - int independentRuns_; // Number of independent runs per algorithm - // TODO: Settings[] algorithmSettings_; // Parameter settings of each algorithm + string experimentName_; + vector algorithmNameList_; // List of the names of the algorithms to + // be executed + vector problemList_; // List of problems to be solved + string experimentBaseDirectory_; // Directory to store the results + string latexDirectory_; // Directory to store the latex files + string rDirectory_; // Directory to store the generated R scripts + string paretoFrontDirectory_; // Directory containing the Pareto front files + string outputParetoFrontFile_; // Name of the file containing the output + // Pareto front + string outputParetoSetFile_; // Name of the file containing the output + // Pareto set + int independentRuns_; // Number of independent runs per algorithm + // TODO: Settings[] algorithmSettings_; // Parameter settings of each algorithm }; // RunExperiment diff --git a/src/experiments/util/Statistics.cpp b/src/experiments/util/Statistics.cpp index 831443e..6d8c816 100644 --- a/src/experiments/util/Statistics.cpp +++ b/src/experiments/util/Statistics.cpp @@ -30,19 +30,23 @@ * @param last index of last position to consider in the vector * @return The median */ -double Statistics::calculateMedian(vector vector_, int first, int last) { - double median = 0.0; +double Statistics::calculateMedian(vector vector_, int first, int last) +{ + double median = 0.0; - int size = last - first + 1; - // cout << "size: " << size << "first: " << first << " last: " << last << endl; + int size = last - first + 1; + // cout << "size: " << size << "first: " << first << " last: " << last << endl; - if (size % 2 != 0) { - median = vector_[first + size / 2]; - } else { - median = (vector_[first + size / 2 - 1] + vector_[first + size / 2]) / 2.0; - } + if (size % 2 != 0) + { + median = vector_[first + size / 2]; + } + else + { + median = (vector_[first + size / 2 - 1] + vector_[first + size / 2]) / 2.0; + } - return median; + return median; } // calculatemedian @@ -51,23 +55,28 @@ double Statistics::calculateMedian(vector vector_, int first, int last) * @param vector * @return The IQR */ -double Statistics::calculateIQR(vector vector_) { - double q3 = 0.0; - double q1 = 0.0; +double Statistics::calculateIQR(vector vector_) +{ + double q3 = 0.0; + double q1 = 0.0; - if (vector_.size() > 1) { // == 1 implies IQR = 0 - if (vector_.size() % 2 != 0) { - q3 = calculateMedian(vector_, vector_.size() / 2 + 1, vector_.size() - 1); - q1 = calculateMedian(vector_, 0, vector_.size() / 2 - 1); - //cout << "Q1: [" << 0 << ", " << (vector.size()/2 - 1) << "] = " << q1 << endl; - //cout << "Q3: [" << (vector.size()/2+1) << ", " << (vector.size()-1) << "]= " << q3 << endl; - } else { - q3 = calculateMedian(vector_, vector_.size() / 2, vector_.size() - 1); - q1 = calculateMedian(vector_, 0, vector_.size() / 2 - 1); - //cout << "Q1: [" << 0 << ", " << (vector.size()/2 - 1) << "] = " << q1 << endl; - //cout << "Q3: [" << (vector.size()/2) << ", " << (vector.size()-1) << "]= " << q3 << endl; - } // else - } // if + if (vector_.size() > 1) // == 1 implies IQR = 0 + { + if (vector_.size() % 2 != 0) + { + q3 = calculateMedian(vector_, vector_.size() / 2 + 1, vector_.size() - 1); + q1 = calculateMedian(vector_, 0, vector_.size() / 2 - 1); + //cout << "Q1: [" << 0 << ", " << (vector.size()/2 - 1) << "] = " << q1 << endl; + //cout << "Q3: [" << (vector.size()/2+1) << ", " << (vector.size()-1) << "]= " << q3 << endl; + } + else + { + q3 = calculateMedian(vector_, vector_.size() / 2, vector_.size() - 1); + q1 = calculateMedian(vector_, 0, vector_.size() / 2 - 1); + //cout << "Q1: [" << 0 << ", " << (vector.size()/2 - 1) << "] = " << q1 << endl; + //cout << "Q3: [" << (vector.size()/2) << ", " << (vector.size()-1) << "]= " << q3 << endl; + } // else + } // if - return q3 - q1; + return q3 - q1; } // calculateIQR diff --git a/src/experiments/util/Statistics.h b/src/experiments/util/Statistics.h index 269ccf7..d682a53 100644 --- a/src/experiments/util/Statistics.h +++ b/src/experiments/util/Statistics.h @@ -29,11 +29,12 @@ using namespace std; * This class provides methods for computing some statistics */ -class Statistics { +class Statistics +{ public: - static double calculateMedian(vector vector_, int first, int last); - static double calculateIQR(vector vector_); + static double calculateMedian(vector vector_, int first, int last); + static double calculateIQR(vector vector_); }; diff --git a/src/main/CMAES_main.cpp b/src/main/CMAES_main.cpp index 4900848..275fc04 100644 --- a/src/main/CMAES_main.cpp +++ b/src/main/CMAES_main.cpp @@ -26,48 +26,52 @@ #include #include -int main(int argc, char ** argv) { +int main(int argc, char ** argv) +{ - clock_t t_ini, t_fin; + clock_t t_ini, t_fin; - Problem * problem ; // The problem to solve - Algorithm * algorithm ; // The algorithm to use + Problem * problem ; // The problem to solve + Algorithm * algorithm ; // The algorithm to use - if (argc>=2) { - problem = ProblemFactory::getProblem(argc, argv); - cout << "Selected problem: " << problem->getName() << endl; - } else { - cout << "No problem selected." << endl; - cout << "Default problem will be used: Sphere" << endl; - problem = ProblemFactory::getProblem(const_cast("Sphere")); - } + if (argc>=2) + { + problem = ProblemFactory::getProblem(argc, argv); + cout << "Selected problem: " << problem->getName() << endl; + } + else + { + cout << "No problem selected." << endl; + cout << "Default problem will be used: Sphere" << endl; + problem = ProblemFactory::getProblem(const_cast("Sphere")); + } - algorithm = new CMAES(problem); + algorithm = new CMAES(problem); - // Algorithm parameters - int populationSizeValue = 20; - int maxEvaluationsValue = 1000000; - algorithm->setInputParameter("populationSize",&populationSizeValue); - algorithm->setInputParameter("maxEvaluations",&maxEvaluationsValue); + // Algorithm parameters + int populationSizeValue = 20; + int maxEvaluationsValue = 1000000; + algorithm->setInputParameter("populationSize",&populationSizeValue); + algorithm->setInputParameter("maxEvaluations",&maxEvaluationsValue); - // Add the indicator object to the algorithm - //algorithm->setInputParameter("indicators", indicators) ; + // Add the indicator object to the algorithm + //algorithm->setInputParameter("indicators", indicators) ; - // Execute the Algorithm - t_ini = clock(); - SolutionSet * population = algorithm->execute(); - t_fin = clock(); - double secs = (double) (t_fin - t_ini); - secs = secs / CLOCKS_PER_SEC; + // Execute the Algorithm + t_ini = clock(); + SolutionSet * population = algorithm->execute(); + t_fin = clock(); + double secs = (double) (t_fin - t_ini); + secs = secs / CLOCKS_PER_SEC; - // Result messages - cout << "Total execution time: " << secs << "s" << endl; - cout << "Variables values have been written to file VAR" << endl; - population->printVariablesToFile("VAR"); - cout << "Objectives values have been written to file FUN" << endl; - population->printObjectivesToFile("FUN"); - - delete population; - delete algorithm; + // Result messages + cout << "Total execution time: " << secs << "s" << endl; + cout << "Variables values have been written to file VAR" << endl; + population->printVariablesToFile("VAR"); + cout << "Objectives values have been written to file FUN" << endl; + population->printObjectivesToFile("FUN"); + + delete population; + delete algorithm; } // main diff --git a/src/main/DE_main.cpp b/src/main/DE_main.cpp index e16e6f9..6689a78 100644 --- a/src/main/DE_main.cpp +++ b/src/main/DE_main.cpp @@ -30,74 +30,78 @@ #include #include -int main(int argc, char ** argv) { - - clock_t t_ini, t_fin; - - Problem * problem ; // The problem to solve - Algorithm * algorithm ; // The algorithm to use - Operator * crossover ; // Crossover operator - Operator * mutation ; // Mutation operator - Operator * selection ; // Selection operator - - map parameters; - - //TODO: QualityIndicator * indicators; - - if (argc>=2) { - problem = ProblemFactory::getProblem(argc, argv); - cout << "Selected problem: " << problem->getName() << endl; - } else { - cout << "No problem selected." << endl; - cout << "Default problem will be used: Sphere" << endl; - problem = ProblemFactory::getProblem(const_cast("Sphere")); - } - - algorithm = new DE(problem); - - // Algorithm parameters - int populationSizeValue = 100; - int maxEvaluationsValue = 1000000; - algorithm->setInputParameter("populationSize",&populationSizeValue); - algorithm->setInputParameter("maxEvaluations",&maxEvaluationsValue); - - // Crossover operator - double crParameter = 0.5; - double fParameter = 0.5; - parameters["CR"] = &crParameter; - parameters["F"] = &fParameter; - string deVariantParameter = "rand/1/bin"; - parameters["DE_VARIANT"] = &deVariantParameter; - crossover = new DifferentialEvolutionCrossover(parameters); - - // Selection operator - parameters.clear(); - selection = new DifferentialEvolutionSelection(parameters) ; - - // Add the operators to the algorithm - algorithm->addOperator("crossover",crossover); - algorithm->addOperator("selection",selection); - - // Add the indicator object to the algorithm - //algorithm->setInputParameter("indicators", indicators); - - // Execute the Algorithm - t_ini = clock(); - SolutionSet * population = algorithm->execute(); - t_fin = clock(); - double secs = (double) (t_fin - t_ini); - secs = secs / CLOCKS_PER_SEC; - - // Result messages - cout << "Total execution time: " << secs << "s" << endl; - cout << "Variables values have been written to file VAR" << endl; - population->printVariablesToFile("VAR"); - cout << "Objectives values have been written to file FUN" << endl; - population->printObjectivesToFile("FUN"); - - delete crossover; - delete selection; - delete population; - delete algorithm; +int main(int argc, char ** argv) +{ + + clock_t t_ini, t_fin; + + Problem * problem ; // The problem to solve + Algorithm * algorithm ; // The algorithm to use + Operator * crossover ; // Crossover operator + Operator * mutation ; // Mutation operator + Operator * selection ; // Selection operator + + map parameters; + + //TODO: QualityIndicator * indicators; + + if (argc>=2) + { + problem = ProblemFactory::getProblem(argc, argv); + cout << "Selected problem: " << problem->getName() << endl; + } + else + { + cout << "No problem selected." << endl; + cout << "Default problem will be used: Sphere" << endl; + problem = ProblemFactory::getProblem(const_cast("Sphere")); + } + + algorithm = new DE(problem); + + // Algorithm parameters + int populationSizeValue = 100; + int maxEvaluationsValue = 1000000; + algorithm->setInputParameter("populationSize",&populationSizeValue); + algorithm->setInputParameter("maxEvaluations",&maxEvaluationsValue); + + // Crossover operator + double crParameter = 0.5; + double fParameter = 0.5; + parameters["CR"] = &crParameter; + parameters["F"] = &fParameter; + string deVariantParameter = "rand/1/bin"; + parameters["DE_VARIANT"] = &deVariantParameter; + crossover = new DifferentialEvolutionCrossover(parameters); + + // Selection operator + parameters.clear(); + selection = new DifferentialEvolutionSelection(parameters) ; + + // Add the operators to the algorithm + algorithm->addOperator("crossover",crossover); + algorithm->addOperator("selection",selection); + + // Add the indicator object to the algorithm + //algorithm->setInputParameter("indicators", indicators); + + // Execute the Algorithm + t_ini = clock(); + SolutionSet * population = algorithm->execute(); + t_fin = clock(); + double secs = (double) (t_fin - t_ini); + secs = secs / CLOCKS_PER_SEC; + + // Result messages + cout << "Total execution time: " << secs << "s" << endl; + cout << "Variables values have been written to file VAR" << endl; + population->printVariablesToFile("VAR"); + cout << "Objectives values have been written to file FUN" << endl; + population->printObjectivesToFile("FUN"); + + delete crossover; + delete selection; + delete population; + delete algorithm; } // main diff --git a/src/main/FastSMSEMOA_main.cpp b/src/main/FastSMSEMOA_main.cpp index a6f57bd..f0bca43 100755 --- a/src/main/FastSMSEMOA_main.cpp +++ b/src/main/FastSMSEMOA_main.cpp @@ -32,88 +32,92 @@ -int main(int argc, char ** argv) { - - clock_t t_ini, t_fin; - - Problem * problem ; // The problem to solve - Algorithm * algorithm ; // The algorithm to use - Operator * crossover ; // Crossover operator - Operator * mutation ; // Mutation operator - Operator * selection ; // Selection operator - - if (argc>=2) { - problem = ProblemFactory::getProblem(argc, argv); - cout << "Selected problem: " << problem->getName() << endl; - } else { - cout << "No problem selected." << endl; - cout << "Default problem will be used: Fonseca" << endl; - problem = ProblemFactory::getProblem(const_cast("Fonseca")); - } - - //TODO: Quality Indicators - //QualityIndicator indicators ; // Object to get quality indicators - //indicators = null ; - - algorithm = new FastSMSEMOA(problem); - - // Algorithm parameters - int populationSize = 100; - int maxEvaluations = 500; - double offset = 100; - - algorithm->setInputParameter("populationSize",&populationSize); - algorithm->setInputParameter("maxEvaluations",&maxEvaluations); - algorithm->setInputParameter("offset",&offset); - - // Mutation - map parameters; - double crossoverProbability = 0.9; - double crossoverDistributionIndex = 20.0; - parameters["probability"] = &crossoverProbability; - parameters["distributionIndex"] = &crossoverDistributionIndex; - crossover = new SBXCrossover(parameters); - - //Crossover - parameters.clear(); - double mutationProbability = 1.0/problem->getNumberOfVariables(); - double mutationDistributionIndex = 20.0; - parameters["probability"] = &mutationProbability; - parameters["distributionIndex"] = &mutationDistributionIndex; - mutation = new PolynomialMutation(parameters); - - // Selection Operator - parameters.clear(); - selection = new RandomSelection(parameters); - - // Add the operators to the algorithm - algorithm->addOperator("crossover",crossover); - algorithm->addOperator("mutation",mutation); - algorithm->addOperator("selection",selection); - - // Add the indicator object to the algorithm - //algorithm->setInputParameter("indicators", indicators) ; - - // Execute the Algorithm - t_ini = clock(); - - SolutionSet * population = algorithm->execute(); - - t_fin = clock(); - double secs = (double) (t_fin - t_ini); - secs = secs / CLOCKS_PER_SEC; - - // Result messages - cout << "Total execution time: " << secs << "s" << endl; - cout << "Variables values have been written to file VAR" << endl; - population->printVariablesToFile("VAR"); - cout << "Objectives values have been written to file FUN" << endl; - population->printObjectivesToFile("FUN"); - - delete mutation; - delete crossover; - delete selection; - delete population; - delete algorithm; +int main(int argc, char ** argv) +{ + + clock_t t_ini, t_fin; + + Problem * problem ; // The problem to solve + Algorithm * algorithm ; // The algorithm to use + Operator * crossover ; // Crossover operator + Operator * mutation ; // Mutation operator + Operator * selection ; // Selection operator + + if (argc>=2) + { + problem = ProblemFactory::getProblem(argc, argv); + cout << "Selected problem: " << problem->getName() << endl; + } + else + { + cout << "No problem selected." << endl; + cout << "Default problem will be used: Fonseca" << endl; + problem = ProblemFactory::getProblem(const_cast("Fonseca")); + } + + //TODO: Quality Indicators + //QualityIndicator indicators ; // Object to get quality indicators + //indicators = null ; + + algorithm = new FastSMSEMOA(problem); + + // Algorithm parameters + int populationSize = 100; + int maxEvaluations = 500; + double offset = 100; + + algorithm->setInputParameter("populationSize",&populationSize); + algorithm->setInputParameter("maxEvaluations",&maxEvaluations); + algorithm->setInputParameter("offset",&offset); + + // Mutation + map parameters; + double crossoverProbability = 0.9; + double crossoverDistributionIndex = 20.0; + parameters["probability"] = &crossoverProbability; + parameters["distributionIndex"] = &crossoverDistributionIndex; + crossover = new SBXCrossover(parameters); + + //Crossover + parameters.clear(); + double mutationProbability = 1.0/problem->getNumberOfVariables(); + double mutationDistributionIndex = 20.0; + parameters["probability"] = &mutationProbability; + parameters["distributionIndex"] = &mutationDistributionIndex; + mutation = new PolynomialMutation(parameters); + + // Selection Operator + parameters.clear(); + selection = new RandomSelection(parameters); + + // Add the operators to the algorithm + algorithm->addOperator("crossover",crossover); + algorithm->addOperator("mutation",mutation); + algorithm->addOperator("selection",selection); + + // Add the indicator object to the algorithm + //algorithm->setInputParameter("indicators", indicators) ; + + // Execute the Algorithm + t_ini = clock(); + + SolutionSet * population = algorithm->execute(); + + t_fin = clock(); + double secs = (double) (t_fin - t_ini); + secs = secs / CLOCKS_PER_SEC; + + // Result messages + cout << "Total execution time: " << secs << "s" << endl; + cout << "Variables values have been written to file VAR" << endl; + population->printVariablesToFile("VAR"); + cout << "Objectives values have been written to file FUN" << endl; + population->printObjectivesToFile("FUN"); + + delete mutation; + delete crossover; + delete selection; + delete population; + delete algorithm; } // main diff --git a/src/main/GDE3_main.cpp b/src/main/GDE3_main.cpp index 97a273d..4873199 100644 --- a/src/main/GDE3_main.cpp +++ b/src/main/GDE3_main.cpp @@ -30,71 +30,75 @@ #include #include -int main(int argc, char ** argv) { - - clock_t t_ini, t_fin; - - Problem * problem ; // The problem to solve - Algorithm * algorithm ; // The algorithm to use - Operator * crossover ; // Crossover operator - Operator * selection ; // Selection operator - - map parameters; - - //TODO: QualityIndicator * indicators; - - if (argc>=2) { - problem = ProblemFactory::getProblem(argc, argv); - cout << "Selected problem: " << problem->getName() << endl; - } else { - cout << "No problem selected." << endl; - cout << "Default problem will be used: Fonseca" << endl; - problem = ProblemFactory::getProblem(const_cast("Fonseca")); - } - - algorithm = new GDE3(problem); - - // Algorithm parameters - int populationSizeValue = 100; - int maxIterationsValue = 250; - algorithm->setInputParameter("populationSize",&populationSizeValue); - algorithm->setInputParameter("maxIterations",&maxIterationsValue); - - // Crossover operator - double crParameter = 0.5; - double fParameter = 0.5; - parameters["CR"] = &crParameter; - parameters["F"] = &fParameter; - crossover = new DifferentialEvolutionCrossover(parameters); - - // Selection operator - parameters.clear(); - selection = new DifferentialEvolutionSelection(parameters) ; - - // Add the operators to the algorithm - algorithm->addOperator("crossover",crossover); - algorithm->addOperator("selection",selection); - - // Add the indicator object to the algorithm - //algorithm->setInputParameter("indicators", indicators) ; - - // Execute the Algorithm - t_ini = clock(); - SolutionSet * population = algorithm->execute(); - t_fin = clock(); - double secs = (double) (t_fin - t_ini); - secs = secs / CLOCKS_PER_SEC; - - // Result messages - cout << "Total execution time: " << secs << "s" << endl; - cout << "Variables values have been written to file VAR" << endl; - population->printVariablesToFile("VAR"); - cout << "Objectives values have been written to file FUN" << endl; - population->printObjectivesToFile("FUN"); - - delete selection; - delete crossover; - delete population; - delete algorithm; +int main(int argc, char ** argv) +{ + + clock_t t_ini, t_fin; + + Problem * problem ; // The problem to solve + Algorithm * algorithm ; // The algorithm to use + Operator * crossover ; // Crossover operator + Operator * selection ; // Selection operator + + map parameters; + + //TODO: QualityIndicator * indicators; + + if (argc>=2) + { + problem = ProblemFactory::getProblem(argc, argv); + cout << "Selected problem: " << problem->getName() << endl; + } + else + { + cout << "No problem selected." << endl; + cout << "Default problem will be used: Fonseca" << endl; + problem = ProblemFactory::getProblem(const_cast("Fonseca")); + } + + algorithm = new GDE3(problem); + + // Algorithm parameters + int populationSizeValue = 100; + int maxIterationsValue = 250; + algorithm->setInputParameter("populationSize",&populationSizeValue); + algorithm->setInputParameter("maxIterations",&maxIterationsValue); + + // Crossover operator + double crParameter = 0.5; + double fParameter = 0.5; + parameters["CR"] = &crParameter; + parameters["F"] = &fParameter; + crossover = new DifferentialEvolutionCrossover(parameters); + + // Selection operator + parameters.clear(); + selection = new DifferentialEvolutionSelection(parameters) ; + + // Add the operators to the algorithm + algorithm->addOperator("crossover",crossover); + algorithm->addOperator("selection",selection); + + // Add the indicator object to the algorithm + //algorithm->setInputParameter("indicators", indicators) ; + + // Execute the Algorithm + t_ini = clock(); + SolutionSet * population = algorithm->execute(); + t_fin = clock(); + double secs = (double) (t_fin - t_ini); + secs = secs / CLOCKS_PER_SEC; + + // Result messages + cout << "Total execution time: " << secs << "s" << endl; + cout << "Variables values have been written to file VAR" << endl; + population->printVariablesToFile("VAR"); + cout << "Objectives values have been written to file FUN" << endl; + population->printObjectivesToFile("FUN"); + + delete selection; + delete crossover; + delete population; + delete algorithm; } // main diff --git a/src/main/MOCHC_main.cpp b/src/main/MOCHC_main.cpp index 218290e..d977ad7 100644 --- a/src/main/MOCHC_main.cpp +++ b/src/main/MOCHC_main.cpp @@ -48,87 +48,91 @@ * 5th International Conference, EMO 2009, pp: 183-197. * April 2009) */ -int main(int argc, char ** argv) { - - clock_t t_ini, t_fin; - - Problem * problem ; // The problem to solve - Algorithm * algorithm ; // The algorithm to use - HUXCrossover * crossover ; // Crossover operator - BitFlipMutation * mutation ; // Mutation operator - BinaryTournament * selection ; // Selection operator - - if (argc>=2) { - problem = ProblemFactory::getProblem(argc, argv); - cout << "Selected problem: " << problem->getName() << endl; - } else { - cout << "No problem selected." << endl; - cout << "Default problem will be used: Fonseca" << endl; - problem = ProblemFactory::getProblem(const_cast("ZDT5")); - } - +int main(int argc, char ** argv) +{ + + clock_t t_ini, t_fin; + + Problem * problem ; // The problem to solve + Algorithm * algorithm ; // The algorithm to use + HUXCrossover * crossover ; // Crossover operator + BitFlipMutation * mutation ; // Mutation operator + BinaryTournament * selection ; // Selection operator + + if (argc>=2) + { + problem = ProblemFactory::getProblem(argc, argv); + cout << "Selected problem: " << problem->getName() << endl; + } + else + { + cout << "No problem selected." << endl; + cout << "Default problem will be used: Fonseca" << endl; + problem = ProblemFactory::getProblem(const_cast("ZDT5")); + } + // QualityIndicator * indicators ; // Object to get quality indicators // indicators = NULL ; - algorithm = new MOCHC(problem); + algorithm = new MOCHC(problem); - // Algorithm parameters - int populationSize = 100; - int maxEvaluations = 25000; - double initialConvergenceCount = 0.25; - double preservedPopulation = 0.05; - int convergenceValue = 3; - algorithm->setInputParameter("populationSize",&populationSize); - algorithm->setInputParameter("maxEvaluations",&maxEvaluations); - algorithm->setInputParameter("initialConvergenceCount",&initialConvergenceCount); - algorithm->setInputParameter("preservedPopulation",&preservedPopulation); - algorithm->setInputParameter("convergenceValue",&convergenceValue); + // Algorithm parameters + int populationSize = 100; + int maxEvaluations = 25000; + double initialConvergenceCount = 0.25; + double preservedPopulation = 0.05; + int convergenceValue = 3; + algorithm->setInputParameter("populationSize",&populationSize); + algorithm->setInputParameter("maxEvaluations",&maxEvaluations); + algorithm->setInputParameter("initialConvergenceCount",&initialConvergenceCount); + algorithm->setInputParameter("preservedPopulation",&preservedPopulation); + algorithm->setInputParameter("convergenceValue",&convergenceValue); - // Mutation and Crossover for Real codification - map parameters; + // Mutation and Crossover for Real codification + map parameters; - double crossoverProbability = 1.0; - double crossoverDistributionIndex = 20.0; - parameters["probability"] = &crossoverProbability; - crossover = new HUXCrossover(parameters); + double crossoverProbability = 1.0; + double crossoverDistributionIndex = 20.0; + parameters["probability"] = &crossoverProbability; + crossover = new HUXCrossover(parameters); - parameters.clear(); - double mutationProbability = 0.35; - parameters["probability"] = &mutationProbability; + parameters.clear(); + double mutationProbability = 0.35; + parameters["probability"] = &mutationProbability; - mutation = new BitFlipMutation(parameters); + mutation = new BitFlipMutation(parameters); - // Selection Operator - parameters.clear(); - selection = new BinaryTournament(parameters); + // Selection Operator + parameters.clear(); + selection = new BinaryTournament(parameters); - // Add the operators to the algorithm - algorithm->addOperator("crossover",crossover); - algorithm->addOperator("mutation",mutation); - algorithm->addOperator("parentSelection",selection); + // Add the operators to the algorithm + algorithm->addOperator("crossover",crossover); + algorithm->addOperator("mutation",mutation); + algorithm->addOperator("parentSelection",selection); - // Add the indicator object to the algorithm + // Add the indicator object to the algorithm // algorithm->setInputParameter("indicators", indicators) ; - // Execute the Algorithm - t_ini = clock(); - SolutionSet * population = algorithm->execute(); - t_fin = clock(); - double secs = (double) (t_fin - t_ini); - secs = secs / CLOCKS_PER_SEC; - - // Result messages - cout << "Total execution time: " << secs << "s" << endl; - cout << "Variables values have been written to file VAR" << endl; - population->printVariablesToFile("VAR"); - cout << "Objectives values have been written to file FUN" << endl; - population->printObjectivesToFile("FUN"); - - - delete selection; - delete mutation; - delete crossover; - delete population; - delete algorithm; + // Execute the Algorithm + t_ini = clock(); + SolutionSet * population = algorithm->execute(); + t_fin = clock(); + double secs = (double) (t_fin - t_ini); + secs = secs / CLOCKS_PER_SEC; + + // Result messages + cout << "Total execution time: " << secs << "s" << endl; + cout << "Variables values have been written to file VAR" << endl; + population->printVariablesToFile("VAR"); + cout << "Objectives values have been written to file FUN" << endl; + population->printObjectivesToFile("FUN"); + + + delete selection; + delete mutation; + delete crossover; + delete population; + delete algorithm; } // main diff --git a/src/main/MOEAD_main.cpp b/src/main/MOEAD_main.cpp index 125afdf..0aaed16 100644 --- a/src/main/MOEAD_main.cpp +++ b/src/main/MOEAD_main.cpp @@ -31,93 +31,97 @@ /** * This class executes the algorithm described in: - * H. Li and Q. Zhang, - * "Multiobjective Optimization Problems with Complicated Pareto Sets, MOEA/D - * and NSGA-II". IEEE Trans on Evolutionary Computation, vol. 12, no 2, - * pp 284-302, April/2009. + * H. Li and Q. Zhang, + * "Multiobjective Optimization Problems with Complicated Pareto Sets, MOEA/D + * and NSGA-II". IEEE Trans on Evolutionary Computation, vol. 12, no 2, + * pp 284-302, April/2009. */ -int main(int argc, char ** argv) { - - clock_t t_ini, t_fin; - - Problem * problem; // The problem to solve - Algorithm * algorithm; // The algorithm to use - Operator * crossover; // Crossover operator - Operator * mutation; // Mutation operator - - //QualityIndicator * indicators ; // Object to get quality indicators - - map parameters; // Operator parameters - - //TODO: QualityIndicator * indicators; // Object to get quality indicators - - if (argc>=2) { - problem = ProblemFactory::getProblem(argc, argv); - cout << "Selected problem: " << problem->getName() << endl; - } else { - cout << "No problem selected." << endl; - cout << "Default problem will be used: Kursawe" << endl; - problem = ProblemFactory::getProblem(const_cast("Kursawe")); - } - - algorithm = new MOEAD(problem); - - // Algorithm parameters - int populationSizeValue = 300; - int maxEvaluationsValue = 150000; - algorithm->setInputParameter("populationSize",&populationSizeValue); - algorithm->setInputParameter("maxEvaluations",&maxEvaluationsValue); - - // Directory with the files containing the weight vectors used in - // Q. Zhang, W. Liu, and H Li, The Performance of a New Version of MOEA/D - // on CEC09 Unconstrained MOP Test Instances Working Report CES-491, School - // of CS & EE, University of Essex, 02/2009. - // http://dces.essex.ac.uk/staff/qzhang/MOEAcompetition/CEC09final/code/ZhangMOEADcode/moead0305.rar - string dataDirectoryValue = - "../../data/Weight"; - algorithm->setInputParameter("dataDirectory", &dataDirectoryValue); - - // Crossover operator - double crParameter = 1.0; - double fParameter = 0.5; - parameters["CR"] = &crParameter; - parameters["F"] = &fParameter; - crossover = new DifferentialEvolutionCrossover(parameters); - - // Mutation operator - parameters.clear(); - double probabilityParameter = 1.0/(problem->getNumberOfVariables()); - double distributionIndexParameter = 20.0; - parameters["probability"] = &probabilityParameter; - parameters["distributionIndex"] = &distributionIndexParameter; - mutation = new PolynomialMutation(parameters); - - // Add the operators to the algorithm - algorithm->addOperator("crossover",crossover); - algorithm->addOperator("mutation",mutation); - - // Add the indicator object to the algorithm - //algorithm->setInputParameter("indicators", indicators) ; - - // Execute the Algorithm - t_ini = clock(); - SolutionSet * population = algorithm->execute(); - t_fin = clock(); - double secs = (double) (t_fin - t_ini); - secs = secs / CLOCKS_PER_SEC; - - // Result messages - cout << "Total execution time: " << secs << "s" << endl; - cout << "Variables values have been written to file VAR" << endl; - population->printVariablesToFile("VAR"); - cout << "Objectives values have been written to file FUN" << endl; - population->printObjectivesToFile("FUN"); - - delete mutation; - delete crossover; - delete population; - delete algorithm; +int main(int argc, char ** argv) +{ + + clock_t t_ini, t_fin; + + Problem * problem; // The problem to solve + Algorithm * algorithm; // The algorithm to use + Operator * crossover; // Crossover operator + Operator * mutation; // Mutation operator + + //QualityIndicator * indicators ; // Object to get quality indicators + + map parameters; // Operator parameters + + //TODO: QualityIndicator * indicators; // Object to get quality indicators + + if (argc>=2) + { + problem = ProblemFactory::getProblem(argc, argv); + cout << "Selected problem: " << problem->getName() << endl; + } + else + { + cout << "No problem selected." << endl; + cout << "Default problem will be used: Kursawe" << endl; + problem = ProblemFactory::getProblem(const_cast("Kursawe")); + } + + algorithm = new MOEAD(problem); + + // Algorithm parameters + int populationSizeValue = 300; + int maxEvaluationsValue = 150000; + algorithm->setInputParameter("populationSize",&populationSizeValue); + algorithm->setInputParameter("maxEvaluations",&maxEvaluationsValue); + + // Directory with the files containing the weight vectors used in + // Q. Zhang, W. Liu, and H Li, The Performance of a New Version of MOEA/D + // on CEC09 Unconstrained MOP Test Instances Working Report CES-491, School + // of CS & EE, University of Essex, 02/2009. + // http://dces.essex.ac.uk/staff/qzhang/MOEAcompetition/CEC09final/code/ZhangMOEADcode/moead0305.rar + string dataDirectoryValue = + "../../data/Weight"; + algorithm->setInputParameter("dataDirectory", &dataDirectoryValue); + + // Crossover operator + double crParameter = 1.0; + double fParameter = 0.5; + parameters["CR"] = &crParameter; + parameters["F"] = &fParameter; + crossover = new DifferentialEvolutionCrossover(parameters); + + // Mutation operator + parameters.clear(); + double probabilityParameter = 1.0/(problem->getNumberOfVariables()); + double distributionIndexParameter = 20.0; + parameters["probability"] = &probabilityParameter; + parameters["distributionIndex"] = &distributionIndexParameter; + mutation = new PolynomialMutation(parameters); + + // Add the operators to the algorithm + algorithm->addOperator("crossover",crossover); + algorithm->addOperator("mutation",mutation); + + // Add the indicator object to the algorithm + //algorithm->setInputParameter("indicators", indicators) ; + + // Execute the Algorithm + t_ini = clock(); + SolutionSet * population = algorithm->execute(); + t_fin = clock(); + double secs = (double) (t_fin - t_ini); + secs = secs / CLOCKS_PER_SEC; + + // Result messages + cout << "Total execution time: " << secs << "s" << endl; + cout << "Variables values have been written to file VAR" << endl; + population->printVariablesToFile("VAR"); + cout << "Objectives values have been written to file FUN" << endl; + population->printObjectivesToFile("FUN"); + + delete mutation; + delete crossover; + delete population; + delete algorithm; } // main diff --git a/src/main/NSGAII_main.cpp b/src/main/NSGAII_main.cpp index 76662cb..f672ef7 100644 --- a/src/main/NSGAII_main.cpp +++ b/src/main/NSGAII_main.cpp @@ -47,78 +47,82 @@ * 5th International Conference, EMO 2009, pp: 183-197. * April 2009) */ -int main(int argc, char ** argv) { - - clock_t t_ini, t_fin; - - Problem * problem ; // The problem to solve - Algorithm * algorithm ; // The algorithm to use - Operator * crossover ; // Crossover operator - Operator * mutation ; // Mutation operator - Operator * selection ; // Selection operator - - if (argc>=2) { - problem = ProblemFactory::getProblem(argc, argv); - cout << "Selected problem: " << problem->getName() << endl; - } else { - cout << "No problem selected." << endl; - cout << "Default problem will be used: Fonseca" << endl; - problem = ProblemFactory::getProblem(const_cast("Fonseca")); - } - +int main(int argc, char ** argv) +{ + + clock_t t_ini, t_fin; + + Problem * problem ; // The problem to solve + Algorithm * algorithm ; // The algorithm to use + Operator * crossover ; // Crossover operator + Operator * mutation ; // Mutation operator + Operator * selection ; // Selection operator + + if (argc>=2) + { + problem = ProblemFactory::getProblem(argc, argv); + cout << "Selected problem: " << problem->getName() << endl; + } + else + { + cout << "No problem selected." << endl; + cout << "Default problem will be used: Fonseca" << endl; + problem = ProblemFactory::getProblem(const_cast("Fonseca")); + } + // QualityIndicator * indicators ; // Object to get quality indicators // indicators = NULL ; - algorithm = new NSGAII(problem); + algorithm = new NSGAII(problem); - // Algorithm parameters - int populationSize = 100; - int maxEvaluations = 25000; - algorithm->setInputParameter("populationSize",&populationSize); - algorithm->setInputParameter("maxEvaluations",&maxEvaluations); + // Algorithm parameters + int populationSize = 100; + int maxEvaluations = 25000; + algorithm->setInputParameter("populationSize",&populationSize); + algorithm->setInputParameter("maxEvaluations",&maxEvaluations); - // Mutation and Crossover for Real codification - map parameters; + // Mutation and Crossover for Real codification + map parameters; - double crossoverProbability = 0.9; - double crossoverDistributionIndex = 20.0; - parameters["probability"] = &crossoverProbability; - parameters["distributionIndex"] = &crossoverDistributionIndex; - crossover = new SBXCrossover(parameters); + double crossoverProbability = 0.9; + double crossoverDistributionIndex = 20.0; + parameters["probability"] = &crossoverProbability; + parameters["distributionIndex"] = &crossoverDistributionIndex; + crossover = new SBXCrossover(parameters); - parameters.clear(); - double mutationProbability = 1.0/problem->getNumberOfVariables(); - double mutationDistributionIndex = 20.0; - parameters["probability"] = &mutationProbability; - parameters["distributionIndex"] = &mutationDistributionIndex; - mutation = new PolynomialMutation(parameters); + parameters.clear(); + double mutationProbability = 1.0/problem->getNumberOfVariables(); + double mutationDistributionIndex = 20.0; + parameters["probability"] = &mutationProbability; + parameters["distributionIndex"] = &mutationDistributionIndex; + mutation = new PolynomialMutation(parameters); - // Selection Operator - parameters.clear(); - selection = new BinaryTournament2(parameters); + // Selection Operator + parameters.clear(); + selection = new BinaryTournament2(parameters); - // Add the operators to the algorithm - algorithm->addOperator("crossover",crossover); - algorithm->addOperator("mutation",mutation); - algorithm->addOperator("selection",selection); + // Add the operators to the algorithm + algorithm->addOperator("crossover",crossover); + algorithm->addOperator("mutation",mutation); + algorithm->addOperator("selection",selection); - // Add the indicator object to the algorithm + // Add the indicator object to the algorithm // algorithm->setInputParameter("indicators", indicators) ; - // Execute the Algorithm - t_ini = clock(); - SolutionSet * population = algorithm->execute(); - t_fin = clock(); - double secs = (double) (t_fin - t_ini); - secs = secs / CLOCKS_PER_SEC; - - // Result messages - cout << "Total execution time: " << secs << "s" << endl; - cout << "Variables values have been written to file VAR" << endl; - population->printVariablesToFile("VAR"); - cout << "Objectives values have been written to file FUN" << endl; - population->printObjectivesToFile("FUN"); - + // Execute the Algorithm + t_ini = clock(); + SolutionSet * population = algorithm->execute(); + t_fin = clock(); + double secs = (double) (t_fin - t_ini); + secs = secs / CLOCKS_PER_SEC; + + // Result messages + cout << "Total execution time: " << secs << "s" << endl; + cout << "Variables values have been written to file VAR" << endl; + population->printVariablesToFile("VAR"); + cout << "Objectives values have been written to file FUN" << endl; + population->printObjectivesToFile("FUN"); + // if (indicators != NULL) { // cout << "Quality indicators" << endl; // cout << "Hypervolume: " << indicators->getHypervolume(population) << endl; @@ -126,15 +130,15 @@ int main(int argc, char ** argv) { // cout << "IGD : " << indicators->getIGD(population) << endl; // cout << "Spread : " << indicators->getSpread(population) << endl; // cout << "Epsilon : " << indicators->getEpsilon(population) << endl; -// +// // int evaluations = *(int *) algorithm->getOutputParameter("evaluations");; // cout << "Speed : " << evaluations << " evaluations" << endl; // } // if - delete selection; - delete mutation; - delete crossover; - delete population; - delete algorithm; + delete selection; + delete mutation; + delete crossover; + delete population; + delete algorithm; } // main diff --git a/src/main/NSGAIIbin_main.cpp b/src/main/NSGAIIbin_main.cpp index 49af279..22e0fa4 100644 --- a/src/main/NSGAIIbin_main.cpp +++ b/src/main/NSGAIIbin_main.cpp @@ -33,91 +33,95 @@ /** * Class implementing the NSGA-II algorithm -> binary encoding version */ -int main(int argc, char ** argv) { - - clock_t t_ini, t_fin; - - Problem * problem ; // The problem to solve - Algorithm * algorithm ; // The algorithm to use - Operator * crossover ; // Crossover operator - Operator * mutation ; // Mutation operator - Operator * selection ; // Selection operator - - if (argc>=2) { - problem = ProblemFactory::getProblem(argc, argv); - cout << "Selected problem: " << problem->getName() << endl; - } else { - - cout << "No problem selected." << endl; - cout << "Default problem will be used: OneMax" << endl; - - char ** argv = new char*[2]; - argv[0] = new char[3]; - strcpy(argv[0], "200"); - argv[1] = new char[1]; - strcpy(argv[1], "2"); - char * problemName = new char[7]; - strcpy(problemName, "OneMax"); - - problem = ProblemFactory::getProblem(problemName, 2, argv); - - delete argv[0]; - delete argv[1]; - delete [] argv; - delete [] problemName; - - } - - algorithm = new NSGAII(problem); - - // Algorithm parameters - int populationSize = 100; - int maxEvaluations = 25000; - algorithm->setInputParameter("populationSize",&populationSize); - algorithm->setInputParameter("maxEvaluations",&maxEvaluations); - - map parameters; - - // Mutation operator - parameters.clear(); - double mutationProbability = 1.0/problem->getNumberOfBits(); - parameters["probability"] = &mutationProbability; - mutation = new BitFlipMutation(parameters); - - // Crossover operator - parameters.clear(); - double crossoverProbability = 0.9; - parameters["probability"] = &crossoverProbability; - crossover = new SinglePointCrossover(parameters); - - // Selection Operator - parameters.clear(); - selection = new BinaryTournament2(parameters) ; - - // Add the operators to the algorithm - algorithm->addOperator("crossover",crossover); - algorithm->addOperator("mutation",mutation); - algorithm->addOperator("selection",selection); - - // Execute the Algorithm - t_ini = clock(); - SolutionSet * population = algorithm->execute(); - t_fin = clock(); - double secs = (double) (t_fin - t_ini); - secs = secs / CLOCKS_PER_SEC; - - // Result messages - cout << "Total execution time: " << secs << "s" << endl; - cout << "Variables values have been written to file VAR" << endl; - population->printVariablesToFile("VAR"); - cout << "Objectives values have been written to file FUN" << endl; - population->printObjectivesToFile("FUN"); - - delete selection; - delete mutation; - delete crossover; - delete population; - delete algorithm; +int main(int argc, char ** argv) +{ + + clock_t t_ini, t_fin; + + Problem * problem ; // The problem to solve + Algorithm * algorithm ; // The algorithm to use + Operator * crossover ; // Crossover operator + Operator * mutation ; // Mutation operator + Operator * selection ; // Selection operator + + if (argc>=2) + { + problem = ProblemFactory::getProblem(argc, argv); + cout << "Selected problem: " << problem->getName() << endl; + } + else + { + + cout << "No problem selected." << endl; + cout << "Default problem will be used: OneMax" << endl; + + char ** argv = new char*[2]; + argv[0] = new char[3]; + strcpy(argv[0], "200"); + argv[1] = new char[1]; + strcpy(argv[1], "2"); + char * problemName = new char[7]; + strcpy(problemName, "OneMax"); + + problem = ProblemFactory::getProblem(problemName, 2, argv); + + delete argv[0]; + delete argv[1]; + delete [] argv; + delete [] problemName; + + } + + algorithm = new NSGAII(problem); + + // Algorithm parameters + int populationSize = 100; + int maxEvaluations = 25000; + algorithm->setInputParameter("populationSize",&populationSize); + algorithm->setInputParameter("maxEvaluations",&maxEvaluations); + + map parameters; + + // Mutation operator + parameters.clear(); + double mutationProbability = 1.0/problem->getNumberOfBits(); + parameters["probability"] = &mutationProbability; + mutation = new BitFlipMutation(parameters); + + // Crossover operator + parameters.clear(); + double crossoverProbability = 0.9; + parameters["probability"] = &crossoverProbability; + crossover = new SinglePointCrossover(parameters); + + // Selection Operator + parameters.clear(); + selection = new BinaryTournament2(parameters) ; + + // Add the operators to the algorithm + algorithm->addOperator("crossover",crossover); + algorithm->addOperator("mutation",mutation); + algorithm->addOperator("selection",selection); + + // Execute the Algorithm + t_ini = clock(); + SolutionSet * population = algorithm->execute(); + t_fin = clock(); + double secs = (double) (t_fin - t_ini); + secs = secs / CLOCKS_PER_SEC; + + // Result messages + cout << "Total execution time: " << secs << "s" << endl; + cout << "Variables values have been written to file VAR" << endl; + population->printVariablesToFile("VAR"); + cout << "Objectives values have been written to file FUN" << endl; + population->printObjectivesToFile("FUN"); + + delete selection; + delete mutation; + delete crossover; + delete population; + delete algorithm; } // main diff --git a/src/main/OMOPSO_main.cpp b/src/main/OMOPSO_main.cpp index 9a4272e..9878b42 100644 --- a/src/main/OMOPSO_main.cpp +++ b/src/main/OMOPSO_main.cpp @@ -36,84 +36,89 @@ /** * Method for configuring and running the OMOPSO algorithm */ -int main(int argc, char ** argv) { - - clock_t t_ini, t_fin; - - Problem *problem; // The problem to solve - Algorithm *algorithm; // The algorithm to use - Mutation *uniformMutation; - Mutation *nonUniformMutation; - - QualityIndicator *indicators ; // Object to get quality indicators - - map parameters; // Operator parameters - - indicators = NULL; - - if (argc>=2) { - problem = ProblemFactory::getProblem(argc, argv); - cout << "Selected problem: " << problem->getName() << endl; - } else { - cout << "No problem selected." << endl; - cout << "Default problem will be used: Kursawe" << endl; - problem = ProblemFactory::getProblem(const_cast("Kursawe")); - } - - algorithm = new OMOPSO(problem); - - int maxIterations = 250; - double perturbationIndex = 0.5; - double mutationProbability = 1.0/problem->getNumberOfVariables(); - int swarmSize = 100; - int archiveSize = 100; - - // Algorithm parameters - algorithm->setInputParameter("swarmSize",&swarmSize); - algorithm->setInputParameter("archiveSize",&archiveSize); - algorithm->setInputParameter("maxIterations",&maxIterations); - - parameters["probability"] = &mutationProbability; - parameters["perturbation"] = &perturbationIndex; - uniformMutation = new UniformMutation(parameters); - - parameters.clear(); - parameters["probability"] = &mutationProbability; - parameters["perturbation"] = &perturbationIndex; - parameters["maxIterations"] = &maxIterations; - nonUniformMutation = new NonUniformMutation(parameters); - - - // Add the operators to the algorithm - algorithm->addOperator("uniformMutation",uniformMutation); - algorithm->addOperator("nonUniformMutation",nonUniformMutation); - - // Execute the Algorithm - t_ini = clock(); - SolutionSet * population = algorithm->execute(); - t_fin = clock(); - double secs = (double) (t_fin - t_ini); - secs = secs / CLOCKS_PER_SEC; - - // Print the results - cout << "Total execution time: " << secs << "s" << endl; - cout << "Variables values have been written to file VAR" << endl; - population->printVariablesToFile("VAR"); - cout << "Objectives values have been written to file FUN" << endl; - population->printObjectivesToFile("FUN"); - - if (indicators != NULL) { - cout << "Quality indicators" << endl ; - cout << "Hypervolume: " << indicators->getHypervolume(population) << endl; - cout << "GD : " << indicators->getGD(population) << endl ; - cout << "IGD : " << indicators->getIGD(population) << endl ; - cout << "Spread : " << indicators->getSpread(population) << endl ; - cout << "Epsilon : " << indicators->getEpsilon(population) << endl ; - } // if - - delete uniformMutation; - delete nonUniformMutation; - delete population; - delete algorithm; +int main(int argc, char ** argv) +{ + + clock_t t_ini, t_fin; + + Problem *problem; // The problem to solve + Algorithm *algorithm; // The algorithm to use + Mutation *uniformMutation; + Mutation *nonUniformMutation; + + QualityIndicator *indicators ; // Object to get quality indicators + + map parameters; // Operator parameters + + indicators = NULL; + + if (argc>=2) + { + problem = ProblemFactory::getProblem(argc, argv); + cout << "Selected problem: " << problem->getName() << endl; + } + else + { + cout << "No problem selected." << endl; + cout << "Default problem will be used: Kursawe" << endl; + problem = ProblemFactory::getProblem(const_cast("Kursawe")); + } + + algorithm = new OMOPSO(problem); + + int maxIterations = 250; + double perturbationIndex = 0.5; + double mutationProbability = 1.0/problem->getNumberOfVariables(); + int swarmSize = 100; + int archiveSize = 100; + + // Algorithm parameters + algorithm->setInputParameter("swarmSize",&swarmSize); + algorithm->setInputParameter("archiveSize",&archiveSize); + algorithm->setInputParameter("maxIterations",&maxIterations); + + parameters["probability"] = &mutationProbability; + parameters["perturbation"] = &perturbationIndex; + uniformMutation = new UniformMutation(parameters); + + parameters.clear(); + parameters["probability"] = &mutationProbability; + parameters["perturbation"] = &perturbationIndex; + parameters["maxIterations"] = &maxIterations; + nonUniformMutation = new NonUniformMutation(parameters); + + + // Add the operators to the algorithm + algorithm->addOperator("uniformMutation",uniformMutation); + algorithm->addOperator("nonUniformMutation",nonUniformMutation); + + // Execute the Algorithm + t_ini = clock(); + SolutionSet * population = algorithm->execute(); + t_fin = clock(); + double secs = (double) (t_fin - t_ini); + secs = secs / CLOCKS_PER_SEC; + + // Print the results + cout << "Total execution time: " << secs << "s" << endl; + cout << "Variables values have been written to file VAR" << endl; + population->printVariablesToFile("VAR"); + cout << "Objectives values have been written to file FUN" << endl; + population->printObjectivesToFile("FUN"); + + if (indicators != NULL) + { + cout << "Quality indicators" << endl ; + cout << "Hypervolume: " << indicators->getHypervolume(population) << endl; + cout << "GD : " << indicators->getGD(population) << endl ; + cout << "IGD : " << indicators->getIGD(population) << endl ; + cout << "Spread : " << indicators->getSpread(population) << endl ; + cout << "Epsilon : " << indicators->getEpsilon(population) << endl ; + } // if + + delete uniformMutation; + delete nonUniformMutation; + delete population; + delete algorithm; } // main diff --git a/src/main/PAES_main.cpp b/src/main/PAES_main.cpp index e184078..3c9cc7d 100644 --- a/src/main/PAES_main.cpp +++ b/src/main/PAES_main.cpp @@ -29,72 +29,76 @@ #include #include -int main(int argc, char ** argv) { - - clock_t t_ini, t_fin; - Problem * problem ; // The problem to solve - Algorithm * algorithm ; // The algorithm to use - Operator * mutation ; // Mutation operator - - if (argc>=2) { - problem = ProblemFactory::getProblem(argc, argv); - cout << "Selected problem: " << problem->getName() << endl; - } else { - cout << "No problem selected." << endl; - cout << "Default problem will be used: Fonseca" << endl; - problem = ProblemFactory::getProblem(const_cast("Fonseca")); - } - - //QualityIndicator indicators ; // Object to get quality indicators - - algorithm = new paes(problem); - - // Algorithm parameters - int archiveSizeValue = 100; - int *archiveSizePtr = &archiveSizeValue; - int biSectionsValue = 5; - int *biSectionsPtr = &biSectionsValue; - int maxEvaluationsValue = 25000; - int *maxEvaluationsPtr = &maxEvaluationsValue; - - algorithm->setInputParameter("archiveSize",archiveSizePtr); - algorithm->setInputParameter("biSections",biSectionsPtr); - algorithm->setInputParameter("maxEvaluations",maxEvaluationsPtr); - - // Mutation (Real variables) - map parameters; // Operator parameters - parameters.clear(); - double probabilityValue1 = 1.0/problem->getNumberOfVariables(); - double *probabilityPtr1 = &probabilityValue1; - double distributionIndexValue1 = 20.0; - double *distributionIndexPtr1 = &distributionIndexValue1; - parameters["probability"] = probabilityPtr1 ; - parameters["distributionIndex"] = distributionIndexPtr1 ; - mutation = new PolynomialMutation(parameters); - - // Mutation (BinaryReal variables) - //mutation = MutationFactory.getMutationOperator("BitFlipMutation"); - //mutation.setParameter("probability",0.1); - algorithm->addOperator("mutation",mutation); - - // Checking parameters - //cout << "PolynomialMutation:" << endl; - //cout << *(double *) algorithm->getOperator("mutation")->getParameter("probability") << endl; - //cout << *(double *) algorithm->getOperator("mutation")->getParameter("distributionIndex") << endl; - - t_ini = clock(); - SolutionSet * population = algorithm->execute(); - t_fin = clock(); - double secs = (double) (t_fin - t_ini); - secs = secs / CLOCKS_PER_SEC; - - // Result messages - cout << "Total execution time: " << secs << "s" << endl; - cout << "Variables values have been writen to file VAR" << endl; - population->printVariablesToFile("VAR"); - cout << "Objectives values have been writen to file FUN" << endl; - population->printObjectivesToFile("FUN"); - +int main(int argc, char ** argv) +{ + + clock_t t_ini, t_fin; + Problem * problem ; // The problem to solve + Algorithm * algorithm ; // The algorithm to use + Operator * mutation ; // Mutation operator + + if (argc>=2) + { + problem = ProblemFactory::getProblem(argc, argv); + cout << "Selected problem: " << problem->getName() << endl; + } + else + { + cout << "No problem selected." << endl; + cout << "Default problem will be used: Fonseca" << endl; + problem = ProblemFactory::getProblem(const_cast("Fonseca")); + } + + //QualityIndicator indicators ; // Object to get quality indicators + + algorithm = new paes(problem); + + // Algorithm parameters + int archiveSizeValue = 100; + int *archiveSizePtr = &archiveSizeValue; + int biSectionsValue = 5; + int *biSectionsPtr = &biSectionsValue; + int maxEvaluationsValue = 25000; + int *maxEvaluationsPtr = &maxEvaluationsValue; + + algorithm->setInputParameter("archiveSize",archiveSizePtr); + algorithm->setInputParameter("biSections",biSectionsPtr); + algorithm->setInputParameter("maxEvaluations",maxEvaluationsPtr); + + // Mutation (Real variables) + map parameters; // Operator parameters + parameters.clear(); + double probabilityValue1 = 1.0/problem->getNumberOfVariables(); + double *probabilityPtr1 = &probabilityValue1; + double distributionIndexValue1 = 20.0; + double *distributionIndexPtr1 = &distributionIndexValue1; + parameters["probability"] = probabilityPtr1 ; + parameters["distributionIndex"] = distributionIndexPtr1 ; + mutation = new PolynomialMutation(parameters); + + // Mutation (BinaryReal variables) + //mutation = MutationFactory.getMutationOperator("BitFlipMutation"); + //mutation.setParameter("probability",0.1); + algorithm->addOperator("mutation",mutation); + + // Checking parameters + //cout << "PolynomialMutation:" << endl; + //cout << *(double *) algorithm->getOperator("mutation")->getParameter("probability") << endl; + //cout << *(double *) algorithm->getOperator("mutation")->getParameter("distributionIndex") << endl; + + t_ini = clock(); + SolutionSet * population = algorithm->execute(); + t_fin = clock(); + double secs = (double) (t_fin - t_ini); + secs = secs / CLOCKS_PER_SEC; + + // Result messages + cout << "Total execution time: " << secs << "s" << endl; + cout << "Variables values have been writen to file VAR" << endl; + population->printVariablesToFile("VAR"); + cout << "Objectives values have been writen to file FUN" << endl; + population->printObjectivesToFile("FUN"); + // if (indicators != NULL) { // cout << "Quality indicators" << endl; // cout << "Hypervolume: " << indicators->getHypervolume(population) << endl; @@ -102,11 +106,11 @@ int main(int argc, char ** argv) { // cout << "IGD : " << indicators->getIGD(population) << endl; // cout << "Spread : " << indicators->getSpread(population) << endl; // cout << "Epsilon : " << indicators->getEpsilon(population) << endl; -// +// // int evaluations = *(int *) algorithm->getOutputParameter("evaluations");; // cout << "Speed : " << evaluations << " evaluations" << endl; // } // if - + } // main diff --git a/src/main/PSO_main.cpp b/src/main/PSO_main.cpp index 3e23431..3123611 100644 --- a/src/main/PSO_main.cpp +++ b/src/main/PSO_main.cpp @@ -27,58 +27,62 @@ #include #include -int main(int argc, char ** argv) { +int main(int argc, char ** argv) +{ - clock_t t_ini, t_fin; + clock_t t_ini, t_fin; - Problem * problem ; // The problem to solve - Algorithm * algorithm ; // The algorithm to use - Operator * mutation ; // Mutation operator + Problem * problem ; // The problem to solve + Algorithm * algorithm ; // The algorithm to use + Operator * mutation ; // Mutation operator - if (argc>=2) { - problem = ProblemFactory::getProblem(argc, argv); - cout << "Selected problem: " << problem->getName() << endl; - } else { - cout << "No problem selected." << endl; - cout << "Default problem will be used: Sphere" << endl; - problem = ProblemFactory::getProblem(const_cast("Sphere")); - } + if (argc>=2) + { + problem = ProblemFactory::getProblem(argc, argv); + cout << "Selected problem: " << problem->getName() << endl; + } + else + { + cout << "No problem selected." << endl; + cout << "Default problem will be used: Sphere" << endl; + problem = ProblemFactory::getProblem(const_cast("Sphere")); + } - algorithm = new PSO(problem); + algorithm = new PSO(problem); - // Algorithm parameters - int swarmSize = 50; - int maxIterations = 5000; - algorithm->setInputParameter("swarmSize",&swarmSize); - algorithm->setInputParameter("maxIterations",&maxIterations); + // Algorithm parameters + int swarmSize = 50; + int maxIterations = 5000; + algorithm->setInputParameter("swarmSize",&swarmSize); + algorithm->setInputParameter("maxIterations",&maxIterations); - // Mutation operator - map parameters; - double probability = 1.0/problem->getNumberOfVariables(); - double distributionIndex = 20.0; - parameters["probability"] = &probability; - parameters["distributionIndex"] = &distributionIndex; - mutation = new PolynomialMutation(parameters); + // Mutation operator + map parameters; + double probability = 1.0/problem->getNumberOfVariables(); + double distributionIndex = 20.0; + parameters["probability"] = &probability; + parameters["distributionIndex"] = &distributionIndex; + mutation = new PolynomialMutation(parameters); - // Add the operators to the algorithm - algorithm->addOperator("mutation",mutation); + // Add the operators to the algorithm + algorithm->addOperator("mutation",mutation); - // Execute the Algorithm - t_ini = clock(); - SolutionSet * population = algorithm->execute(); - t_fin = clock(); - double secs = (double) (t_fin - t_ini); - secs = secs / CLOCKS_PER_SEC; + // Execute the Algorithm + t_ini = clock(); + SolutionSet * population = algorithm->execute(); + t_fin = clock(); + double secs = (double) (t_fin - t_ini); + secs = secs / CLOCKS_PER_SEC; - // Result messages - cout << "Total execution time: " << secs << "s" << endl; - cout << "Variables values have been written to file VAR" << endl; - population->printVariablesToFile("VAR"); - cout << "Objectives values have been written to file FUN" << endl; - population->printObjectivesToFile("FUN"); + // Result messages + cout << "Total execution time: " << secs << "s" << endl; + cout << "Variables values have been written to file VAR" << endl; + population->printVariablesToFile("VAR"); + cout << "Objectives values have been written to file FUN" << endl; + population->printObjectivesToFile("FUN"); - delete mutation; - delete population; - delete algorithm; + delete mutation; + delete population; + delete algorithm; } // main diff --git a/src/main/SMPSO_main.cpp b/src/main/SMPSO_main.cpp index e21a78a..61835a0 100644 --- a/src/main/SMPSO_main.cpp +++ b/src/main/SMPSO_main.cpp @@ -37,66 +37,70 @@ * (MCDM 2009), pp: 66-73. March 2009 */ -int main(int argc, char ** argv) { - - clock_t t_ini, t_fin; - - Problem * problem; // The problem to solve - Algorithm * algorithm; // The algorithm to use - Operator * mutation; // "Turbulence" operator - - map parameters; // Operator parameters - - //TODO: QualityIndicator * indicators; // Object to get quality indicators - - if (argc>=2) { - problem = ProblemFactory::getProblem(argc, argv); - cout << "Selected problem: " << problem->getName() << endl; - } else { - cout << "No problem selected." << endl; - cout << "Default problem will be used: Kursawe" << endl; - problem = ProblemFactory::getProblem(const_cast("Kursawe")); - } - - algorithm = new SMPSO(problem); - - // Algorithm parameters - int swarmSizeValue = 100; - int archiveSizeValue = 100; - int maxIterationsValue = 250; - algorithm->setInputParameter("swarmSize",&swarmSizeValue); - algorithm->setInputParameter("archiveSize",&archiveSizeValue); - algorithm->setInputParameter("maxIterations",&maxIterationsValue); - - // Mutation operator - double probabilityParameter = 1.0/(problem->getNumberOfVariables()); - double distributionIndexParameter = 20.0; - parameters["probability"] = &probabilityParameter; - parameters["distributionIndex"] = &distributionIndexParameter; - mutation = new PolynomialMutation(parameters); - - // Add the operators to the algorithm - algorithm->addOperator("mutation",mutation); - - // Add the indicator object to the algorithm - //algorithm->setInputParameter("indicators", indicators) ; - - // Execute the Algorithm - t_ini = clock(); - SolutionSet * population = algorithm->execute(); - t_fin = clock(); - double secs = (double) (t_fin - t_ini); - secs = secs / CLOCKS_PER_SEC; - - // Result messages - cout << "Total execution time: " << secs << "s" << endl; - cout << "Variables values have been written to file VAR" << endl; - population->printVariablesToFile("VAR"); - cout << "Objectives values have been written to file FUN" << endl; - population->printObjectivesToFile("FUN"); - - delete mutation; - delete population; - delete algorithm; +int main(int argc, char ** argv) +{ + + clock_t t_ini, t_fin; + + Problem * problem; // The problem to solve + Algorithm * algorithm; // The algorithm to use + Operator * mutation; // "Turbulence" operator + + map parameters; // Operator parameters + + //TODO: QualityIndicator * indicators; // Object to get quality indicators + + if (argc>=2) + { + problem = ProblemFactory::getProblem(argc, argv); + cout << "Selected problem: " << problem->getName() << endl; + } + else + { + cout << "No problem selected." << endl; + cout << "Default problem will be used: Kursawe" << endl; + problem = ProblemFactory::getProblem(const_cast("Kursawe")); + } + + algorithm = new SMPSO(problem); + + // Algorithm parameters + int swarmSizeValue = 100; + int archiveSizeValue = 100; + int maxIterationsValue = 250; + algorithm->setInputParameter("swarmSize",&swarmSizeValue); + algorithm->setInputParameter("archiveSize",&archiveSizeValue); + algorithm->setInputParameter("maxIterations",&maxIterationsValue); + + // Mutation operator + double probabilityParameter = 1.0/(problem->getNumberOfVariables()); + double distributionIndexParameter = 20.0; + parameters["probability"] = &probabilityParameter; + parameters["distributionIndex"] = &distributionIndexParameter; + mutation = new PolynomialMutation(parameters); + + // Add the operators to the algorithm + algorithm->addOperator("mutation",mutation); + + // Add the indicator object to the algorithm + //algorithm->setInputParameter("indicators", indicators) ; + + // Execute the Algorithm + t_ini = clock(); + SolutionSet * population = algorithm->execute(); + t_fin = clock(); + double secs = (double) (t_fin - t_ini); + secs = secs / CLOCKS_PER_SEC; + + // Result messages + cout << "Total execution time: " << secs << "s" << endl; + cout << "Variables values have been written to file VAR" << endl; + population->printVariablesToFile("VAR"); + cout << "Objectives values have been written to file FUN" << endl; + population->printObjectivesToFile("FUN"); + + delete mutation; + delete population; + delete algorithm; } // main diff --git a/src/main/SMPSOhv_main.cpp b/src/main/SMPSOhv_main.cpp index 0c96b80..7cd2999 100644 --- a/src/main/SMPSOhv_main.cpp +++ b/src/main/SMPSOhv_main.cpp @@ -40,75 +40,80 @@ * IEEE Congress on Evolutionary Computation 2013: 3153-3160 */ -int main(int argc, char ** argv) { - - clock_t t_ini, t_fin; - - Problem *problem; // The problem to solve - Algorithm *algorithm; // The algorithm to use - Mutation *mutation; - - QualityIndicator *indicators ; // Object to get quality indicators - - map parameters; // Operator parameters - - indicators = NULL; - - if (argc>=2) { - problem = ProblemFactory::getProblem(argc, argv); - cout << "Selected problem: " << problem->getName() << endl; - } else { - cout << "No problem selected." << endl; - cout << "Default problem will be used: Kursawe" << endl; - problem = ProblemFactory::getProblem(const_cast("Kursawe")); - } - - algorithm = new SMPSOhv(problem); - - int maxIterations = 250; - int swarmSize = 100; - int archiveSize = 100; - - double distributionIndex = 20.0; - double mutationProbability = 1.0/problem->getNumberOfVariables(); - - // Algorithm parameters - algorithm->setInputParameter("swarmSize",&swarmSize); - algorithm->setInputParameter("archiveSize",&archiveSize); - algorithm->setInputParameter("maxIterations",&maxIterations); - - parameters["probability"] = &mutationProbability; - parameters["distributionIndex"] = &distributionIndex; - mutation = new PolynomialMutation(parameters); - - // Add the operators to the algorithm - algorithm->addOperator("mutation",mutation); - - // Execute the Algorithm - t_ini = clock(); - SolutionSet * population = algorithm->execute(); - t_fin = clock(); - double secs = (double) (t_fin - t_ini); - secs = secs / CLOCKS_PER_SEC; - - // Print the results - cout << "Total execution time: " << secs << "s" << endl; - cout << "Variables values have been written to file VAR" << endl; - population->printVariablesToFile("VAR"); - cout << "Objectives values have been written to file FUN" << endl; - population->printObjectivesToFile("FUN"); - - if (indicators != NULL) { - cout << "Quality indicators" << endl ; - cout << "Hypervolume: " << indicators->getHypervolume(population) << endl; - cout << "GD : " << indicators->getGD(population) << endl ; - cout << "IGD : " << indicators->getIGD(population) << endl ; - cout << "Spread : " << indicators->getSpread(population) << endl ; - cout << "Epsilon : " << indicators->getEpsilon(population) << endl ; - } // if - - delete mutation; - delete population; - delete algorithm; +int main(int argc, char ** argv) +{ + + clock_t t_ini, t_fin; + + Problem *problem; // The problem to solve + Algorithm *algorithm; // The algorithm to use + Mutation *mutation; + + QualityIndicator *indicators ; // Object to get quality indicators + + map parameters; // Operator parameters + + indicators = NULL; + + if (argc>=2) + { + problem = ProblemFactory::getProblem(argc, argv); + cout << "Selected problem: " << problem->getName() << endl; + } + else + { + cout << "No problem selected." << endl; + cout << "Default problem will be used: Kursawe" << endl; + problem = ProblemFactory::getProblem(const_cast("Kursawe")); + } + + algorithm = new SMPSOhv(problem); + + int maxIterations = 250; + int swarmSize = 100; + int archiveSize = 100; + + double distributionIndex = 20.0; + double mutationProbability = 1.0/problem->getNumberOfVariables(); + + // Algorithm parameters + algorithm->setInputParameter("swarmSize",&swarmSize); + algorithm->setInputParameter("archiveSize",&archiveSize); + algorithm->setInputParameter("maxIterations",&maxIterations); + + parameters["probability"] = &mutationProbability; + parameters["distributionIndex"] = &distributionIndex; + mutation = new PolynomialMutation(parameters); + + // Add the operators to the algorithm + algorithm->addOperator("mutation",mutation); + + // Execute the Algorithm + t_ini = clock(); + SolutionSet * population = algorithm->execute(); + t_fin = clock(); + double secs = (double) (t_fin - t_ini); + secs = secs / CLOCKS_PER_SEC; + + // Print the results + cout << "Total execution time: " << secs << "s" << endl; + cout << "Variables values have been written to file VAR" << endl; + population->printVariablesToFile("VAR"); + cout << "Objectives values have been written to file FUN" << endl; + population->printObjectivesToFile("FUN"); + + if (indicators != NULL) + { + cout << "Quality indicators" << endl ; + cout << "Hypervolume: " << indicators->getHypervolume(population) << endl; + cout << "GD : " << indicators->getGD(population) << endl ; + cout << "IGD : " << indicators->getIGD(population) << endl ; + cout << "Spread : " << indicators->getSpread(population) << endl ; + cout << "Epsilon : " << indicators->getEpsilon(population) << endl ; + } // if + + delete mutation; + delete population; + delete algorithm; } // main diff --git a/src/main/SMSEMOA_main.cpp b/src/main/SMSEMOA_main.cpp index cad8716..41f2992 100755 --- a/src/main/SMSEMOA_main.cpp +++ b/src/main/SMSEMOA_main.cpp @@ -32,88 +32,92 @@ -int main(int argc, char ** argv) { - - clock_t t_ini, t_fin; - - Problem * problem ; // The problem to solve - Algorithm * algorithm ; // The algorithm to use - Operator * crossover ; // Crossover operator - Operator * mutation ; // Mutation operator - Operator * selection ; // Selection operator - - if (argc>=2) { - problem = ProblemFactory::getProblem(argc, argv); - cout << "Selected problem: " << problem->getName() << endl; - } else { - cout << "No problem selected." << endl; - cout << "Default problem will be used: Fonseca" << endl; - problem = ProblemFactory::getProblem(const_cast("Fonseca")); - } - - //TODO: Quality Indicators - //QualityIndicator indicators ; // Object to get quality indicators - //indicators = null ; - - algorithm = new SMSEMOA(problem); - - // Algorithm parameters - int populationSize = 100; - int maxEvaluations = 25000; - double offset = 100; - - algorithm->setInputParameter("populationSize",&populationSize); - algorithm->setInputParameter("maxEvaluations",&maxEvaluations); - algorithm->setInputParameter("offset",&offset); - - // Mutation - map parameters; - double crossoverProbability = 0.9; - double crossoverDistributionIndex = 20.0; - parameters["probability"] = &crossoverProbability; - parameters["distributionIndex"] = &crossoverDistributionIndex; - crossover = new SBXCrossover(parameters); - - //Crossover - parameters.clear(); - double mutationProbability = 1.0/problem->getNumberOfVariables(); - double mutationDistributionIndex = 20.0; - parameters["probability"] = &mutationProbability; - parameters["distributionIndex"] = &mutationDistributionIndex; - mutation = new PolynomialMutation(parameters); - - // Selection Operator - parameters.clear(); - selection = new RandomSelection(parameters); - - // Add the operators to the algorithm - algorithm->addOperator("crossover",crossover); - algorithm->addOperator("mutation",mutation); - algorithm->addOperator("selection",selection); - - // Add the indicator object to the algorithm - //algorithm->setInputParameter("indicators", indicators) ; - - // Execute the Algorithm - t_ini = clock(); - - SolutionSet * population = algorithm->execute(); - - t_fin = clock(); - double secs = (double) (t_fin - t_ini); - secs = secs / CLOCKS_PER_SEC; - - // Result messages - cout << "Total execution time: " << secs << "s" << endl; - cout << "Variables values have been written to file VAR" << endl; - population->printVariablesToFile("VAR"); - cout << "Objectives values have been written to file FUN" << endl; - population->printObjectivesToFile("FUN"); - - delete mutation; - delete crossover; - delete selection; - delete population; - delete algorithm; +int main(int argc, char ** argv) +{ + + clock_t t_ini, t_fin; + + Problem * problem ; // The problem to solve + Algorithm * algorithm ; // The algorithm to use + Operator * crossover ; // Crossover operator + Operator * mutation ; // Mutation operator + Operator * selection ; // Selection operator + + if (argc>=2) + { + problem = ProblemFactory::getProblem(argc, argv); + cout << "Selected problem: " << problem->getName() << endl; + } + else + { + cout << "No problem selected." << endl; + cout << "Default problem will be used: Fonseca" << endl; + problem = ProblemFactory::getProblem(const_cast("Fonseca")); + } + + //TODO: Quality Indicators + //QualityIndicator indicators ; // Object to get quality indicators + //indicators = null ; + + algorithm = new SMSEMOA(problem); + + // Algorithm parameters + int populationSize = 100; + int maxEvaluations = 25000; + double offset = 100; + + algorithm->setInputParameter("populationSize",&populationSize); + algorithm->setInputParameter("maxEvaluations",&maxEvaluations); + algorithm->setInputParameter("offset",&offset); + + // Mutation + map parameters; + double crossoverProbability = 0.9; + double crossoverDistributionIndex = 20.0; + parameters["probability"] = &crossoverProbability; + parameters["distributionIndex"] = &crossoverDistributionIndex; + crossover = new SBXCrossover(parameters); + + //Crossover + parameters.clear(); + double mutationProbability = 1.0/problem->getNumberOfVariables(); + double mutationDistributionIndex = 20.0; + parameters["probability"] = &mutationProbability; + parameters["distributionIndex"] = &mutationDistributionIndex; + mutation = new PolynomialMutation(parameters); + + // Selection Operator + parameters.clear(); + selection = new RandomSelection(parameters); + + // Add the operators to the algorithm + algorithm->addOperator("crossover",crossover); + algorithm->addOperator("mutation",mutation); + algorithm->addOperator("selection",selection); + + // Add the indicator object to the algorithm + //algorithm->setInputParameter("indicators", indicators) ; + + // Execute the Algorithm + t_ini = clock(); + + SolutionSet * population = algorithm->execute(); + + t_fin = clock(); + double secs = (double) (t_fin - t_ini); + secs = secs / CLOCKS_PER_SEC; + + // Result messages + cout << "Total execution time: " << secs << "s" << endl; + cout << "Variables values have been written to file VAR" << endl; + population->printVariablesToFile("VAR"); + cout << "Objectives values have been written to file FUN" << endl; + population->printObjectivesToFile("FUN"); + + delete mutation; + delete crossover; + delete selection; + delete population; + delete algorithm; } // main diff --git a/src/main/StandardPSO2007_main.cpp b/src/main/StandardPSO2007_main.cpp index ddb0aeb..84c8242 100644 --- a/src/main/StandardPSO2007_main.cpp +++ b/src/main/StandardPSO2007_main.cpp @@ -28,48 +28,52 @@ #include #include -int main(int argc, char ** argv) { +int main(int argc, char ** argv) +{ - clock_t t_ini, t_fin; + clock_t t_ini, t_fin; - Problem * problem ; // The problem to solve - Algorithm * algorithm ; // The algorithm to use - //Operator * mutation ; // "Turbulence" operator + Problem * problem ; // The problem to solve + Algorithm * algorithm ; // The algorithm to use + //Operator * mutation ; // "Turbulence" operator - if (argc>=2) { - problem = ProblemFactory::getProblem(argc, argv); - cout << "Selected problem: " << problem->getName() << endl; - } else { - cout << "No problem selected." << endl; - cout << "Default problem will be used: Sphere" << endl; - problem = ProblemFactory::getProblem(const_cast("Sphere")); - } + if (argc>=2) + { + problem = ProblemFactory::getProblem(argc, argv); + cout << "Selected problem: " << problem->getName() << endl; + } + else + { + cout << "No problem selected." << endl; + cout << "Default problem will be used: Sphere" << endl; + problem = ProblemFactory::getProblem(const_cast("Sphere")); + } - algorithm = new StandardPSO2007(problem); + algorithm = new StandardPSO2007(problem); - // Algorithm parameters - int swarmSize = 10 + (int) (2 * sqrt(problem->getNumberOfVariables())); - int maxIterations = 80000; - int numberOfParticlesToInform = 3; - algorithm->setInputParameter("swarmSize",&swarmSize); - algorithm->setInputParameter("maxIterations",&maxIterations); - algorithm->setInputParameter("numberOfParticlesToInform", &numberOfParticlesToInform); + // Algorithm parameters + int swarmSize = 10 + (int) (2 * sqrt(problem->getNumberOfVariables())); + int maxIterations = 80000; + int numberOfParticlesToInform = 3; + algorithm->setInputParameter("swarmSize",&swarmSize); + algorithm->setInputParameter("maxIterations",&maxIterations); + algorithm->setInputParameter("numberOfParticlesToInform", &numberOfParticlesToInform); - // Execute the Algorithm - t_ini = clock(); - SolutionSet * population = algorithm->execute(); - t_fin = clock(); - double secs = (double) (t_fin - t_ini); - secs = secs / CLOCKS_PER_SEC; + // Execute the Algorithm + t_ini = clock(); + SolutionSet * population = algorithm->execute(); + t_fin = clock(); + double secs = (double) (t_fin - t_ini); + secs = secs / CLOCKS_PER_SEC; - // Result messages - cout << "Total execution time: " << secs << "s" << endl; - cout << "Variables values have been written to file VAR" << endl; - population->printVariablesToFile("VAR"); - cout << "Objectives values have been written to file FUN" << endl; - population->printObjectivesToFile("FUN"); + // Result messages + cout << "Total execution time: " << secs << "s" << endl; + cout << "Variables values have been written to file VAR" << endl; + population->printVariablesToFile("VAR"); + cout << "Objectives values have been written to file FUN" << endl; + population->printObjectivesToFile("FUN"); - delete population; - delete algorithm; + delete population; + delete algorithm; } // main diff --git a/src/main/StandardPSO2011_main.cpp b/src/main/StandardPSO2011_main.cpp index 06401b8..2d202ab 100644 --- a/src/main/StandardPSO2011_main.cpp +++ b/src/main/StandardPSO2011_main.cpp @@ -28,48 +28,52 @@ #include #include -int main(int argc, char ** argv) { +int main(int argc, char ** argv) +{ - clock_t t_ini, t_fin; + clock_t t_ini, t_fin; - Problem * problem ; // The problem to solve - Algorithm * algorithm ; // The algorithm to use - //Operator * mutation ; // "Turbulence" operator + Problem * problem ; // The problem to solve + Algorithm * algorithm ; // The algorithm to use + //Operator * mutation ; // "Turbulence" operator - if (argc>=2) { - problem = ProblemFactory::getProblem(argc, argv); - cout << "Selected problem: " << problem->getName() << endl; - } else { - cout << "No problem selected." << endl; - cout << "Default problem will be used: Sphere" << endl; - problem = ProblemFactory::getProblem(const_cast("Sphere")); - } + if (argc>=2) + { + problem = ProblemFactory::getProblem(argc, argv); + cout << "Selected problem: " << problem->getName() << endl; + } + else + { + cout << "No problem selected." << endl; + cout << "Default problem will be used: Sphere" << endl; + problem = ProblemFactory::getProblem(const_cast("Sphere")); + } - algorithm = new StandardPSO2011(problem); + algorithm = new StandardPSO2011(problem); - // Algorithm parameters - int swarmSize = 100; - int maxIterations = 8000; - int numberOfParticlesToInform = 3; - algorithm->setInputParameter("swarmSize",&swarmSize); - algorithm->setInputParameter("maxIterations",&maxIterations); - algorithm->setInputParameter("numberOfParticlesToInform", &numberOfParticlesToInform); + // Algorithm parameters + int swarmSize = 100; + int maxIterations = 8000; + int numberOfParticlesToInform = 3; + algorithm->setInputParameter("swarmSize",&swarmSize); + algorithm->setInputParameter("maxIterations",&maxIterations); + algorithm->setInputParameter("numberOfParticlesToInform", &numberOfParticlesToInform); - // Execute the Algorithm - t_ini = clock(); - SolutionSet * population = algorithm->execute(); - t_fin = clock(); - double secs = (double) (t_fin - t_ini); - secs = secs / CLOCKS_PER_SEC; + // Execute the Algorithm + t_ini = clock(); + SolutionSet * population = algorithm->execute(); + t_fin = clock(); + double secs = (double) (t_fin - t_ini); + secs = secs / CLOCKS_PER_SEC; - // Result messages - cout << "Total execution time: " << secs << "s" << endl; - cout << "Variables values have been written to file VAR" << endl; - population->printVariablesToFile("VAR"); - cout << "Objectives values have been written to file FUN" << endl; - population->printObjectivesToFile("FUN"); + // Result messages + cout << "Total execution time: " << secs << "s" << endl; + cout << "Variables values have been written to file VAR" << endl; + population->printVariablesToFile("VAR"); + cout << "Objectives values have been written to file FUN" << endl; + population->printObjectivesToFile("FUN"); - delete population; - delete algorithm; + delete population; + delete algorithm; } // main diff --git a/src/main/gGA_main.cpp b/src/main/gGA_main.cpp index 2d36712..8742de1 100644 --- a/src/main/gGA_main.cpp +++ b/src/main/gGA_main.cpp @@ -29,78 +29,82 @@ #include #include -int main(int argc, char ** argv) { - - clock_t t_ini, t_fin; - - Problem * problem ; // The problem to solve - Algorithm * algorithm ; // The algorithm to use - Operator * crossover ; // Crossover operator - Operator * mutation ; // Mutation operator - Operator * selection ; // Selection operator - - if (argc>=2) { - problem = ProblemFactory::getProblem(argc, argv); - cout << "Selected problem: " << problem->getName() << endl; - } else { - cout << "No problem selected." << endl; - cout << "Default problem will be used: Sphere" << endl; - problem = ProblemFactory::getProblem(const_cast("Sphere")); - } - - algorithm = new gGA(problem); - - // Algorithm parameters - int populationSizeValue = 100; - int maxEvaluationsValue = 250000; - algorithm->setInputParameter("populationSize",&populationSizeValue); - algorithm->setInputParameter("maxEvaluations",&maxEvaluationsValue); - - // Mutation and Crossover for Real codification - map parameters; - double crossoverProbability = 0.9; - double distributionIndexValue1 = 20.0; - parameters["probability"] = &crossoverProbability ; - parameters["distributionIndex"] = &distributionIndexValue1 ; - crossover = new SBXCrossover(parameters); - - parameters.clear(); - double mutationProbability = 1.0/problem->getNumberOfVariables(); - double distributionIndexValue2 = 20.0; - parameters["probability"] = &mutationProbability; - parameters["distributionIndex"] = &distributionIndexValue2 ; - mutation = new PolynomialMutation(parameters); - - // Selection Operator - parameters.clear(); - selection = new BinaryTournament2(parameters) ; - - // Add the operators to the algorithm - algorithm->addOperator("crossover",crossover); - algorithm->addOperator("mutation",mutation); - algorithm->addOperator("selection",selection); - - // Add the indicator object to the algorithm - //algorithm->setInputParameter("indicators", indicators) ; - - // Execute the Algorithm - t_ini = clock(); - SolutionSet * population = algorithm->execute(); - t_fin = clock(); - double secs = (double) (t_fin - t_ini); - secs = secs / CLOCKS_PER_SEC; - - // Result messages - cout << "Total execution time: " << secs << "s" << endl; - cout << "Variables values have been written to file VAR" << endl; - population->printVariablesToFile("VAR"); - cout << "Objectives values have been written to file FUN" << endl; - population->printObjectivesToFile("FUN"); - - delete crossover; - delete mutation; - delete selection; - delete population; - delete algorithm; +int main(int argc, char ** argv) +{ + + clock_t t_ini, t_fin; + + Problem * problem ; // The problem to solve + Algorithm * algorithm ; // The algorithm to use + Operator * crossover ; // Crossover operator + Operator * mutation ; // Mutation operator + Operator * selection ; // Selection operator + + if (argc>=2) + { + problem = ProblemFactory::getProblem(argc, argv); + cout << "Selected problem: " << problem->getName() << endl; + } + else + { + cout << "No problem selected." << endl; + cout << "Default problem will be used: Sphere" << endl; + problem = ProblemFactory::getProblem(const_cast("Sphere")); + } + + algorithm = new gGA(problem); + + // Algorithm parameters + int populationSizeValue = 100; + int maxEvaluationsValue = 250000; + algorithm->setInputParameter("populationSize",&populationSizeValue); + algorithm->setInputParameter("maxEvaluations",&maxEvaluationsValue); + + // Mutation and Crossover for Real codification + map parameters; + double crossoverProbability = 0.9; + double distributionIndexValue1 = 20.0; + parameters["probability"] = &crossoverProbability ; + parameters["distributionIndex"] = &distributionIndexValue1 ; + crossover = new SBXCrossover(parameters); + + parameters.clear(); + double mutationProbability = 1.0/problem->getNumberOfVariables(); + double distributionIndexValue2 = 20.0; + parameters["probability"] = &mutationProbability; + parameters["distributionIndex"] = &distributionIndexValue2 ; + mutation = new PolynomialMutation(parameters); + + // Selection Operator + parameters.clear(); + selection = new BinaryTournament2(parameters) ; + + // Add the operators to the algorithm + algorithm->addOperator("crossover",crossover); + algorithm->addOperator("mutation",mutation); + algorithm->addOperator("selection",selection); + + // Add the indicator object to the algorithm + //algorithm->setInputParameter("indicators", indicators) ; + + // Execute the Algorithm + t_ini = clock(); + SolutionSet * population = algorithm->execute(); + t_fin = clock(); + double secs = (double) (t_fin - t_ini); + secs = secs / CLOCKS_PER_SEC; + + // Result messages + cout << "Total execution time: " << secs << "s" << endl; + cout << "Variables values have been written to file VAR" << endl; + population->printVariablesToFile("VAR"); + cout << "Objectives values have been written to file FUN" << endl; + population->printObjectivesToFile("FUN"); + + delete crossover; + delete mutation; + delete selection; + delete population; + delete algorithm; } // main diff --git a/src/main/gGAbin_main.cpp b/src/main/gGAbin_main.cpp index 44b8d2c..b3951a8 100644 --- a/src/main/gGAbin_main.cpp +++ b/src/main/gGAbin_main.cpp @@ -30,90 +30,94 @@ #include #include -int main(int argc, char ** argv) { - - clock_t t_ini, t_fin; - - Problem * problem ; // The problem to solve - Algorithm * algorithm ; // The algorithm to use - Operator * crossover ; // Crossover operator - Operator * mutation ; // Mutation operator - Operator * selection ; // Selection operator - - if (argc>=2) { - problem = ProblemFactory::getProblem(argc, argv); - cout << "Selected problem: " << problem->getName() << endl; - } else { - - cout << "No problem selected." << endl; - cout << "Default problem will be used: OneMax" << endl; - - char ** argv = new char*[2]; - argv[0] = new char[3]; - strcpy(argv[0], "400"); - argv[1] = new char[1]; - strcpy(argv[1], "2"); - char * problemName = new char[7]; - strcpy(problemName, "OneMax"); - - problem = ProblemFactory::getProblem(problemName, 2, argv); - - delete argv[0]; - delete argv[1]; - delete [] argv; - delete [] problemName; - - } - - algorithm = new gGA(problem); - - // Algorithm parameters - int populationSize = 100; - int maxEvaluations = 25000; - algorithm->setInputParameter("populationSize",&populationSize); - algorithm->setInputParameter("maxEvaluations",&maxEvaluations); - - map parameters; - - // Mutation operator - parameters.clear(); - double mutationProbability = 1.0/problem->getNumberOfBits(); - parameters["probability"] = &mutationProbability; - mutation = new BitFlipMutation(parameters); - - // Crossover operator - parameters.clear(); - double crossoverProbability = 0.9; - parameters["probability"] = &crossoverProbability; - crossover = new SinglePointCrossover(parameters); - - // Selection Operator - parameters.clear(); - selection = new BinaryTournament2(parameters) ; - - // Add the operators to the algorithm - algorithm->addOperator("crossover",crossover); - algorithm->addOperator("mutation",mutation); - algorithm->addOperator("selection",selection); - - // Execute the Algorithm - t_ini = clock(); - SolutionSet * population = algorithm->execute(); - t_fin = clock(); - double secs = (double) (t_fin - t_ini); - secs = secs / CLOCKS_PER_SEC; - - // Result messages - cout << "Total execution time: " << secs << "s" << endl; - cout << "Variables values have been written to file VAR" << endl; - population->printVariablesToFile("VAR"); - cout << "Objectives values have been written to file FUN" << endl; - population->printObjectivesToFile("FUN"); - - delete selection; - delete mutation; - delete crossover; - delete population; - delete algorithm; +int main(int argc, char ** argv) +{ + + clock_t t_ini, t_fin; + + Problem * problem ; // The problem to solve + Algorithm * algorithm ; // The algorithm to use + Operator * crossover ; // Crossover operator + Operator * mutation ; // Mutation operator + Operator * selection ; // Selection operator + + if (argc>=2) + { + problem = ProblemFactory::getProblem(argc, argv); + cout << "Selected problem: " << problem->getName() << endl; + } + else + { + + cout << "No problem selected." << endl; + cout << "Default problem will be used: OneMax" << endl; + + char ** argv = new char*[2]; + argv[0] = new char[3]; + strcpy(argv[0], "400"); + argv[1] = new char[1]; + strcpy(argv[1], "2"); + char * problemName = new char[7]; + strcpy(problemName, "OneMax"); + + problem = ProblemFactory::getProblem(problemName, 2, argv); + + delete argv[0]; + delete argv[1]; + delete [] argv; + delete [] problemName; + + } + + algorithm = new gGA(problem); + + // Algorithm parameters + int populationSize = 100; + int maxEvaluations = 25000; + algorithm->setInputParameter("populationSize",&populationSize); + algorithm->setInputParameter("maxEvaluations",&maxEvaluations); + + map parameters; + + // Mutation operator + parameters.clear(); + double mutationProbability = 1.0/problem->getNumberOfBits(); + parameters["probability"] = &mutationProbability; + mutation = new BitFlipMutation(parameters); + + // Crossover operator + parameters.clear(); + double crossoverProbability = 0.9; + parameters["probability"] = &crossoverProbability; + crossover = new SinglePointCrossover(parameters); + + // Selection Operator + parameters.clear(); + selection = new BinaryTournament2(parameters) ; + + // Add the operators to the algorithm + algorithm->addOperator("crossover",crossover); + algorithm->addOperator("mutation",mutation); + algorithm->addOperator("selection",selection); + + // Execute the Algorithm + t_ini = clock(); + SolutionSet * population = algorithm->execute(); + t_fin = clock(); + double secs = (double) (t_fin - t_ini); + secs = secs / CLOCKS_PER_SEC; + + // Result messages + cout << "Total execution time: " << secs << "s" << endl; + cout << "Variables values have been written to file VAR" << endl; + population->printVariablesToFile("VAR"); + cout << "Objectives values have been written to file FUN" << endl; + population->printObjectivesToFile("FUN"); + + delete selection; + delete mutation; + delete crossover; + delete population; + delete algorithm; } // main diff --git a/src/main/ssGA_main.cpp b/src/main/ssGA_main.cpp index fc90c23..f401170 100644 --- a/src/main/ssGA_main.cpp +++ b/src/main/ssGA_main.cpp @@ -30,77 +30,81 @@ #include #include -int main(int argc, char ** argv) { - - clock_t t_ini, t_fin; - - Problem * problem ; // The problem to solve - Algorithm * algorithm ; // The algorithm to use - Operator * crossover ; // Crossover operator - Operator * mutation ; // Mutation operator - Operator * selection ; // Selection operator - - if (argc>=2) { - problem = ProblemFactory::getProblem(argc, argv); - } else { - cout << "No problem selected." << endl; - cout << "Default problem will be used: Sphere" << endl; - problem = ProblemFactory::getProblem(const_cast("Sphere")); - } - - algorithm = new ssGA(problem); // Steady-state GA - - // Algorithm parameters - int populationSize = 100; - int maxEvaluations = 250000; - algorithm->setInputParameter("populationSize",&populationSize); - algorithm->setInputParameter("maxEvaluations",&maxEvaluations); - - // Mutation and Crossover for Real codification - map parameters; - double crossoverProbability = 0.9; - double distributionIndex1 = 20.0; - parameters["probability"] = &crossoverProbability ; - parameters["distributionIndex"] = &distributionIndex1 ; - crossover = new SBXCrossover(parameters); - - parameters.clear(); - double mutationProbability = 1.0/problem->getNumberOfVariables(); - double distributionIndex2 = 20.0; - parameters["probability"] = &mutationProbability; - parameters["distributionIndex"] = &distributionIndex2 ; - mutation = new PolynomialMutation(parameters); - - // Selection Operator - parameters.clear(); - selection = new BinaryTournament(parameters) ; - - // Add the operators to the algorithm - algorithm->addOperator("crossover",crossover); - algorithm->addOperator("mutation",mutation); - algorithm->addOperator("selection",selection); - - // Add the indicator object to the algorithm - //algorithm->setInputParameter("indicators", indicators) ; - - // Execute the Algorithm - t_ini = clock(); - SolutionSet * population = algorithm->execute(); - t_fin = clock(); - double secs = (double) (t_fin - t_ini); - secs = secs / CLOCKS_PER_SEC; - - // Result messages - cout << "Total execution time: " << secs << "s" << endl; - cout << "Variables values have been written to file VAR" << endl; - population->printVariablesToFile("VAR"); - cout << "Objectives values have been written to file FUN" << endl; - population->printObjectivesToFile("FUN"); - - delete crossover; - delete mutation; - delete selection; - delete population; - delete algorithm; +int main(int argc, char ** argv) +{ + + clock_t t_ini, t_fin; + + Problem * problem ; // The problem to solve + Algorithm * algorithm ; // The algorithm to use + Operator * crossover ; // Crossover operator + Operator * mutation ; // Mutation operator + Operator * selection ; // Selection operator + + if (argc>=2) + { + problem = ProblemFactory::getProblem(argc, argv); + } + else + { + cout << "No problem selected." << endl; + cout << "Default problem will be used: Sphere" << endl; + problem = ProblemFactory::getProblem(const_cast("Sphere")); + } + + algorithm = new ssGA(problem); // Steady-state GA + + // Algorithm parameters + int populationSize = 100; + int maxEvaluations = 250000; + algorithm->setInputParameter("populationSize",&populationSize); + algorithm->setInputParameter("maxEvaluations",&maxEvaluations); + + // Mutation and Crossover for Real codification + map parameters; + double crossoverProbability = 0.9; + double distributionIndex1 = 20.0; + parameters["probability"] = &crossoverProbability ; + parameters["distributionIndex"] = &distributionIndex1 ; + crossover = new SBXCrossover(parameters); + + parameters.clear(); + double mutationProbability = 1.0/problem->getNumberOfVariables(); + double distributionIndex2 = 20.0; + parameters["probability"] = &mutationProbability; + parameters["distributionIndex"] = &distributionIndex2 ; + mutation = new PolynomialMutation(parameters); + + // Selection Operator + parameters.clear(); + selection = new BinaryTournament(parameters) ; + + // Add the operators to the algorithm + algorithm->addOperator("crossover",crossover); + algorithm->addOperator("mutation",mutation); + algorithm->addOperator("selection",selection); + + // Add the indicator object to the algorithm + //algorithm->setInputParameter("indicators", indicators) ; + + // Execute the Algorithm + t_ini = clock(); + SolutionSet * population = algorithm->execute(); + t_fin = clock(); + double secs = (double) (t_fin - t_ini); + secs = secs / CLOCKS_PER_SEC; + + // Result messages + cout << "Total execution time: " << secs << "s" << endl; + cout << "Variables values have been written to file VAR" << endl; + population->printVariablesToFile("VAR"); + cout << "Objectives values have been written to file FUN" << endl; + population->printObjectivesToFile("FUN"); + + delete crossover; + delete mutation; + delete selection; + delete population; + delete algorithm; } // main diff --git a/src/main/ssNSGAII_main.cpp b/src/main/ssNSGAII_main.cpp index 40e0d38..6163019 100644 --- a/src/main/ssNSGAII_main.cpp +++ b/src/main/ssNSGAII_main.cpp @@ -41,83 +41,87 @@ * Genetic Algorithms" 5th International Conference, EMO 2009, pp: 183-197. * April 2009) */ -int main(int argc, char ** argv) { - - clock_t t_ini, t_fin; - - Problem * problem ; // The problem to solve - Algorithm * algorithm ; // The algorithm to use - Operator * crossover ; // Crossover operator - Operator * mutation ; // Mutation operator - Operator * selection ; // Selection operator - - if (argc>=2) { - problem = ProblemFactory::getProblem(argc, argv); - cout << "Selected problem: " << problem->getName() << endl; - } else { - cout << "No problem selected." << endl; - cout << "Default problem will be used: Fonseca" << endl; - problem = ProblemFactory::getProblem(const_cast("Fonseca")); - } - - //TODO: Quality Indicators - //QualityIndicator indicators ; // Object to get quality indicators - //indicators = null ; - - algorithm = new ssNSGAII(problem); - - // Algorithm parameters - int populationSize = 100; - int maxEvaluations = 25000; - algorithm->setInputParameter("populationSize",&populationSize); - algorithm->setInputParameter("maxEvaluations",&maxEvaluations); - - // Mutation and Crossover for Real codification - map parameters; - - double crossoverProbability = 0.9; - double crossoverDistributionIndex = 20.0; - parameters["probability"] = &crossoverProbability; - parameters["distributionIndex"] = &crossoverDistributionIndex; - crossover = new SBXCrossover(parameters); - - parameters.clear(); - double mutationProbability = 1.0/problem->getNumberOfVariables(); - double mutationDistributionIndex = 20.0; - parameters["probability"] = &mutationProbability; - parameters["distributionIndex"] = &mutationDistributionIndex; - mutation = new PolynomialMutation(parameters); - - // Selection Operator - parameters.clear(); - selection = new BinaryTournament2(parameters); - - // Add the operators to the algorithm - algorithm->addOperator("crossover",crossover); - algorithm->addOperator("mutation",mutation); - algorithm->addOperator("selection",selection); - - // Add the indicator object to the algorithm - //algorithm->setInputParameter("indicators", indicators) ; - - // Execute the Algorithm - t_ini = clock(); - SolutionSet * population = algorithm->execute(); - t_fin = clock(); - double secs = (double) (t_fin - t_ini); - secs = secs / CLOCKS_PER_SEC; - - // Result messages - cout << "Total execution time: " << secs << "s" << endl; - cout << "Variables values have been written to file VAR" << endl; - population->printVariablesToFile("VAR"); - cout << "Objectives values have been written to file FUN" << endl; - population->printObjectivesToFile("FUN"); - - delete selection; - delete mutation; - delete crossover; - delete population; - delete algorithm; +int main(int argc, char ** argv) +{ + + clock_t t_ini, t_fin; + + Problem * problem ; // The problem to solve + Algorithm * algorithm ; // The algorithm to use + Operator * crossover ; // Crossover operator + Operator * mutation ; // Mutation operator + Operator * selection ; // Selection operator + + if (argc>=2) + { + problem = ProblemFactory::getProblem(argc, argv); + cout << "Selected problem: " << problem->getName() << endl; + } + else + { + cout << "No problem selected." << endl; + cout << "Default problem will be used: Fonseca" << endl; + problem = ProblemFactory::getProblem(const_cast("Fonseca")); + } + + //TODO: Quality Indicators + //QualityIndicator indicators ; // Object to get quality indicators + //indicators = null ; + + algorithm = new ssNSGAII(problem); + + // Algorithm parameters + int populationSize = 100; + int maxEvaluations = 25000; + algorithm->setInputParameter("populationSize",&populationSize); + algorithm->setInputParameter("maxEvaluations",&maxEvaluations); + + // Mutation and Crossover for Real codification + map parameters; + + double crossoverProbability = 0.9; + double crossoverDistributionIndex = 20.0; + parameters["probability"] = &crossoverProbability; + parameters["distributionIndex"] = &crossoverDistributionIndex; + crossover = new SBXCrossover(parameters); + + parameters.clear(); + double mutationProbability = 1.0/problem->getNumberOfVariables(); + double mutationDistributionIndex = 20.0; + parameters["probability"] = &mutationProbability; + parameters["distributionIndex"] = &mutationDistributionIndex; + mutation = new PolynomialMutation(parameters); + + // Selection Operator + parameters.clear(); + selection = new BinaryTournament2(parameters); + + // Add the operators to the algorithm + algorithm->addOperator("crossover",crossover); + algorithm->addOperator("mutation",mutation); + algorithm->addOperator("selection",selection); + + // Add the indicator object to the algorithm + //algorithm->setInputParameter("indicators", indicators) ; + + // Execute the Algorithm + t_ini = clock(); + SolutionSet * population = algorithm->execute(); + t_fin = clock(); + double secs = (double) (t_fin - t_ini); + secs = secs / CLOCKS_PER_SEC; + + // Result messages + cout << "Total execution time: " << secs << "s" << endl; + cout << "Variables values have been written to file VAR" << endl; + population->printVariablesToFile("VAR"); + cout << "Objectives values have been written to file FUN" << endl; + population->printObjectivesToFile("FUN"); + + delete selection; + delete mutation; + delete crossover; + delete population; + delete algorithm; } // main diff --git a/src/metaheuristics/gde3/GDE3.cpp b/src/metaheuristics/gde3/GDE3.cpp index 9e97dd7..83972ca 100644 --- a/src/metaheuristics/gde3/GDE3.cpp +++ b/src/metaheuristics/gde3/GDE3.cpp @@ -31,7 +31,8 @@ * Constructor * @param problem Problem to solve */ -GDE3::GDE3(Problem *problem) : Algorithm(problem) { +GDE3::GDE3(Problem *problem) : Algorithm(problem) +{ } // GDE3 @@ -40,161 +41,176 @@ GDE3::GDE3(Problem *problem) : Algorithm(problem) { * @return a SolutionSet that is a set of non dominated solutions * as a result of the algorithm execution */ -SolutionSet * GDE3::execute() { - - int populationSize; - int maxIterations; - int evaluations; - int iterations; - - SolutionSet * population; - SolutionSet * offspringPopulation; - - Distance * distance; - Comparator * dominance; - - Operator * crossoverOperator; - Operator * selectionOperator; - - distance = new Distance(); - dominance = new DominanceComparator(); - - Solution ** parent; - - //Read the parameters - populationSize = *(int *) getInputParameter("populationSize"); - maxIterations = *(int *) getInputParameter("maxIterations"); - - //Initialize the variables - population = new SolutionSet(populationSize); - evaluations = 0; - iterations = 0; - - //Read the operators - crossoverOperator = operators_["crossover"]; - selectionOperator = operators_["selection"]; - - // Create the initial solutionSet - Solution * newSolution; - for (int i = 0; i < populationSize; i++) { - newSolution = new Solution(problem_); - problem_->evaluate(newSolution); - problem_->evaluateConstraints(newSolution); - evaluations++; - population->add(newSolution); - } //for - - // Generations ... - while (iterations < maxIterations) { - // Create the offSpring solutionSet - offspringPopulation = new SolutionSet(populationSize * 2); - - for (int i = 0; i < populationSize; i++){ - // Obtain parents. Two parameters are required: the population and the - // index of the current individual - void ** object1 = new void*[2]; - object1[0] = population; - object1[1] = &i; - parent = (Solution **) (selectionOperator->execute(object1)); - delete[] object1; - - Solution * child ; - // Crossover. Two parameters are required: the current individual and the - // array of parents - void ** object2 = new void*[2]; - object2[0] = population->get(i); - object2[1] = parent; - child = (Solution *) (crossoverOperator->execute(object2)); - delete[] object2; - delete[] parent; - - problem_->evaluate(child) ; - problem_->evaluateConstraints(child); - evaluations++ ; - - // Dominance test - int result ; - result = dominance->compare(population->get(i), child) ; - if (result == -1) { // Solution i dominates child - offspringPopulation->add(new Solution(population->get(i))); - delete child; - } // if - else if (result == 1) { // child dominates - offspringPopulation->add(child) ; - } // else if - else { // the two solutions are non-dominated - offspringPopulation->add(child) ; - offspringPopulation->add(new Solution(population->get(i))); - } // else - } // for - - // Ranking the offspring population - Ranking * ranking = new Ranking(offspringPopulation); - - int remain = populationSize; - int index = 0; - SolutionSet * front = NULL; - for (int i = 0; i < populationSize; i++) { - delete population->get(i); - } - population->clear(); - - // Obtain the next front - front = ranking->getSubfront(index); - - while ((remain > 0) && (remain >= front->size())){ - //Assign crowding distance to individuals - distance->crowdingDistanceAssignment(front,problem_->getNumberOfObjectives()); - //Add the individuals of this front - for (int k = 0; k < front->size(); k++ ) { - population->add(new Solution(front->get(k))); - } // for - - //Decrement remain - remain = remain - front->size(); - - //Obtain the next front - index++; - if (remain > 0) { +SolutionSet * GDE3::execute() +{ + + int populationSize; + int maxIterations; + int evaluations; + int iterations; + + SolutionSet * population; + SolutionSet * offspringPopulation; + + Distance * distance; + Comparator * dominance; + + Operator * crossoverOperator; + Operator * selectionOperator; + + distance = new Distance(); + dominance = new DominanceComparator(); + + Solution ** parent; + + //Read the parameters + populationSize = *(int *) getInputParameter("populationSize"); + maxIterations = *(int *) getInputParameter("maxIterations"); + + //Initialize the variables + population = new SolutionSet(populationSize); + evaluations = 0; + iterations = 0; + + //Read the operators + crossoverOperator = operators_["crossover"]; + selectionOperator = operators_["selection"]; + + // Create the initial solutionSet + Solution * newSolution; + for (int i = 0; i < populationSize; i++) + { + newSolution = new Solution(problem_); + problem_->evaluate(newSolution); + problem_->evaluateConstraints(newSolution); + evaluations++; + population->add(newSolution); + } //for + + // Generations ... + while (iterations < maxIterations) + { + // Create the offSpring solutionSet + offspringPopulation = new SolutionSet(populationSize * 2); + + for (int i = 0; i < populationSize; i++) + { + // Obtain parents. Two parameters are required: the population and the + // index of the current individual + void ** object1 = new void*[2]; + object1[0] = population; + object1[1] = &i; + parent = (Solution **) (selectionOperator->execute(object1)); + delete[] object1; + + Solution * child ; + // Crossover. Two parameters are required: the current individual and the + // array of parents + void ** object2 = new void*[2]; + object2[0] = population->get(i); + object2[1] = parent; + child = (Solution *) (crossoverOperator->execute(object2)); + delete[] object2; + delete[] parent; + + problem_->evaluate(child) ; + problem_->evaluateConstraints(child); + evaluations++ ; + + // Dominance test + int result ; + result = dominance->compare(population->get(i), child) ; + if (result == -1) // Solution i dominates child + { + offspringPopulation->add(new Solution(population->get(i))); + delete child; + } // if + else if (result == 1) // child dominates + { + offspringPopulation->add(child) ; + } // else if + else // the two solutions are non-dominated + { + offspringPopulation->add(child) ; + offspringPopulation->add(new Solution(population->get(i))); + } // else + } // for + + // Ranking the offspring population + Ranking * ranking = new Ranking(offspringPopulation); + + int remain = populationSize; + int index = 0; + SolutionSet * front = NULL; + for (int i = 0; i < populationSize; i++) + { + delete population->get(i); + } + population->clear(); + + // Obtain the next front front = ranking->getSubfront(index); - } // if + + while ((remain > 0) && (remain >= front->size())) + { + //Assign crowding distance to individuals + distance->crowdingDistanceAssignment(front,problem_->getNumberOfObjectives()); + //Add the individuals of this front + for (int k = 0; k < front->size(); k++ ) + { + population->add(new Solution(front->get(k))); + } // for + + //Decrement remain + remain = remain - front->size(); + + //Obtain the next front + index++; + if (remain > 0) + { + front = ranking->getSubfront(index); + } // if + } // while + + // remain is less than front(index).size, insert only the best one + if (remain > 0) // front contains individuals to insert + { + while (front->size() > remain) + { + distance->crowdingDistanceAssignment(front,problem_->getNumberOfObjectives()); + Comparator * crowdingComparator = new CrowdingComparator(); + int indexWorst = front->indexWorst(crowdingComparator); + delete crowdingComparator; + delete front->get(indexWorst); + front->remove(indexWorst); + } + for (int k = 0; k < front->size(); k++) + { + population->add(new Solution(front->get(k))); + } + + remain = 0; + } // if + + delete ranking; + delete offspringPopulation; + + iterations ++ ; } // while - // remain is less than front(index).size, insert only the best one - if (remain > 0) { // front contains individuals to insert - while (front->size() > remain) { - distance->crowdingDistanceAssignment(front,problem_->getNumberOfObjectives()); - Comparator * crowdingComparator = new CrowdingComparator(); - int indexWorst = front->indexWorst(crowdingComparator); - delete crowdingComparator; - delete front->get(indexWorst); - front->remove(indexWorst); - } - for (int k = 0; k < front->size(); k++) { - population->add(new Solution(front->get(k))); - } - - remain = 0; - } // if + delete dominance; + delete distance; + // Return the first non-dominated front + Ranking * ranking = new Ranking(population); + SolutionSet * result = new SolutionSet(ranking->getSubfront(0)->size()); + for (int i=0; igetSubfront(0)->size(); i++) + { + result->add(new Solution(ranking->getSubfront(0)->get(i))); + } delete ranking; - delete offspringPopulation; - - iterations ++ ; - } // while - - delete dominance; - delete distance; - - // Return the first non-dominated front - Ranking * ranking = new Ranking(population); - SolutionSet * result = new SolutionSet(ranking->getSubfront(0)->size()); - for (int i=0;igetSubfront(0)->size();i++) { - result->add(new Solution(ranking->getSubfront(0)->get(i))); - } - delete ranking; - delete population; + delete population; - return result; + return result; } // execute diff --git a/src/metaheuristics/gde3/GDE3.h b/src/metaheuristics/gde3/GDE3.h index f1526c8..2119f27 100644 --- a/src/metaheuristics/gde3/GDE3.h +++ b/src/metaheuristics/gde3/GDE3.h @@ -33,14 +33,15 @@ * @brief This class implements the GDE3 algorithm. **/ -class GDE3 : public Algorithm { +class GDE3 : public Algorithm +{ private: - int populationSize_; - int maxEvaluations_; - //QualityIndicator *indicators_; + int populationSize_; + int maxEvaluations_; + //QualityIndicator *indicators_; public: - GDE3(Problem * problem); - SolutionSet * execute(); + GDE3(Problem * problem); + SolutionSet * execute(); }; #endif /* __GDE3__ */ diff --git a/src/metaheuristics/mochc/MOCHC.cpp b/src/metaheuristics/mochc/MOCHC.cpp index 64a0f09..7ce5d92 100644 --- a/src/metaheuristics/mochc/MOCHC.cpp +++ b/src/metaheuristics/mochc/MOCHC.cpp @@ -20,63 +20,74 @@ // #include -bool MOCHC::equalsIndividuals(Solution & s1, Solution & s2) { - - for (int var = 0; var < s1.getNumberOfVariables(); var++) { - Binary *b1, *b2; - b1 = (Binary *)s1.getDecisionVariables()[var]; - b2 = (Binary *)s2.getDecisionVariables()[var]; - bool found = true; - for (int bit = 0; bit < b1->getNumberOfBits(); bit++) { - if (b1->getIth(bit)!=b2->getIth(bit)) { - return false; - } - } - } - - return true; +bool MOCHC::equalsIndividuals(Solution & s1, Solution & s2) +{ + + for (int var = 0; var < s1.getNumberOfVariables(); var++) + { + Binary *b1, *b2; + b1 = (Binary *)s1.getDecisionVariables()[var]; + b2 = (Binary *)s2.getDecisionVariables()[var]; + bool found = true; + for (int bit = 0; bit < b1->getNumberOfBits(); bit++) + { + if (b1->getIth(bit)!=b2->getIth(bit)) + { + return false; + } + } + } + + return true; } -bool MOCHC::exist(Solution & s1, SolutionSet & set2) { - for (int i = 0; i < set2.size(); i++) { - if (equalsIndividuals(s1,*set2.get(i))) - return true; - } - return false; +bool MOCHC::exist(Solution & s1, SolutionSet & set2) +{ + for (int i = 0; i < set2.size(); i++) + { + if (equalsIndividuals(s1,*set2.get(i))) + return true; + } + return false; } -bool MOCHC::equals(SolutionSet & set1, SolutionSet & set2) { +bool MOCHC::equals(SolutionSet & set1, SolutionSet & set2) +{ - if (set1.size() != set2.size()) - return false; + if (set1.size() != set2.size()) + return false; - for (int i = 0; i < set1.size(); i++) { - if (!exist(*set1.get(i),set2)) - return false; - } - return true; + for (int i = 0; i < set1.size(); i++) + { + if (!exist(*set1.get(i),set2)) + return false; + } + return true; } // returns the equal -int MOCHC::hammingDistance(Solution & sol1, Solution & sol2) { - int distance = 0; - for (int i = 0; i < problem_->getNumberOfVariables(); i++) { - Binary *varFrom1, *varFrom2; - varFrom1 = (Binary *)sol1.getDecisionVariables()[i]; - varFrom2 = (Binary *)sol2.getDecisionVariables()[i]; - distance += varFrom1->hammingDistance(varFrom2); - } - return distance; +int MOCHC::hammingDistance(Solution & sol1, Solution & sol2) +{ + int distance = 0; + for (int i = 0; i < problem_->getNumberOfVariables(); i++) + { + Binary *varFrom1, *varFrom2; + varFrom1 = (Binary *)sol1.getDecisionVariables()[i]; + varFrom2 = (Binary *)sol2.getDecisionVariables()[i]; + distance += varFrom1->hammingDistance(varFrom2); + } + return distance; } -SolutionSet *MOCHC::rankingAndCrowdingSelection(SolutionSet * pop, int size) { +SolutionSet *MOCHC::rankingAndCrowdingSelection(SolutionSet * pop, int size) +{ SolutionSet *result = new SolutionSet(size); // Ranking the union - Ranking * ranking = new Ranking(pop); + Ranking * ranking = new Ranking(pop); Distance * distance = new Distance(); int remain = size; int index = 0; @@ -85,166 +96,182 @@ SolutionSet *MOCHC::rankingAndCrowdingSelection(SolutionSet * pop, int size) { // Obtain the next front front = ranking->getSubfront(index); - while ((remain > 0) && (remain >= front->size())) { - //Assign crowding distance to individuals - distance->crowdingDistanceAssignment(front, problem_->getNumberOfObjectives()); + while ((remain > 0) && (remain >= front->size())) + { + //Assign crowding distance to individuals + distance->crowdingDistanceAssignment(front, problem_->getNumberOfObjectives()); - //Add the individuals of this front - for (int k = 0; k < front->size(); k++) { - result->add(new Solution(front->get(k))); - } // for + //Add the individuals of this front + for (int k = 0; k < front->size(); k++) + { + result->add(new Solution(front->get(k))); + } // for - //Decrement remain - remain = remain - front->size(); + //Decrement remain + remain = remain - front->size(); + + //Obtain the next front + index++; + if (remain > 0) + { + front = ranking->getSubfront(index); + } // if - //Obtain the next front - index++; - if (remain > 0) { - front = ranking->getSubfront(index); - } // if - } // while // Remain is less than front(index).size, insert only the best one - if (remain > 0) { // front contains individuals to insert - distance->crowdingDistanceAssignment(front, problem_->getNumberOfObjectives()); - Comparator * c = new CrowdingComparator(); - front->sort(c); - delete c; - for (int k = 0; k < remain; k++) { - result->add(new Solution(front->get(k))); - } // for - - remain = 0; + if (remain > 0) // front contains individuals to insert + { + distance->crowdingDistanceAssignment(front, problem_->getNumberOfObjectives()); + Comparator * c = new CrowdingComparator(); + front->sort(c); + delete c; + for (int k = 0; k < remain; k++) + { + result->add(new Solution(front->get(k))); + } // for + + remain = 0; } // if delete ranking; delete distance; - return result; + return result; } -SolutionSet *MOCHC::execute() { - - int populationSize; - int iterations; - int maxEvaluations; - int convergenceValue; - int minimumDistance; - int evaluations; - - double preservedPopulation; - double initialConvergenceCount; - bool condition = false; - SolutionSet *solutionSet, *offSpringPopulation, *newPopulation; - - Comparator * crowdingComparator = new CrowdingComparator(); - - SolutionSet * population; - SolutionSet * offspringPopulation; - SolutionSet * unionSolution; - - Operator * cataclysmicMutation; - Operator * crossover; - Operator * parentSelection; - - - //Read the parameters - populationSize = *(int *) getInputParameter("populationSize"); - maxEvaluations = *(int *) getInputParameter("maxEvaluations"); - convergenceValue = *(int *) getInputParameter("convergenceValue"); - initialConvergenceCount = *(double *)getInputParameter("initialConvergenceCount"); - preservedPopulation = *(double *)getInputParameter("preservedPopulation"); - - - //Read the operators - cataclysmicMutation = operators_["mutation"]; - crossover = operators_["crossover"]; - parentSelection = operators_["parentSelection"]; - - iterations = 0; - evaluations = 0; - - // calculating the maximum problem sizes .... - Solution * sol = new Solution(problem_); - int size = 0; - for (int var = 0; var < problem_->getNumberOfVariables(); var++) { - Binary *binaryVar; +SolutionSet *MOCHC::execute() +{ + + int populationSize; + int iterations; + int maxEvaluations; + int convergenceValue; + int minimumDistance; + int evaluations; + + double preservedPopulation; + double initialConvergenceCount; + bool condition = false; + SolutionSet *solutionSet, *offSpringPopulation, *newPopulation; + + Comparator * crowdingComparator = new CrowdingComparator(); + + SolutionSet * population; + SolutionSet * offspringPopulation; + SolutionSet * unionSolution; + + Operator * cataclysmicMutation; + Operator * crossover; + Operator * parentSelection; + + + //Read the parameters + populationSize = *(int *) getInputParameter("populationSize"); + maxEvaluations = *(int *) getInputParameter("maxEvaluations"); + convergenceValue = *(int *) getInputParameter("convergenceValue"); + initialConvergenceCount = *(double *)getInputParameter("initialConvergenceCount"); + preservedPopulation = *(double *)getInputParameter("preservedPopulation"); + + + //Read the operators + cataclysmicMutation = operators_["mutation"]; + crossover = operators_["crossover"]; + parentSelection = operators_["parentSelection"]; + + iterations = 0; + evaluations = 0; + + // calculating the maximum problem sizes .... + Solution * sol = new Solution(problem_); + int size = 0; + for (int var = 0; var < problem_->getNumberOfVariables(); var++) + { + Binary *binaryVar; binaryVar = (Binary *)sol->getDecisionVariables()[var]; - size += binaryVar->getNumberOfBits(); - } - minimumDistance = (int) std::floor(initialConvergenceCount*size); - std::cout << minimumDistance << std::endl; - std::cout << convergenceValue << std::endl; - - // Create the initial solutionSet - Solution * newSolution; - population = new SolutionSet(populationSize); - for (int i = 0; i < populationSize; i++) { - newSolution = new Solution(problem_); - problem_->evaluate(newSolution); - problem_->evaluateConstraints(newSolution); - evaluations++; - population->add(newSolution); - } //for - - - while (!condition) { - offSpringPopulation = new SolutionSet(populationSize); - Solution **parents = new Solution*[2]; - - for (int i = 0; i < population->size()/2; i++) { - parents[0] = (Solution *) (parentSelection->execute(population)); - parents[1] = (Solution *) (parentSelection->execute(population)); - - if (hammingDistance(*parents[0],*parents[1])>= minimumDistance) { - Solution ** offSpring = (Solution **) (crossover->execute(parents)); - problem_->evaluate(offSpring[0]); - problem_->evaluateConstraints(offSpring[0]); - problem_->evaluate(offSpring[1]); - problem_->evaluateConstraints(offSpring[1]); - evaluations+=2; - offSpringPopulation->add(offSpring[0]); - offSpringPopulation->add(offSpring[1]); - } - } - SolutionSet *join = population->join(offSpringPopulation); - delete offSpringPopulation; - - newPopulation = rankingAndCrowdingSelection(join,populationSize); - delete join; - if (equals(*population,*newPopulation)) { - std::cout << "populations are equals" << std::endl; - minimumDistance--; - } - - if (minimumDistance <= -convergenceValue) { - minimumDistance = (int) (1.0/size * (1-1.0/size) * size); - int preserve = (int) std::floor(preservedPopulation*populationSize); - newPopulation->clear(); //do the new in c++ really hurts me(juanjo) - population->sort(crowdingComparator); - for (int i = 0; i < preserve; i++) { - newPopulation->add(new Solution(population->get(i))); - } - for (int i = preserve; i < populationSize; i++) { - Solution * solution = new Solution(population->get(i)); - cataclysmicMutation->execute(solution); - problem_->evaluate(solution); - problem_->evaluateConstraints(solution); - newPopulation->add(solution); - } - - } - - iterations++; - delete population; - population = newPopulation; - if (evaluations >= maxEvaluations) { - condition = true; - } - } - - return population; + size += binaryVar->getNumberOfBits(); + } + minimumDistance = (int) std::floor(initialConvergenceCount*size); + std::cout << minimumDistance << std::endl; + std::cout << convergenceValue << std::endl; + + // Create the initial solutionSet + Solution * newSolution; + population = new SolutionSet(populationSize); + for (int i = 0; i < populationSize; i++) + { + newSolution = new Solution(problem_); + problem_->evaluate(newSolution); + problem_->evaluateConstraints(newSolution); + evaluations++; + population->add(newSolution); + } //for + + + while (!condition) + { + offSpringPopulation = new SolutionSet(populationSize); + Solution **parents = new Solution*[2]; + + for (int i = 0; i < population->size()/2; i++) + { + parents[0] = (Solution *) (parentSelection->execute(population)); + parents[1] = (Solution *) (parentSelection->execute(population)); + + if (hammingDistance(*parents[0],*parents[1])>= minimumDistance) + { + Solution ** offSpring = (Solution **) (crossover->execute(parents)); + problem_->evaluate(offSpring[0]); + problem_->evaluateConstraints(offSpring[0]); + problem_->evaluate(offSpring[1]); + problem_->evaluateConstraints(offSpring[1]); + evaluations+=2; + offSpringPopulation->add(offSpring[0]); + offSpringPopulation->add(offSpring[1]); + } + } + SolutionSet *join = population->join(offSpringPopulation); + delete offSpringPopulation; + + newPopulation = rankingAndCrowdingSelection(join,populationSize); + delete join; + if (equals(*population,*newPopulation)) + { + std::cout << "populations are equals" << std::endl; + minimumDistance--; + } + + if (minimumDistance <= -convergenceValue) + { + minimumDistance = (int) (1.0/size * (1-1.0/size) * size); + int preserve = (int) std::floor(preservedPopulation*populationSize); + newPopulation->clear(); //do the new in c++ really hurts me(juanjo) + population->sort(crowdingComparator); + for (int i = 0; i < preserve; i++) + { + newPopulation->add(new Solution(population->get(i))); + } + for (int i = preserve; i < populationSize; i++) + { + Solution * solution = new Solution(population->get(i)); + cataclysmicMutation->execute(solution); + problem_->evaluate(solution); + problem_->evaluateConstraints(solution); + newPopulation->add(solution); + } + + } + + iterations++; + delete population; + population = newPopulation; + if (evaluations >= maxEvaluations) + { + condition = true; + } + } + + return population; } diff --git a/src/metaheuristics/mochc/MOCHC.h b/src/metaheuristics/mochc/MOCHC.h index e1d5f13..adcffe4 100644 --- a/src/metaheuristics/mochc/MOCHC.h +++ b/src/metaheuristics/mochc/MOCHC.h @@ -31,21 +31,22 @@ #include #include #include -// Juanjo: I am following the same sintax as in the other algorithms. +// Juanjo: I am following the same sintax as in the other algorithms. // however, I would never ever program like this in C++ // I would recommend to use something as MOCHC(Problem &) -class MOCHC : public Algorithm { +class MOCHC : public Algorithm +{ - bool equalsIndividuals(Solution &s1, Solution & s2); - bool exist(Solution &s1, SolutionSet &set2); - bool equals(SolutionSet& set1, SolutionSet& set2); - int hammingDistance(Solution &sol1, Solution& sol2); - SolutionSet *rankingAndCrowdingSelection(SolutionSet *sol,int size); + bool equalsIndividuals(Solution &s1, Solution & s2); + bool exist(Solution &s1, SolutionSet &set2); + bool equals(SolutionSet& set1, SolutionSet& set2); + int hammingDistance(Solution &sol1, Solution& sol2); + SolutionSet *rankingAndCrowdingSelection(SolutionSet *sol,int size); public: - MOCHC(Problem * problem) : Algorithm(problem){}; - SolutionSet *execute(); + MOCHC(Problem * problem) : Algorithm(problem) {}; + SolutionSet *execute(); }; diff --git a/src/metaheuristics/moead/MOEAD.cpp b/src/metaheuristics/moead/MOEAD.cpp index f38144e..afe0e24 100644 --- a/src/metaheuristics/moead/MOEAD.cpp +++ b/src/metaheuristics/moead/MOEAD.cpp @@ -31,288 +31,322 @@ * Constructor * @param problem Problem to solve */ -MOEAD::MOEAD(Problem *problem) : Algorithm(problem) { - functionType_ = "_TCHE1"; +MOEAD::MOEAD(Problem *problem) : Algorithm(problem) +{ + functionType_ = "_TCHE1"; } // MOEAD -SolutionSet * MOEAD::execute() { - int maxEvaluations; - - evaluations_ = 0; - maxEvaluations = *(int *) getInputParameter("maxEvaluations"); - populationSize_ = *(int *) getInputParameter("populationSize"); - dataDirectory_ = * (string *) getInputParameter("dataDirectory"); - - population_ = new SolutionSet(populationSize_); - //indArray_ = new Solution*[problem_->getNumberOfObjectives()]; - - T_ = 20; - delta_ = 0.9; - nr_ = 2; -/* - T_ = * (int *) (0.1 * populationSize_); - delta_ = 0.9; - nr_ = * (int *) (0.01 * populationSize_); -*/ - neighborhood_ = new int*[populationSize_]; - - z_ = new double[problem_->getNumberOfObjectives()]; - //lambda_ = new Vector(problem_->getNumberOfObjectives()) ; - lambda_ = new double*[populationSize_]; - - crossover_ = operators_["crossover"]; // default: DE crossover - mutation_ = operators_["mutation"]; // default: polynomial mutation - - // STEP 1. Initialization - // STEP 1.1. Compute euclidean distances between weight vectors and find T - initUniformWeight(); - //for (int i = 0; i < 300; i++) - // cout << lambda_[i][0] << " " << lambda_[i][1] << endl ; - - initNeighborhood(); - - // STEP 1.2. Initialize population - initPopulation(); - - // STEP 1.3. Initialize z_ - initIdealPoint(); - - // STEP 2. Update - do { - int * permutation = new int[populationSize_]; - UtilsMOEAD::randomPermutation(permutation, populationSize_); - for (int i = 0; i < populationSize_; i++) { - int n = permutation[i]; // or int n = i; - //int n = i ; // or int n = i; - int type; - double rnd = PseudoRandom::randDouble(); - - // STEP 2.1. Mating selection based on probability - if (rnd < delta_) // if (rnd < realb) - { - type = 1; // neighborhood - } else { - type = 2; // whole population - } - vector p; - matingSelection(p, n, 2, type); - - // STEP 2.2. Reproduction - Solution * child; - Solution ** parents = new Solution*[3]; - - parents[0] = population_->get(p[0]); - parents[1] = population_->get(p[1]); - parents[2] = population_->get(n); - - // Apply DE crossover - void ** object = new void*[2]; - object[0] = population_->get(n); - object[1] = parents; - child = (Solution *) (crossover_->execute(object)); - delete[] object; - delete[] parents; - - // Apply mutation - mutation_->execute(child); - - // Evaluation - problem_->evaluate(child); - - evaluations_++; - - // STEP 2.3. Repair. Not necessary - - // STEP 2.4. Update z_ - updateReference(child); - - // STEP 2.5. Update of solutions - updateProblem(child, n, type); - } // for - - delete[] permutation; - - } while (evaluations_ < maxEvaluations); - - // Free memory - deleteParams(); - - return population_; +SolutionSet * MOEAD::execute() +{ + int maxEvaluations; + + evaluations_ = 0; + maxEvaluations = *(int *) getInputParameter("maxEvaluations"); + populationSize_ = *(int *) getInputParameter("populationSize"); + dataDirectory_ = * (string *) getInputParameter("dataDirectory"); + + population_ = new SolutionSet(populationSize_); + //indArray_ = new Solution*[problem_->getNumberOfObjectives()]; + + T_ = 20; + delta_ = 0.9; + nr_ = 2; + /* + T_ = * (int *) (0.1 * populationSize_); + delta_ = 0.9; + nr_ = * (int *) (0.01 * populationSize_); + */ + neighborhood_ = new int*[populationSize_]; + + z_ = new double[problem_->getNumberOfObjectives()]; + //lambda_ = new Vector(problem_->getNumberOfObjectives()) ; + lambda_ = new double*[populationSize_]; + + crossover_ = operators_["crossover"]; // default: DE crossover + mutation_ = operators_["mutation"]; // default: polynomial mutation + + // STEP 1. Initialization + // STEP 1.1. Compute euclidean distances between weight vectors and find T + initUniformWeight(); + //for (int i = 0; i < 300; i++) + // cout << lambda_[i][0] << " " << lambda_[i][1] << endl ; + + initNeighborhood(); + + // STEP 1.2. Initialize population + initPopulation(); + + // STEP 1.3. Initialize z_ + initIdealPoint(); + + // STEP 2. Update + do + { + int * permutation = new int[populationSize_]; + UtilsMOEAD::randomPermutation(permutation, populationSize_); + for (int i = 0; i < populationSize_; i++) + { + int n = permutation[i]; // or int n = i; + //int n = i ; // or int n = i; + int type; + double rnd = PseudoRandom::randDouble(); + + // STEP 2.1. Mating selection based on probability + if (rnd < delta_) // if (rnd < realb) + { + type = 1; // neighborhood + } + else + { + type = 2; // whole population + } + vector p; + matingSelection(p, n, 2, type); + + // STEP 2.2. Reproduction + Solution * child; + Solution ** parents = new Solution*[3]; + + parents[0] = population_->get(p[0]); + parents[1] = population_->get(p[1]); + parents[2] = population_->get(n); + + // Apply DE crossover + void ** object = new void*[2]; + object[0] = population_->get(n); + object[1] = parents; + child = (Solution *) (crossover_->execute(object)); + delete[] object; + delete[] parents; + + // Apply mutation + mutation_->execute(child); + + // Evaluation + problem_->evaluate(child); + + evaluations_++; + + // STEP 2.3. Repair. Not necessary + + // STEP 2.4. Update z_ + updateReference(child); + + // STEP 2.5. Update of solutions + updateProblem(child, n, type); + } // for + + delete[] permutation; + + } + while (evaluations_ < maxEvaluations); + + // Free memory + deleteParams(); + + return population_; } // execute /** * initUniformWeight */ -void MOEAD::initUniformWeight() { - if ((problem_->getNumberOfObjectives() == 2) && (populationSize_ <= 300)) { - for (int n = 0; n < populationSize_; n++) { - lambda_[n] = new double[problem_->getNumberOfObjectives()]; - double a = 1.0 * n / (populationSize_ - 1); - lambda_[n][0] = a; - lambda_[n][1] = 1 - a; - } // for - } // if - else { - ostringstream os; - os << dataDirectory_ + "/" << "W" << problem_->getNumberOfObjectives() << "D_" - << populationSize_ << ".dat"; - string dataFileName; - dataFileName = os.str(); - - // Open the file - std::ifstream in(dataFileName.c_str()); - if( !in ) { - cout << "initUniformWeight: failed when reading from file: : " << - dataFileName << endl; - exit(-1); +void MOEAD::initUniformWeight() +{ + if ((problem_->getNumberOfObjectives() == 2) && (populationSize_ <= 300)) + { + for (int n = 0; n < populationSize_; n++) + { + lambda_[n] = new double[problem_->getNumberOfObjectives()]; + double a = 1.0 * n / (populationSize_ - 1); + lambda_[n][0] = a; + lambda_[n][1] = 1 - a; + } // for } // if + else + { + ostringstream os; + os << dataDirectory_ + "/" << "W" << problem_->getNumberOfObjectives() << "D_" + << populationSize_ << ".dat"; + string dataFileName; + dataFileName = os.str(); - //int numberOfObjectives = 0; - int i = 0; - int j = 0; - string aux; - while (getline(in, aux)) { - istringstream iss(aux); - j = 0; - // TODO: Check if number of tokens per line is equal to number of - // objectives - lambda_[i] = new double[problem_->getNumberOfObjectives()]; - while (iss) { - string token; - iss >> token; - if (token.compare("")!=0) { - double value = atof(token.c_str()); - lambda_[i][j] = value; - //cout << "lambda[" << i << "," << j << "] = " << value << endl; - j++; + // Open the file + std::ifstream in(dataFileName.c_str()); + if( !in ) + { + cout << "initUniformWeight: failed when reading from file: : " << + dataFileName << endl; + exit(-1); } // if - } // while - i++; - } // while - in.close(); - } // else + + //int numberOfObjectives = 0; + int i = 0; + int j = 0; + string aux; + while (getline(in, aux)) + { + istringstream iss(aux); + j = 0; + // TODO: Check if number of tokens per line is equal to number of + // objectives + lambda_[i] = new double[problem_->getNumberOfObjectives()]; + while (iss) + { + string token; + iss >> token; + if (token.compare("")!=0) + { + double value = atof(token.c_str()); + lambda_[i][j] = value; + //cout << "lambda[" << i << "," << j << "] = " << value << endl; + j++; + } // if + } // while + i++; + } // while + in.close(); + } // else } // initUniformWeight /** * initNeighborhood */ -void MOEAD::initNeighborhood() { - double * x = new double[populationSize_]; - int * idx = new int[populationSize_]; - - for (int i = 0; i < populationSize_; i++) { - // calculate the distances based on weight vectors - for (int j = 0; j < populationSize_; j++) { - x[j] = UtilsMOEAD::distVector(lambda_[i], lambda_[j], - problem_->getNumberOfObjectives()); - //x[j] = dist_vector(population[i].namda,population[j].namda); - idx[j] = j; - // cout << "x[" << j << "]: " << x[j] << ". idx[" << j << "]: " << - // idx[j] << endl ; +void MOEAD::initNeighborhood() +{ + double * x = new double[populationSize_]; + int * idx = new int[populationSize_]; + + for (int i = 0; i < populationSize_; i++) + { + // calculate the distances based on weight vectors + for (int j = 0; j < populationSize_; j++) + { + x[j] = UtilsMOEAD::distVector(lambda_[i], lambda_[j], + problem_->getNumberOfObjectives()); + //x[j] = dist_vector(population[i].namda,population[j].namda); + idx[j] = j; + // cout << "x[" << j << "]: " << x[j] << ". idx[" << j << "]: " << + // idx[j] << endl ; + } // for + + // find 'niche' nearest neighboring subproblems + UtilsMOEAD::minFastSort(x, idx, populationSize_, T_); + //minfastsort(x,idx,population.size(),niche); + + neighborhood_[i] = new int[T_]; + for (int k = 0; k < T_; k++) + { + neighborhood_[i][k] = idx[k]; + //cout << "neg[ << i << "," << k << "]: " << neighborhood_[i][k] << endl; + } } // for - - // find 'niche' nearest neighboring subproblems - UtilsMOEAD::minFastSort(x, idx, populationSize_, T_); - //minfastsort(x,idx,population.size(),niche); - - neighborhood_[i] = new int[T_]; - for (int k = 0; k < T_; k++) { - neighborhood_[i][k] = idx[k]; - //cout << "neg[ << i << "," << k << "]: " << neighborhood_[i][k] << endl; - } - } // for - - delete[] x; - delete[] idx; - + + delete[] x; + delete[] idx; + } // initNeighborhood /** * initPopulation */ -void MOEAD::initPopulation() { - for (int i = 0; i < populationSize_; i++) { - Solution * newSolution = new Solution(problem_); - - problem_->evaluate(newSolution); - evaluations_++; - population_->add(newSolution); - } // for +void MOEAD::initPopulation() +{ + for (int i = 0; i < populationSize_; i++) + { + Solution * newSolution = new Solution(problem_); + + problem_->evaluate(newSolution); + evaluations_++; + population_->add(newSolution); + } // for } // initPopulation /** * initIdealPoint */ -void MOEAD::initIdealPoint() { - for (int i = 0; i < problem_->getNumberOfObjectives(); i++) { - z_[i] = 1.0e+30; - //indArray_[i] = new Solution(problem_); - //problem_->evaluate(indArray_[i]); - //evaluations_++; - } // for - - for (int i = 0; i < populationSize_; i++) { - updateReference(population_->get(i)); - } // for +void MOEAD::initIdealPoint() +{ + for (int i = 0; i < problem_->getNumberOfObjectives(); i++) + { + z_[i] = 1.0e+30; + //indArray_[i] = new Solution(problem_); + //problem_->evaluate(indArray_[i]); + //evaluations_++; + } // for + + for (int i = 0; i < populationSize_; i++) + { + updateReference(population_->get(i)); + } // for } // initIdealPoint /** * matingSelection */ -void MOEAD::matingSelection(vector &list, int cid, int size, int type) { - - // list : the set of the indexes of selected mating parents - // cid : the id of current subproblem - // size : the number of selected mating parents - // type : 1 - neighborhood; otherwise - whole population - int ss; - int r; - int p; - - //ss = neighborhood_[cid].length; - ss = T_; - while (list.size() < size) { - if (type == 1) { - r = PseudoRandom::randInt(0, ss - 1); - p = neighborhood_[cid][r]; - //p = population[cid].table[r]; - } else { - p = PseudoRandom::randInt(0, populationSize_ - 1); - } - bool flag = true; - for (int i = 0; i < list.size(); i++) { - if (list[i] == p) // p is in the list - { - flag = false; - break; - } - } - - //if (flag) list.push_back(p); - if (flag) { - list.push_back(p); +void MOEAD::matingSelection(vector &list, int cid, int size, int type) +{ + + // list : the set of the indexes of selected mating parents + // cid : the id of current subproblem + // size : the number of selected mating parents + // type : 1 - neighborhood; otherwise - whole population + int ss; + int r; + int p; + + //ss = neighborhood_[cid].length; + ss = T_; + while (list.size() < size) + { + if (type == 1) + { + r = PseudoRandom::randInt(0, ss - 1); + p = neighborhood_[cid][r]; + //p = population[cid].table[r]; + } + else + { + p = PseudoRandom::randInt(0, populationSize_ - 1); + } + bool flag = true; + for (int i = 0; i < list.size(); i++) + { + if (list[i] == p) // p is in the list + { + flag = false; + break; + } + } + + //if (flag) list.push_back(p); + if (flag) + { + list.push_back(p); + } } - } } // matingSelection /** - * + * * @param individual */ -void MOEAD::updateReference(Solution * individual) { - for (int n = 0; n < problem_->getNumberOfObjectives(); n++) { - if (individual->getObjective(n) < z_[n]) { - z_[n] = individual->getObjective(n); - //indArray_[n] = individual; +void MOEAD::updateReference(Solution * individual) +{ + for (int n = 0; n < problem_->getNumberOfObjectives(); n++) + { + if (individual->getObjective(n) < z_[n]) + { + z_[n] = individual->getObjective(n); + //indArray_[n] = individual; + } } - } } // updateReference @@ -321,104 +355,125 @@ void MOEAD::updateReference(Solution * individual) { * @param id * @param type */ -void MOEAD::updateProblem(Solution * indiv, int id, int type) { - // indiv: child solution - // id: the id of current subproblem - // type: update solutions in neighborhood (1) or whole population (otherwise) - int size; - int time; - - time = 0; - - if (type == 1) { - //size = neighborhood_[id].length; - size = T_; - } else { - //size = population_.size(); - size = populationSize_; - } - int * perm = new int[size]; - - UtilsMOEAD::randomPermutation(perm, size); - - for (int i = 0; i < size; i++) { - - int k; - - if (type == 1) { - k = neighborhood_[id][perm[i]]; - } else { - k = perm[i]; // calculate the values of objective function regarding - // the current subproblem +void MOEAD::updateProblem(Solution * indiv, int id, int type) +{ + // indiv: child solution + // id: the id of current subproblem + // type: update solutions in neighborhood (1) or whole population (otherwise) + int size; + int time; + + time = 0; + + if (type == 1) + { + //size = neighborhood_[id].length; + size = T_; } - - double f1, f2; - - f1 = fitnessFunction(population_->get(k), lambda_[k]); - f2 = fitnessFunction(indiv, lambda_[k]); - - if (f2 < f1) { - delete population_->get(k); - population_->replace(k, new Solution(indiv)); - //population[k].indiv = indiv; - time++; + else + { + //size = population_.size(); + size = populationSize_; } - // the maximal number of solutions updated is not allowed to exceed 'limit' - if (time >= nr_) { - delete indiv; - delete[] perm; - return; + int * perm = new int[size]; + + UtilsMOEAD::randomPermutation(perm, size); + + for (int i = 0; i < size; i++) + { + + int k; + + if (type == 1) + { + k = neighborhood_[id][perm[i]]; + } + else + { + k = perm[i]; // calculate the values of objective function regarding + // the current subproblem + } + + double f1, f2; + + f1 = fitnessFunction(population_->get(k), lambda_[k]); + f2 = fitnessFunction(indiv, lambda_[k]); + + if (f2 < f1) + { + delete population_->get(k); + population_->replace(k, new Solution(indiv)); + //population[k].indiv = indiv; + time++; + } + // the maximal number of solutions updated is not allowed to exceed 'limit' + if (time >= nr_) + { + delete indiv; + delete[] perm; + return; + } } - } - delete indiv; - delete[] perm; - + delete indiv; + delete[] perm; + } // updateProblem /** * fitnessFunction */ -double MOEAD::fitnessFunction(Solution * individual, double * lambda) { - double fitness; - fitness = 0.0; - - if (functionType_.compare("_TCHE1")==0) { - double maxFun = -1.0e+30; - - for (int n = 0; n < problem_->getNumberOfObjectives(); n++) { - double diff = fabs(individual->getObjective(n) - z_[n]); - - double feval; - if (lambda[n] == 0) { - feval = 0.0001 * diff; - } else { - feval = diff * lambda[n]; - } - if (feval > maxFun) { - maxFun = feval; - } - } // for - - fitness = maxFun; - } // if - else { - cout << "MOEAD.fitnessFunction: unknown type " << functionType_ << endl; - exit (EXIT_FAILURE); - } - return fitness; +double MOEAD::fitnessFunction(Solution * individual, double * lambda) +{ + double fitness; + fitness = 0.0; + + if (functionType_.compare("_TCHE1")==0) + { + double maxFun = -1.0e+30; + + for (int n = 0; n < problem_->getNumberOfObjectives(); n++) + { + double diff = fabs(individual->getObjective(n) - z_[n]); + + double feval; + if (lambda[n] == 0) + { + feval = 0.0001 * diff; + } + else + { + feval = diff * lambda[n]; + } + if (feval > maxFun) + { + maxFun = feval; + } + } // for + + fitness = maxFun; + } // if + else + { + cout << "MOEAD.fitnessFunction: unknown type " << functionType_ << endl; + exit (EXIT_FAILURE); + } + return fitness; } // fitnessEvaluation -void MOEAD::deleteParams() { - delete[] z_; - for (int n = 0; n < populationSize_; n++) { - delete[] lambda_[n]; - } // for - delete[] lambda_; - for (int i = 0; i < populationSize_; i++) { - delete[] neighborhood_[i]; - } - delete[] neighborhood_; +void MOEAD::deleteParams() +{ + delete[] z_; + for (int n = 0; n < populationSize_; n++) + { + delete[] lambda_[n]; + } // for + delete[] lambda_; + for (int i = 0; i < populationSize_; i++) + { + delete[] neighborhood_[i]; + } + delete[] neighborhood_; } //deleteParams diff --git a/src/metaheuristics/moead/MOEAD.h b/src/metaheuristics/moead/MOEAD.h index a3ddce7..0ee5c39 100644 --- a/src/metaheuristics/moead/MOEAD.h +++ b/src/metaheuristics/moead/MOEAD.h @@ -32,66 +32,67 @@ * This class implements the MOEA/D algorithm. */ -class MOEAD : public Algorithm { - +class MOEAD : public Algorithm +{ + private: - /** - * Stores the population size - */ - int populationSize_; - /** - * Stores the population - */ - SolutionSet * population_; - /** - * Z vector (ideal point) - */ - double * z_; - /** - * Lambda vectors - */ - double ** lambda_; - /** - * T: neighbour size - */ - int T_; - /** - * Neighborhood - */ - int ** neighborhood_; - /** - * delta: probability that parent solutions are selected from neighbourhood - */ - double delta_; - /** - * nr: maximal number of solutions replaced by each child solution - */ - int nr_; - Solution ** indArray_; - string functionType_; - int evaluations_; - /** - * Operators - */ - Operator * crossover_; - Operator * mutation_; + /** + * Stores the population size + */ + int populationSize_; + /** + * Stores the population + */ + SolutionSet * population_; + /** + * Z vector (ideal point) + */ + double * z_; + /** + * Lambda vectors + */ + double ** lambda_; + /** + * T: neighbour size + */ + int T_; + /** + * Neighborhood + */ + int ** neighborhood_; + /** + * delta: probability that parent solutions are selected from neighbourhood + */ + double delta_; + /** + * nr: maximal number of solutions replaced by each child solution + */ + int nr_; + Solution ** indArray_; + string functionType_; + int evaluations_; + /** + * Operators + */ + Operator * crossover_; + Operator * mutation_; + + string dataDirectory_; - string dataDirectory_; - - void initUniformWeight(); - void initNeighborhood(); - void initPopulation(); - void initIdealPoint(); - void matingSelection(vector &list, int cid, int size, int type); - void updateReference(Solution * individual); - void updateProblem(Solution * indiv, int id, int type); - double fitnessFunction(Solution * individual, double * lambda); - void deleteParams(); + void initUniformWeight(); + void initNeighborhood(); + void initPopulation(); + void initIdealPoint(); + void matingSelection(vector &list, int cid, int size, int type); + void updateReference(Solution * individual); + void updateProblem(Solution * indiv, int id, int type); + double fitnessFunction(Solution * individual, double * lambda); + void deleteParams(); public: - MOEAD(Problem * problem); - SolutionSet * execute(); + MOEAD(Problem * problem); + SolutionSet * execute(); }; #endif /* __MOEAD__ */ diff --git a/src/metaheuristics/moead/UtilsMOEAD.cpp b/src/metaheuristics/moead/UtilsMOEAD.cpp index bce0408..d00486f 100644 --- a/src/metaheuristics/moead/UtilsMOEAD.cpp +++ b/src/metaheuristics/moead/UtilsMOEAD.cpp @@ -25,63 +25,77 @@ */ -double UtilsMOEAD::distVector(double * vector1, double * vector2, int dim) { - //int dim = vector1.size(); - double sum = 0; - for (int n = 0; n < dim; n++) { - sum += (vector1[n] - vector2[n]) * (vector1[n] - vector2[n]); - } - return sqrt(sum); +double UtilsMOEAD::distVector(double * vector1, double * vector2, int dim) +{ + //int dim = vector1.size(); + double sum = 0; + for (int n = 0; n < dim; n++) + { + sum += (vector1[n] - vector2[n]) * (vector1[n] - vector2[n]); + } + return sqrt(sum); } // distVector -void UtilsMOEAD::minFastSort(double * x, int * idx, int n, int m) { - - for (int i = 0; i < m; i++) { - for (int j = i + 1; j < n; j++) { - if (x[i] > x[j]) { - double temp = x[i]; - x[i] = x[j]; - x[j] = temp; - int id = idx[i]; - idx[i] = idx[j]; - idx[j] = id; - } // if - } - } // for - +void UtilsMOEAD::minFastSort(double * x, int * idx, int n, int m) +{ + + for (int i = 0; i < m; i++) + { + for (int j = i + 1; j < n; j++) + { + if (x[i] > x[j]) + { + double temp = x[i]; + x[i] = x[j]; + x[j] = temp; + int id = idx[i]; + idx[i] = idx[j]; + idx[j] = id; + } // if + } + } // for + } // minFastSort -void UtilsMOEAD::randomPermutation(int * perm, int size) { - int * index = new int[size]; - bool * flag = new bool[size]; - - for (int n = 0; n < size; n++) { - index[n] = n; - flag[n] = true; - } - - int num = 0; - while (num < size) { - int start = PseudoRandom::randInt(0, size - 1); - //int start = int(size*nd_uni(&rnd_uni_init)); - while (true) { - if (flag[start]) { - perm[num] = index[start]; - flag[start] = false; - num++; - break; - } - if (start == (size - 1)) { - start = 0; - } else { - start++; - } +void UtilsMOEAD::randomPermutation(int * perm, int size) +{ + int * index = new int[size]; + bool * flag = new bool[size]; + + for (int n = 0; n < size; n++) + { + index[n] = n; + flag[n] = true; } - } // while - - delete[] index; - delete[] flag; - + + int num = 0; + while (num < size) + { + int start = PseudoRandom::randInt(0, size - 1); + //int start = int(size*nd_uni(&rnd_uni_init)); + while (true) + { + if (flag[start]) + { + perm[num] = index[start]; + flag[start] = false; + num++; + break; + } + if (start == (size - 1)) + { + start = 0; + } + else + { + start++; + } + } + } // while + + delete[] index; + delete[] flag; + } // randomPermutation diff --git a/src/metaheuristics/moead/UtilsMOEAD.h b/src/metaheuristics/moead/UtilsMOEAD.h index e14cd8b..f1afd52 100644 --- a/src/metaheuristics/moead/UtilsMOEAD.h +++ b/src/metaheuristics/moead/UtilsMOEAD.h @@ -36,13 +36,14 @@ using namespace std; */ -class UtilsMOEAD { - +class UtilsMOEAD +{ + public: - static double distVector(double * vector1, double * vector2, int dim); - static void minFastSort(double * x, int * idx, int n, int m); - static void randomPermutation(int * perm, int size); - + static double distVector(double * vector1, double * vector2, int dim); + static void minFastSort(double * x, int * idx, int n, int m); + static void randomPermutation(int * perm, int size); + }; diff --git a/src/metaheuristics/nsgaII/NSGAII.cpp b/src/metaheuristics/nsgaII/NSGAII.cpp index 31251d1..d4bf074 100644 --- a/src/metaheuristics/nsgaII/NSGAII.cpp +++ b/src/metaheuristics/nsgaII/NSGAII.cpp @@ -31,7 +31,8 @@ * Constructor * @param problem Problem to solve */ -NSGAII::NSGAII(Problem *problem) : Algorithm(problem) { +NSGAII::NSGAII(Problem *problem) : Algorithm(problem) +{ } // NSGAII @@ -40,142 +41,153 @@ NSGAII::NSGAII(Problem *problem) : Algorithm(problem) { * @return a SolutionSet that is a set of non dominated solutions * as a result of the algorithm execution */ -SolutionSet * NSGAII::execute() { +SolutionSet * NSGAII::execute() +{ - int populationSize; - int maxEvaluations; - int evaluations; + int populationSize; + int maxEvaluations; + int evaluations; // QualityIndicator * indicators; // QualityIndicator object - int requiredEvaluations; // Use in the example of use of the - // indicators object (see below) + int requiredEvaluations; // Use in the example of use of the + // indicators object (see below) - SolutionSet * population; - SolutionSet * offspringPopulation; - SolutionSet * unionSolution; + SolutionSet * population; + SolutionSet * offspringPopulation; + SolutionSet * unionSolution; - Operator * mutationOperator; - Operator * crossoverOperator; - Operator * selectionOperator; + Operator * mutationOperator; + Operator * crossoverOperator; + Operator * selectionOperator; - Distance * distance = new Distance(); + Distance * distance = new Distance(); - //Read the parameters - populationSize = *(int *) getInputParameter("populationSize"); - maxEvaluations = *(int *) getInputParameter("maxEvaluations"); + //Read the parameters + populationSize = *(int *) getInputParameter("populationSize"); + maxEvaluations = *(int *) getInputParameter("maxEvaluations"); // indicators = (QualityIndicator *) getInputParameter("indicators"); - //Initialize the variables - population = new SolutionSet(populationSize); - evaluations = 0; - - requiredEvaluations = 0; - - //Read the operators - mutationOperator = operators_["mutation"]; - crossoverOperator = operators_["crossover"]; - selectionOperator = operators_["selection"]; - - // Create the initial solutionSet - Solution * newSolution; - for (int i = 0; i < populationSize; i++) { - newSolution = new Solution(problem_); - problem_->evaluate(newSolution); - problem_->evaluateConstraints(newSolution); - evaluations++; - population->add(newSolution); - } //for - - // Generations - while (evaluations < maxEvaluations) { - - // Create the offSpring solutionSet - offspringPopulation = new SolutionSet(populationSize); - Solution ** parents = new Solution*[2]; - - for (int i = 0; i < (populationSize / 2); i++) { - if (evaluations < maxEvaluations) { - //obtain parents - parents[0] = (Solution *) (selectionOperator->execute(population)); - parents[1] = (Solution *) (selectionOperator->execute(population)); - - Solution ** offSpring = (Solution **) (crossoverOperator->execute(parents)); - - mutationOperator->execute(offSpring[0]); - mutationOperator->execute(offSpring[1]); - - problem_->evaluate(offSpring[0]); - problem_->evaluateConstraints(offSpring[0]); - problem_->evaluate(offSpring[1]); - problem_->evaluateConstraints(offSpring[1]); - offspringPopulation->add(offSpring[0]); - offspringPopulation->add(offSpring[1]); - evaluations += 2; - delete[] offSpring; - - } // if - } // for - - delete[] parents; - - // Create the solutionSet union of solutionSet and offSpring - unionSolution = population->join(offspringPopulation); - delete offspringPopulation; - - // Ranking the union - Ranking * ranking = new Ranking(unionSolution); - - int remain = populationSize; - int index = 0; - SolutionSet * front = NULL; - for (int i=0;isize();i++) { - delete population->get(i); - } - population->clear(); - - // Obtain the next front - front = ranking->getSubfront(index); - - while ((remain > 0) && (remain >= front->size())) { - //Assign crowding distance to individuals - distance->crowdingDistanceAssignment(front, problem_->getNumberOfObjectives()); - - //Add the individuals of this front - for (int k = 0; k < front->size(); k++) { - population->add(new Solution(front->get(k))); - } // for - - //Decrement remain - remain = remain - front->size(); - - //Obtain the next front - index++; - if (remain > 0) { + //Initialize the variables + population = new SolutionSet(populationSize); + evaluations = 0; + + requiredEvaluations = 0; + + //Read the operators + mutationOperator = operators_["mutation"]; + crossoverOperator = operators_["crossover"]; + selectionOperator = operators_["selection"]; + + // Create the initial solutionSet + Solution * newSolution; + for (int i = 0; i < populationSize; i++) + { + newSolution = new Solution(problem_); + problem_->evaluate(newSolution); + problem_->evaluateConstraints(newSolution); + evaluations++; + population->add(newSolution); + } //for + + // Generations + while (evaluations < maxEvaluations) + { + + // Create the offSpring solutionSet + offspringPopulation = new SolutionSet(populationSize); + Solution ** parents = new Solution*[2]; + + for (int i = 0; i < (populationSize / 2); i++) + { + if (evaluations < maxEvaluations) + { + //obtain parents + parents[0] = (Solution *) (selectionOperator->execute(population)); + parents[1] = (Solution *) (selectionOperator->execute(population)); + + Solution ** offSpring = (Solution **) (crossoverOperator->execute(parents)); + + mutationOperator->execute(offSpring[0]); + mutationOperator->execute(offSpring[1]); + + problem_->evaluate(offSpring[0]); + problem_->evaluateConstraints(offSpring[0]); + problem_->evaluate(offSpring[1]); + problem_->evaluateConstraints(offSpring[1]); + offspringPopulation->add(offSpring[0]); + offspringPopulation->add(offSpring[1]); + evaluations += 2; + delete[] offSpring; + + } // if + } // for + + delete[] parents; + + // Create the solutionSet union of solutionSet and offSpring + unionSolution = population->join(offspringPopulation); + delete offspringPopulation; + + // Ranking the union + Ranking * ranking = new Ranking(unionSolution); + + int remain = populationSize; + int index = 0; + SolutionSet * front = NULL; + for (int i=0; isize(); i++) + { + delete population->get(i); + } + population->clear(); + + // Obtain the next front front = ranking->getSubfront(index); - } // if - - } // while - // Remain is less than front(index).size, insert only the best one - if (remain > 0) { // front contains individuals to insert - distance->crowdingDistanceAssignment(front, problem_->getNumberOfObjectives()); - Comparator * c = new CrowdingComparator(); - front->sort(c); - delete c; - for (int k = 0; k < remain; k++) { - population->add(new Solution(front->get(k))); - } // for - - remain = 0; - } // if - - delete ranking; - delete unionSolution; - - // This piece of code shows how to use the indicator object into the code - // of NSGA-II. In particular, it finds the number of evaluations required - // by the algorithm to obtain a Pareto front with a hypervolume higher - // than the hypervolume of the true Pareto front. + while ((remain > 0) && (remain >= front->size())) + { + //Assign crowding distance to individuals + distance->crowdingDistanceAssignment(front, problem_->getNumberOfObjectives()); + + //Add the individuals of this front + for (int k = 0; k < front->size(); k++) + { + population->add(new Solution(front->get(k))); + } // for + + //Decrement remain + remain = remain - front->size(); + + //Obtain the next front + index++; + if (remain > 0) + { + front = ranking->getSubfront(index); + } // if + + } // while + + // Remain is less than front(index).size, insert only the best one + if (remain > 0) // front contains individuals to insert + { + distance->crowdingDistanceAssignment(front, problem_->getNumberOfObjectives()); + Comparator * c = new CrowdingComparator(); + front->sort(c); + delete c; + for (int k = 0; k < remain; k++) + { + population->add(new Solution(front->get(k))); + } // for + + remain = 0; + } // if + + delete ranking; + delete unionSolution; + + // This piece of code shows how to use the indicator object into the code + // of NSGA-II. In particular, it finds the number of evaluations required + // by the algorithm to obtain a Pareto front with a hypervolume higher + // than the hypervolume of the true Pareto front. // if ((indicators != NULL) && (requiredEvaluations == 0)) { // double HV = indicators->getHypervolume(population); // if (HV >= (0.98 * indicators->getTrueParetoFrontHypervolume())) { @@ -183,22 +195,23 @@ SolutionSet * NSGAII::execute() { // } // if // } // if - } // while + } // while - delete distance; + delete distance; - // Return as output parameter the required evaluations + // Return as output parameter the required evaluations // setOutputParameter("evaluations", &requiredEvaluations); - // Return the first non-dominated front - Ranking * ranking = new Ranking(population); - SolutionSet * result = new SolutionSet(ranking->getSubfront(0)->size()); - for (int i=0;igetSubfront(0)->size();i++) { - result->add(new Solution(ranking->getSubfront(0)->get(i))); - } - delete ranking; - delete population; + // Return the first non-dominated front + Ranking * ranking = new Ranking(population); + SolutionSet * result = new SolutionSet(ranking->getSubfront(0)->size()); + for (int i=0; igetSubfront(0)->size(); i++) + { + result->add(new Solution(ranking->getSubfront(0)->get(i))); + } + delete ranking; + delete population; - return result; + return result; } // execute diff --git a/src/metaheuristics/nsgaII/NSGAII.h b/src/metaheuristics/nsgaII/NSGAII.h index 81f2bef..017e165 100644 --- a/src/metaheuristics/nsgaII/NSGAII.h +++ b/src/metaheuristics/nsgaII/NSGAII.h @@ -34,11 +34,12 @@ * @brief This class implements the NSGA-II algorithm **/ -class NSGAII : public Algorithm { +class NSGAII : public Algorithm +{ public: - NSGAII(Problem * problem); - SolutionSet * execute(); + NSGAII(Problem * problem); + SolutionSet * execute(); }; diff --git a/src/metaheuristics/nsgaII/ssNSGAII.cpp b/src/metaheuristics/nsgaII/ssNSGAII.cpp index 393e6bd..d6ab3cb 100644 --- a/src/metaheuristics/nsgaII/ssNSGAII.cpp +++ b/src/metaheuristics/nsgaII/ssNSGAII.cpp @@ -31,7 +31,8 @@ * Constructor * @param problem Problem to solve */ -ssNSGAII::ssNSGAII(Problem *problem) : Algorithm(problem) { +ssNSGAII::ssNSGAII(Problem *problem) : Algorithm(problem) +{ } // ssNSGAII @@ -40,137 +41,146 @@ ssNSGAII::ssNSGAII(Problem *problem) : Algorithm(problem) { * @return a SolutionSet that is a set of non dominated solutions * as a result of the algorithm execution */ -SolutionSet * ssNSGAII::execute() { - - int populationSize; - int maxEvaluations; - int evaluations; - - // TODO: QualityIndicator indicators; // QualityIndicator object - int requiredEvaluations; // Use in the example of use of the - // indicators object (see below) - - SolutionSet * population; - SolutionSet * offspringPopulation; - SolutionSet * unionSolution; - - Operator * mutationOperator; - Operator * crossoverOperator; - Operator * selectionOperator; - - Distance * distance = new Distance(); - - //Read the parameters - populationSize = *(int *) getInputParameter("populationSize"); - maxEvaluations = *(int *) getInputParameter("maxEvaluations"); - // TODO: indicators = (QualityIndicator) getInputParameter("indicators"); - - //Initialize the variables - population = new SolutionSet(populationSize); - evaluations = 0; - - requiredEvaluations = 0; - - //Read the operators - mutationOperator = operators_["mutation"]; - crossoverOperator = operators_["crossover"]; - selectionOperator = operators_["selection"]; - - // Create the initial solutionSet - Solution * newSolution; - for (int i = 0; i < populationSize; i++) { - newSolution = new Solution(problem_); - problem_->evaluate(newSolution); - problem_->evaluateConstraints(newSolution); - evaluations++; - population->add(newSolution); - } //for - - // Generations - while (evaluations < maxEvaluations) { - - // Create the offSpring solutionSet - offspringPopulation = new SolutionSet(populationSize); - Solution ** parents = new Solution*[2]; - - //obtain parents - parents[0] = (Solution *) (selectionOperator->execute(population)); - parents[1] = (Solution *) (selectionOperator->execute(population)); - - // crossover - Solution ** offSpring = (Solution **) (crossoverOperator->execute(parents)); - - // mutation - mutationOperator->execute(offSpring[0]); - - // evaluation - problem_->evaluate(offSpring[0]); - problem_->evaluateConstraints(offSpring[0]); - - // insert child into the offspring population - offspringPopulation->add(offSpring[0]); - - evaluations ++; - delete offSpring[1]; - delete[] offSpring; - delete[] parents; - - // Create the solutionSet union of solutionSet and offSpring - unionSolution = population->join(offspringPopulation); - delete offspringPopulation; - - // Ranking the union - Ranking * ranking = new Ranking(unionSolution); - - int remain = populationSize; - int index = 0; - SolutionSet * front = NULL; - for (int i=0;isize();i++) { - delete population->get(i); - } - population->clear(); - - // Obtain the next front - front = ranking->getSubfront(index); - - while ((remain > 0) && (remain >= front->size())) { - //Assign crowding distance to individuals - distance->crowdingDistanceAssignment(front, problem_->getNumberOfObjectives()); - //Add the individuals of this front - for (int k = 0; k < front->size(); k++) { - population->add(new Solution(front->get(k))); - } // for - - //Decrement remain - remain = remain - front->size(); - - //Obtain the next front - index++; - if (remain > 0) { +SolutionSet * ssNSGAII::execute() +{ + + int populationSize; + int maxEvaluations; + int evaluations; + + // TODO: QualityIndicator indicators; // QualityIndicator object + int requiredEvaluations; // Use in the example of use of the + // indicators object (see below) + + SolutionSet * population; + SolutionSet * offspringPopulation; + SolutionSet * unionSolution; + + Operator * mutationOperator; + Operator * crossoverOperator; + Operator * selectionOperator; + + Distance * distance = new Distance(); + + //Read the parameters + populationSize = *(int *) getInputParameter("populationSize"); + maxEvaluations = *(int *) getInputParameter("maxEvaluations"); + // TODO: indicators = (QualityIndicator) getInputParameter("indicators"); + + //Initialize the variables + population = new SolutionSet(populationSize); + evaluations = 0; + + requiredEvaluations = 0; + + //Read the operators + mutationOperator = operators_["mutation"]; + crossoverOperator = operators_["crossover"]; + selectionOperator = operators_["selection"]; + + // Create the initial solutionSet + Solution * newSolution; + for (int i = 0; i < populationSize; i++) + { + newSolution = new Solution(problem_); + problem_->evaluate(newSolution); + problem_->evaluateConstraints(newSolution); + evaluations++; + population->add(newSolution); + } //for + + // Generations + while (evaluations < maxEvaluations) + { + + // Create the offSpring solutionSet + offspringPopulation = new SolutionSet(populationSize); + Solution ** parents = new Solution*[2]; + + //obtain parents + parents[0] = (Solution *) (selectionOperator->execute(population)); + parents[1] = (Solution *) (selectionOperator->execute(population)); + + // crossover + Solution ** offSpring = (Solution **) (crossoverOperator->execute(parents)); + + // mutation + mutationOperator->execute(offSpring[0]); + + // evaluation + problem_->evaluate(offSpring[0]); + problem_->evaluateConstraints(offSpring[0]); + + // insert child into the offspring population + offspringPopulation->add(offSpring[0]); + + evaluations ++; + delete offSpring[1]; + delete[] offSpring; + delete[] parents; + + // Create the solutionSet union of solutionSet and offSpring + unionSolution = population->join(offspringPopulation); + delete offspringPopulation; + + // Ranking the union + Ranking * ranking = new Ranking(unionSolution); + + int remain = populationSize; + int index = 0; + SolutionSet * front = NULL; + for (int i=0; isize(); i++) + { + delete population->get(i); + } + population->clear(); + + // Obtain the next front front = ranking->getSubfront(index); - } // if - } // while - - // Remain is less than front(index).size, insert only the best one - if (remain > 0) { // front contains individuals to insert - distance->crowdingDistanceAssignment(front, problem_->getNumberOfObjectives()); - Comparator * c = new CrowdingComparator(); - front->sort(c); - delete c; - for (int k = 0; k < remain; k++) { - population->add(new Solution(front->get(k))); - } // for - remain = 0; - } // if - - delete ranking; - delete unionSolution; - - // This piece of code shows how to use the indicator object into the code - // of NSGA-II. In particular, it finds the number of evaluations required - // by the algorithm to obtain a Pareto front with a hypervolume higher - // than the hypervolume of the true Pareto front. + while ((remain > 0) && (remain >= front->size())) + { + //Assign crowding distance to individuals + distance->crowdingDistanceAssignment(front, problem_->getNumberOfObjectives()); + //Add the individuals of this front + for (int k = 0; k < front->size(); k++) + { + population->add(new Solution(front->get(k))); + } // for + + //Decrement remain + remain = remain - front->size(); + + //Obtain the next front + index++; + if (remain > 0) + { + front = ranking->getSubfront(index); + } // if + } // while + + // Remain is less than front(index).size, insert only the best one + if (remain > 0) // front contains individuals to insert + { + distance->crowdingDistanceAssignment(front, problem_->getNumberOfObjectives()); + Comparator * c = new CrowdingComparator(); + front->sort(c); + delete c; + for (int k = 0; k < remain; k++) + { + population->add(new Solution(front->get(k))); + } // for + + remain = 0; + } // if + + delete ranking; + delete unionSolution; + + // This piece of code shows how to use the indicator object into the code + // of NSGA-II. In particular, it finds the number of evaluations required + // by the algorithm to obtain a Pareto front with a hypervolume higher + // than the hypervolume of the true Pareto front. // TODO: // if ((indicators != NULL) && // (requiredEvaluations == 0)) { @@ -180,23 +190,24 @@ SolutionSet * ssNSGAII::execute() { // } // if // } // if - } // while + } // while - delete distance; + delete distance; - // Return as output parameter the required evaluations - // TODO: - //setOutputParameter("evaluations", requiredEvaluations); + // Return as output parameter the required evaluations + // TODO: + //setOutputParameter("evaluations", requiredEvaluations); - // Return the first non-dominated front - Ranking * ranking = new Ranking(population); - SolutionSet * result = new SolutionSet(ranking->getSubfront(0)->size()); - for (int i=0;igetSubfront(0)->size();i++) { - result->add(new Solution(ranking->getSubfront(0)->get(i))); - } - delete ranking; - delete population; + // Return the first non-dominated front + Ranking * ranking = new Ranking(population); + SolutionSet * result = new SolutionSet(ranking->getSubfront(0)->size()); + for (int i=0; igetSubfront(0)->size(); i++) + { + result->add(new Solution(ranking->getSubfront(0)->get(i))); + } + delete ranking; + delete population; - return result; + return result; } // execute diff --git a/src/metaheuristics/nsgaII/ssNSGAII.h b/src/metaheuristics/nsgaII/ssNSGAII.h index ac53855..9756090 100644 --- a/src/metaheuristics/nsgaII/ssNSGAII.h +++ b/src/metaheuristics/nsgaII/ssNSGAII.h @@ -34,16 +34,17 @@ * @brief This class implements a steady-state version of NSGA-II. **/ -class ssNSGAII : public Algorithm { +class ssNSGAII : public Algorithm +{ private: - int populationSize_; - int maxEvaluations_; - //QualityIndicator *indicators_; + int populationSize_; + int maxEvaluations_; + //QualityIndicator *indicators_; public: - ssNSGAII(Problem * problem); - SolutionSet * execute(); + ssNSGAII(Problem * problem); + SolutionSet * execute(); }; diff --git a/src/metaheuristics/omopso/OMOPSO.cpp b/src/metaheuristics/omopso/OMOPSO.cpp index b98ab39..762630b 100644 --- a/src/metaheuristics/omopso/OMOPSO.cpp +++ b/src/metaheuristics/omopso/OMOPSO.cpp @@ -31,36 +31,38 @@ * Constructor * @param problem Problem to solve */ -OMOPSO::OMOPSO(Problem *problem) : Algorithm(problem) { +OMOPSO::OMOPSO(Problem *problem) : Algorithm(problem) +{ } // OMOPSO /** * Initialize all parameter of the algorithm */ -void OMOPSO::initParams() { - - particlesSize = *(int *) getInputParameter("swarmSize"); - archiveSize = *(int *) getInputParameter("archiveSize"); - maxIterations = *(int *) getInputParameter("maxIterations"); +void OMOPSO::initParams() +{ - iteration = 0; + particlesSize = *(int *) getInputParameter("swarmSize"); + archiveSize = *(int *) getInputParameter("archiveSize"); + maxIterations = *(int *) getInputParameter("maxIterations"); - particles = new SolutionSet(particlesSize); - best = new Solution*[particlesSize]; - leaders = new CrowdingArchive(archiveSize,problem_->getNumberOfObjectives()); - eArchive = new NonDominatedSolutionList(new EpsilonDominanceComparator(eta)); + iteration = 0; - uniformMutation = operators_["uniformMutation"] ; - nonUniformMutation = operators_["nonUniformMutation"] ; + particles = new SolutionSet(particlesSize); + best = new Solution*[particlesSize]; + leaders = new CrowdingArchive(archiveSize,problem_->getNumberOfObjectives()); + eArchive = new NonDominatedSolutionList(new EpsilonDominanceComparator(eta)); - // Create the dominator for equadless and dominance - dominance = new DominanceComparator(); - crowdingDistanceComparator = new CrowdingDistanceComparator(); - distance = new Distance(); + uniformMutation = operators_["uniformMutation"] ; + nonUniformMutation = operators_["nonUniformMutation"] ; - // Create the speed_ vector - speed = new double*[particlesSize]; + // Create the dominator for equadless and dominance + dominance = new DominanceComparator(); + crowdingDistanceComparator = new CrowdingDistanceComparator(); + distance = new Distance(); + + // Create the speed_ vector + speed = new double*[particlesSize]; } // initParams @@ -68,72 +70,81 @@ void OMOPSO::initParams() { /** * Free all the memory reserved by the algorithm */ -void OMOPSO::deleteParams() { - - for (int i = 0; i < particlesSize; i++) { - delete [] speed[i]; - } - delete [] speed; - delete dominance; - delete crowdingDistanceComparator; - delete distance; - delete particles; - for (int i = 0; i < particlesSize; i++) { - delete best[i]; - } - delete [] best; - delete leaders; - delete eArchive; - +void OMOPSO::deleteParams() +{ + + for (int i = 0; i < particlesSize; i++) + { + delete [] speed[i]; + } + delete [] speed; + delete dominance; + delete crowdingDistanceComparator; + delete distance; + delete particles; + for (int i = 0; i < particlesSize; i++) + { + delete best[i]; + } + delete [] best; + delete leaders; + delete eArchive; + } // deleteParams /** * Update the speed of each particle */ -void OMOPSO::computeSpeed() { - - double r1, r2, W, C1, C2; - XReal *bestGlobal; - - for (int i = 0; i < particlesSize; i++) { - XReal *particle = new XReal(particles->get(i)); - XReal *bestParticle = new XReal(best[i]); - - //Select a global best for calculate the speed of particle i, bestGlobal - Solution *one, *two; - int pos1 = PseudoRandom::randInt(0,leaders->size()-1); - int pos2 = PseudoRandom::randInt(0,leaders->size()-1); - one = leaders->get(pos1); - two = leaders->get(pos2); - - if (crowdingDistanceComparator->compare(one,two) < 1) { - bestGlobal = new XReal(one); - } else { - bestGlobal = new XReal(two); - } +void OMOPSO::computeSpeed() +{ + + double r1, r2, W, C1, C2; + XReal *bestGlobal; + + for (int i = 0; i < particlesSize; i++) + { + XReal *particle = new XReal(particles->get(i)); + XReal *bestParticle = new XReal(best[i]); + + //Select a global best for calculate the speed of particle i, bestGlobal + Solution *one, *two; + int pos1 = PseudoRandom::randInt(0,leaders->size()-1); + int pos2 = PseudoRandom::randInt(0,leaders->size()-1); + one = leaders->get(pos1); + two = leaders->get(pos2); + + if (crowdingDistanceComparator->compare(one,two) < 1) + { + bestGlobal = new XReal(one); + } + else + { + bestGlobal = new XReal(two); + } - //Params for velocity equation - r1 = PseudoRandom::randDouble(); - r2 = PseudoRandom::randDouble(); - C1 = PseudoRandom::randDouble(1.5,2.0); - C2 = PseudoRandom::randDouble(1.5,2.0); - W = PseudoRandom::randDouble(0.1,0.5); - - for (int var = 0; var < particle->getNumberOfDecisionVariables(); var++) { - //Computing the velocity of this particle - speed[i][var] = W * speed[i][var] + - C1 * r1 * (bestParticle->getValue(var) - - particle->getValue(var)) + - C2 * r2 * (bestGlobal->getValue(var) - - particle->getValue(var)); - } + //Params for velocity equation + r1 = PseudoRandom::randDouble(); + r2 = PseudoRandom::randDouble(); + C1 = PseudoRandom::randDouble(1.5,2.0); + C2 = PseudoRandom::randDouble(1.5,2.0); + W = PseudoRandom::randDouble(0.1,0.5); + + for (int var = 0; var < particle->getNumberOfDecisionVariables(); var++) + { + //Computing the velocity of this particle + speed[i][var] = W * speed[i][var] + + C1 * r1 * (bestParticle->getValue(var) - + particle->getValue(var)) + + C2 * r2 * (bestGlobal->getValue(var) - + particle->getValue(var)); + } - delete bestGlobal; - delete particle; - delete bestParticle; + delete bestGlobal; + delete particle; + delete bestParticle; - } + } } // computeSpeed @@ -141,25 +152,30 @@ void OMOPSO::computeSpeed() { /** * Update the position of each particle */ -void OMOPSO::computeNewPositions() { - - for (int i = 0; i < particlesSize; i++) { - XReal * particle = new XReal(particles->get(i)); - //particle.move(speed_[i]); - for (int var = 0; var < particle->getNumberOfDecisionVariables(); var++) { - particle->setValue(var, particle->getValue(var) + speed[i][var]); - - if (particle->getValue(var) < problem_->getLowerLimit(var)) { - particle->setValue(var, problem_->getLowerLimit(var)); - speed[i][var] = speed[i][var] * -1.0; - } - if (particle->getValue(var) > problem_->getUpperLimit(var)){ - particle->setValue(var, problem_->getUpperLimit(var)); - speed[i][var] = speed[i][var] * -1.0; - } +void OMOPSO::computeNewPositions() +{ + + for (int i = 0; i < particlesSize; i++) + { + XReal * particle = new XReal(particles->get(i)); + //particle.move(speed_[i]); + for (int var = 0; var < particle->getNumberOfDecisionVariables(); var++) + { + particle->setValue(var, particle->getValue(var) + speed[i][var]); + + if (particle->getValue(var) < problem_->getLowerLimit(var)) + { + particle->setValue(var, problem_->getLowerLimit(var)); + speed[i][var] = speed[i][var] * -1.0; + } + if (particle->getValue(var) > problem_->getUpperLimit(var)) + { + particle->setValue(var, problem_->getUpperLimit(var)); + speed[i][var] = speed[i][var] * -1.0; + } + } + delete particle; } - delete particle; - } } // computeNewPositions @@ -167,19 +183,25 @@ void OMOPSO::computeNewPositions() { /** * Apply a mutation operator to some particles in the swarm */ -void OMOPSO::mopsoMutation(int actualIteration, int totalIterations) { - // There are three groups of particles_, the ones that are mutated with - // a non-uniform mutation operator, the ones that are mutated with a - // uniform mutation and the one that no are mutated - nonUniformMutation->setParameter("currentIteration", &actualIteration); - - for (int i = 0; i < particles->size();i++) { - if (i % 3 == 0) { //particles_ mutated with a non-uniform mutation - nonUniformMutation->execute(particles->get(i)); - } else if (i % 3 == 1) { //particles_ mutated with a uniform mutation operator - uniformMutation->execute(particles->get(i)); - } else {} //particles_ without mutation - } +void OMOPSO::mopsoMutation(int actualIteration, int totalIterations) +{ + // There are three groups of particles_, the ones that are mutated with + // a non-uniform mutation operator, the ones that are mutated with a + // uniform mutation and the one that no are mutated + nonUniformMutation->setParameter("currentIteration", &actualIteration); + + for (int i = 0; i < particles->size(); i++) + { + if (i % 3 == 0) //particles_ mutated with a non-uniform mutation + { + nonUniformMutation->execute(particles->get(i)); + } + else if (i % 3 == 1) //particles_ mutated with a uniform mutation operator + { + uniformMutation->execute(particles->get(i)); + } + else {} //particles_ without mutation + } } // mopsoMutation @@ -188,104 +210,124 @@ void OMOPSO::mopsoMutation(int actualIteration, int totalIterations) { * @return a SolutionSet that is a set of non dominated solutions * as a result of the algorithm execution */ -SolutionSet *OMOPSO::execute() { - - initParams(); - - //->Step 1 (and 3) Create the initial population and evaluate - for (int i = 0; i < particlesSize; i++){ - Solution *particle = new Solution(problem_); - problem_->evaluate(particle); - problem_->evaluateConstraints(particle); - particles->add(particle); - } - - //-> Step2. Initialize the speed of each particle to 0 - for (int i = 0; i < particlesSize; i++) { - speed[i] = new double[problem_->getNumberOfVariables()]; - for (int j = 0; j < problem_->getNumberOfVariables(); j++) { - speed[i][j] = 0.0; - } - } - - // Step4 and 5 - for (int i = 0; i < particles->size(); i++){ - Solution *particle = new Solution(particles->get(i)); - if (leaders->add(particle)){ - Solution *particle2 = new Solution(particle); - if (eArchive->add(particle2) == false) { - delete particle2; - } - } else { - delete particle; +SolutionSet *OMOPSO::execute() +{ + + initParams(); + + //->Step 1 (and 3) Create the initial population and evaluate + for (int i = 0; i < particlesSize; i++) + { + Solution *particle = new Solution(problem_); + problem_->evaluate(particle); + problem_->evaluateConstraints(particle); + particles->add(particle); } - } - - //-> Step 6. Initialize the memory of each particle - for (int i = 0; i < particles->size(); i++){ - Solution *particle = new Solution(particles->get(i)); - best[i] = particle; - } - - //Crowding the leaders_ - distance->crowdingDistanceAssignment(leaders, problem_->getNumberOfObjectives()); - - //-> Step 7. Iterations .. - while (iteration < maxIterations) { - - //Compute the speed_ - computeSpeed(); - - //Compute the new positions for the particles_ - computeNewPositions(); - - //Mutate the particles_ - mopsoMutation(iteration,maxIterations); - - //Evaluate the new particles in new positions - for (int i = 0; i < particles->size(); i++){ - Solution *particle = particles->get(i); - problem_->evaluate(particle); - problem_->evaluateConstraints(particle); + + //-> Step2. Initialize the speed of each particle to 0 + for (int i = 0; i < particlesSize; i++) + { + speed[i] = new double[problem_->getNumberOfVariables()]; + for (int j = 0; j < problem_->getNumberOfVariables(); j++) + { + speed[i][j] = 0.0; + } } - //Update the archive - for (int i = 0; i < particles->size(); i++) { - Solution *particle = new Solution(particles->get(i)); - if (leaders->add(particle)) { - Solution *particle2 = new Solution(particle); - if (eArchive->add(particle2) == false) { - delete particle2; + // Step4 and 5 + for (int i = 0; i < particles->size(); i++) + { + Solution *particle = new Solution(particles->get(i)); + if (leaders->add(particle)) + { + Solution *particle2 = new Solution(particle); + if (eArchive->add(particle2) == false) + { + delete particle2; + } + } + else + { + delete particle; } - } else { - delete particle; - } } - //Update the memory of this particle - for (int i = 0; i < particles->size(); i++) { - int flag = dominance->compare(particles->get(i), best[i]); - if (flag != 1) { // the new particle is best_ than the older remembered + //-> Step 6. Initialize the memory of each particle + for (int i = 0; i < particles->size(); i++) + { Solution *particle = new Solution(particles->get(i)); - delete best[i]; best[i] = particle; - } } - - //Assign crowding distance to the leaders_ - distance->crowdingDistanceAssignment(leaders, - problem_->getNumberOfObjectives()); - iteration++; - } - - // Build the solution set result - SolutionSet *result = new SolutionSet(leaders->size()); - for (int i=0;isize();i++) { - result->add(new Solution(leaders->get(i))); - } - - // Free memory - deleteParams(); - - return result; + + //Crowding the leaders_ + distance->crowdingDistanceAssignment(leaders, problem_->getNumberOfObjectives()); + + //-> Step 7. Iterations .. + while (iteration < maxIterations) + { + + //Compute the speed_ + computeSpeed(); + + //Compute the new positions for the particles_ + computeNewPositions(); + + //Mutate the particles_ + mopsoMutation(iteration,maxIterations); + + //Evaluate the new particles in new positions + for (int i = 0; i < particles->size(); i++) + { + Solution *particle = particles->get(i); + problem_->evaluate(particle); + problem_->evaluateConstraints(particle); + } + + //Update the archive + for (int i = 0; i < particles->size(); i++) + { + Solution *particle = new Solution(particles->get(i)); + if (leaders->add(particle)) + { + Solution *particle2 = new Solution(particle); + if (eArchive->add(particle2) == false) + { + delete particle2; + } + } + else + { + delete particle; + } + } + + //Update the memory of this particle + for (int i = 0; i < particles->size(); i++) + { + int flag = dominance->compare(particles->get(i), best[i]); + if (flag != 1) // the new particle is best_ than the older remembered + { + Solution *particle = new Solution(particles->get(i)); + delete best[i]; + best[i] = particle; + } + } + + //Assign crowding distance to the leaders_ + distance->crowdingDistanceAssignment(leaders, + problem_->getNumberOfObjectives()); + iteration++; + } + + // Build the solution set result + SolutionSet *result = new SolutionSet(leaders->size()); + for (int i=0; isize(); i++) + { + result->add(new Solution(leaders->get(i))); + } + + // Free memory + deleteParams(); + + return result; } // execute diff --git a/src/metaheuristics/omopso/OMOPSO.h b/src/metaheuristics/omopso/OMOPSO.h index 493a538..33e1c57 100644 --- a/src/metaheuristics/omopso/OMOPSO.h +++ b/src/metaheuristics/omopso/OMOPSO.h @@ -34,130 +34,131 @@ /** * This class implements an asynchronous version of OMOPSO algorithm */ -class OMOPSO : public Algorithm { - +class OMOPSO : public Algorithm +{ + private: - - /** - * Stores the number of particles used - */ - int particlesSize; - - /** - * Stores the maximum size for the archive - */ - int archiveSize; - - /** - * Stores the maximum number of iteration_ - */ - int maxIterations; - - /** - * Stores the current number of iteration_ - */ - int iteration; - - /** - * Stores the perturbation used by the non-uniform mutation - */ - double perturbation; - - /** - * Stores the particles - */ - SolutionSet *particles; - - /** - * Stores the best solutions founds so far for each particles - */ - Solution **best; - - /** - * Stores the leaders - */ - CrowdingArchive *leaders; - - /** - * Stores the epsilon-archive - */ - NonDominatedSolutionList *eArchive; - - /** - * Stores the speed of each particle - */ - double **speed; - - /** - * Stores a comparator for checking dominance - */ - Comparator *dominance; - - /** - * Stores a comparator for crowding checking - */ - Comparator *crowdingDistanceComparator; - - /** - * Stores a Distance object - */ - Distance *distance; - - /** - * Stores a operator for uniform mutations - */ - Operator *uniformMutation; - - /** - * Stores a operator for non uniform mutations - */ - Operator *nonUniformMutation; - - /** - * eta_ value - */ - double eta = 0.0075; - - /** - * Initialize all parameter of the algorithm - */ - void initParams(); - - /** - * Free all the memory reserved by the algorithm - */ - void deleteParams(); - - /** - * Update the speed of each particle - */ - void computeSpeed(); - - /** - * Update the position of each particle - */ - void computeNewPositions(); - - /** - * Apply a mutation operator to some particles in the swarm - */ - void mopsoMutation(int actualIteration, int totalIterations); - + + /** + * Stores the number of particles used + */ + int particlesSize; + + /** + * Stores the maximum size for the archive + */ + int archiveSize; + + /** + * Stores the maximum number of iteration_ + */ + int maxIterations; + + /** + * Stores the current number of iteration_ + */ + int iteration; + + /** + * Stores the perturbation used by the non-uniform mutation + */ + double perturbation; + + /** + * Stores the particles + */ + SolutionSet *particles; + + /** + * Stores the best solutions founds so far for each particles + */ + Solution **best; + + /** + * Stores the leaders + */ + CrowdingArchive *leaders; + + /** + * Stores the epsilon-archive + */ + NonDominatedSolutionList *eArchive; + + /** + * Stores the speed of each particle + */ + double **speed; + + /** + * Stores a comparator for checking dominance + */ + Comparator *dominance; + + /** + * Stores a comparator for crowding checking + */ + Comparator *crowdingDistanceComparator; + + /** + * Stores a Distance object + */ + Distance *distance; + + /** + * Stores a operator for uniform mutations + */ + Operator *uniformMutation; + + /** + * Stores a operator for non uniform mutations + */ + Operator *nonUniformMutation; + + /** + * eta_ value + */ + double eta = 0.0075; + + /** + * Initialize all parameter of the algorithm + */ + void initParams(); + + /** + * Free all the memory reserved by the algorithm + */ + void deleteParams(); + + /** + * Update the speed of each particle + */ + void computeSpeed(); + + /** + * Update the position of each particle + */ + void computeNewPositions(); + + /** + * Apply a mutation operator to some particles in the swarm + */ + void mopsoMutation(int actualIteration, int totalIterations); + public: - - /** - * Constructor - * @param problem Problem to solve - */ - OMOPSO(Problem *problem); - - /** - * Runs of the SMPSO algorithm. - * @return a SolutionSet that is a set of non dominated solutions - * as a result of the algorithm execution - */ - SolutionSet *execute(); - + + /** + * Constructor + * @param problem Problem to solve + */ + OMOPSO(Problem *problem); + + /** + * Runs of the SMPSO algorithm. + * @return a SolutionSet that is a set of non dominated solutions + * as a result of the algorithm execution + */ + SolutionSet *execute(); + }; #endif /* OMOPSO_H_ */ diff --git a/src/metaheuristics/paes/paes.cpp b/src/metaheuristics/paes/paes.cpp index 8517171..7444b24 100644 --- a/src/metaheuristics/paes/paes.cpp +++ b/src/metaheuristics/paes/paes.cpp @@ -21,12 +21,12 @@ #include - /** - * Create a new PAES instance for resolve a problem - * @param problem Problem to solve - */ +/** + * Create a new PAES instance for resolve a problem + * @param problem Problem to solve + */ -paes::paes(Problem * problem) : Algorithm(problem){ } +paes::paes(Problem * problem) : Algorithm(problem) { } /** * Tests two solutions to determine which one becomes be the guide of PAES @@ -36,34 +36,39 @@ paes::paes(Problem * problem) : Algorithm(problem){ } */ Solution * paes::test(Solution * solution, Solution * mutatedSolution, - AdaptiveGridArchive * archive){ + AdaptiveGridArchive * archive) +{ int originalLocation = archive->getGrid()->location(solution); int mutatedLocation = archive->getGrid()->location(mutatedSolution); - if (originalLocation == -1) { - return new Solution(mutatedSolution); + if (originalLocation == -1) + { + return new Solution(mutatedSolution); } - if (mutatedLocation == -1) { - return new Solution(solution); + if (mutatedLocation == -1) + { + return new Solution(solution); } if (archive->getGrid()->getLocationDensity(mutatedLocation) < - archive->getGrid()->getLocationDensity(originalLocation)) { - return new Solution(mutatedSolution); + archive->getGrid()->getLocationDensity(originalLocation)) + { + return new Solution(mutatedSolution); } return new Solution(solution); - } // test +} // test - /** - * Runs of the Paes algorithm. - * @return a SolutionSet that is a set of non dominated solutions - * as a result of the algorithm execution - */ +/** +* Runs of the Paes algorithm. +* @return a SolutionSet that is a set of non dominated solutions +* as a result of the algorithm execution +*/ -SolutionSet * paes::execute() { +SolutionSet * paes::execute() +{ int bisections, archiveSize, maxEvaluations, evaluations; AdaptiveGridArchive * archive; @@ -94,32 +99,38 @@ SolutionSet * paes::execute() { archive->add(new Solution(solution),evaluations ); //Iterations.... - do { - // Create the mutate one - Solution * mutatedIndividual = new Solution(solution); - mutationOperator->execute(mutatedIndividual); - - problem_->evaluate(mutatedIndividual); - problem_->evaluateConstraints(mutatedIndividual); - evaluations++; - //<- - - // Check dominance - int flag = dominance->compare(solution,mutatedIndividual); - - if (flag == 1) { //If mutate solution dominate - solution = new Solution(mutatedIndividual); - archive->add(mutatedIndividual,evaluations ); - } else if (flag == 0) { //If none dominate the other - if (archive->add(mutatedIndividual,evaluations )) { - solution = test(solution,mutatedIndividual,archive); + do + { + // Create the mutate one + Solution * mutatedIndividual = new Solution(solution); + mutationOperator->execute(mutatedIndividual); + + problem_->evaluate(mutatedIndividual); + problem_->evaluateConstraints(mutatedIndividual); + evaluations++; + //<- + + // Check dominance + int flag = dominance->compare(solution,mutatedIndividual); + + if (flag == 1) //If mutate solution dominate + { + solution = new Solution(mutatedIndividual); + archive->add(mutatedIndividual,evaluations ); + } + else if (flag == 0) //If none dominate the other + { + if (archive->add(mutatedIndividual,evaluations )) + { + solution = test(solution,mutatedIndividual,archive); + } } - } - } while (evaluations < maxEvaluations); + } + while (evaluations < maxEvaluations); //Return the population of non-dominated solution return archive; - } // execute +} // execute diff --git a/src/metaheuristics/paes/paes.h b/src/metaheuristics/paes/paes.h index b675b04..10fe7bd 100644 --- a/src/metaheuristics/paes/paes.h +++ b/src/metaheuristics/paes/paes.h @@ -27,12 +27,13 @@ #include #include -class paes : public Algorithm { +class paes : public Algorithm +{ public: - paes(Problem * problem); - Solution * test(Solution * solution,Solution * mutatedSolution, - AdaptiveGridArchive * archive); + paes(Problem * problem); + Solution * test(Solution * solution,Solution * mutatedSolution, + AdaptiveGridArchive * archive); SolutionSet * execute(); }; diff --git a/src/metaheuristics/singleObjective/cmaes/CMAES.cpp b/src/metaheuristics/singleObjective/cmaes/CMAES.cpp index b0ab8c6..11f599a 100644 --- a/src/metaheuristics/singleObjective/cmaes/CMAES.cpp +++ b/src/metaheuristics/singleObjective/cmaes/CMAES.cpp @@ -31,461 +31,527 @@ * Constructor * @param problem Problem to solve */ -CMAES::CMAES(Problem *problem) : Algorithm(problem) { - bestSolutionEver = NULL; +CMAES::CMAES(Problem *problem) : Algorithm(problem) +{ + bestSolutionEver = NULL; } // CMAES -SolutionSet * CMAES::execute() { - - - //Read the parameters - populationSize = *(int *) getInputParameter("populationSize"); - maxEvaluations = *(int *) getInputParameter("maxEvaluations"); - - //Initialize the variables - counteval = 0; - - Comparator * comparator = new ObjectiveComparator(0); - - init(); - - // iteration loop - while (counteval < maxEvaluations) { - - // --- core iteration step --- - population_ = samplePopulation(); // get a new population of solutions - - for(int i = 0; i < populationSize; i++) { - if (!isFeasible(population_->get(i))) { - //cout << "RESAMPLING!" << endl; - population_->replace(i, resampleSingle(i)); - } - problem_->evaluate(population_->get(i)); +SolutionSet * CMAES::execute() +{ + + + //Read the parameters + populationSize = *(int *) getInputParameter("populationSize"); + maxEvaluations = *(int *) getInputParameter("maxEvaluations"); + + //Initialize the variables + counteval = 0; + + Comparator * comparator = new ObjectiveComparator(0); + + init(); + + // iteration loop + while (counteval < maxEvaluations) + { + + // --- core iteration step --- + population_ = samplePopulation(); // get a new population of solutions + + for(int i = 0; i < populationSize; i++) + { + if (!isFeasible(population_->get(i))) + { + //cout << "RESAMPLING!" << endl; + population_->replace(i, resampleSingle(i)); + } + problem_->evaluate(population_->get(i)); + } + counteval += populationSize; + + storeBest(comparator); + //cout << counteval << ": " << bestSolutionEver->getObjective(0) << endl; + updateDistribution(); + + delete population_; + } - counteval += populationSize; - - storeBest(comparator); - //cout << counteval << ": " << bestSolutionEver->getObjective(0) << endl; - updateDistribution(); - - delete population_; - - } - - deleteParams(); - - delete comparator ; - - SolutionSet * resultPopulation = new SolutionSet(1) ; - resultPopulation->add(bestSolutionEver) ; - - return resultPopulation ; - + + deleteParams(); + + delete comparator ; + + SolutionSet * resultPopulation = new SolutionSet(1) ; + resultPopulation->add(bestSolutionEver) ; + + return resultPopulation ; + } // execute -void CMAES::init() { - - /*User defined input parameters */ - - // number of objective variables/problem dimension - int N = problem_->getNumberOfVariables(); - - // objective variables initial point - default_random_engine generator; - xmean = new double[N]; - for (int i = 0; i < N; i++) { - double stddev = (problem_->getUpperLimit(i) - problem_->getLowerLimit(i)) /2; - double mean = problem_->getLowerLimit(i) + stddev; - normal_distribution distribution(mean,stddev/2); - xmean[i] = distribution(generator); - //xmean[i] = PseudoRandom::randDouble(0, 1); - } - - // coordinate wise standard deviation (step size) - sigma = 0.3; - //sigma = 1; - - /* Strategy parameter setting: Selection */ - - // population size, offspring number - int lambda = populationSize; - //lambda = 4+Math.floor(3*Math.log(N)); - - // number of parents/points for recombination - mu = (int) floor(lambda/2); - - // muXone array for weighted recombination - weights = new double[mu]; - double sum = 0; - for (int i=0; igetNumberOfVariables(); + + // objective variables initial point + default_random_engine generator; + xmean = new double[N]; + for (int i = 0; i < N; i++) + { + double stddev = (problem_->getUpperLimit(i) - problem_->getLowerLimit(i)) /2; + double mean = problem_->getLowerLimit(i) + stddev; + normal_distribution distribution(mean,stddev/2); + xmean[i] = distribution(generator); + //xmean[i] = PseudoRandom::randDouble(0, 1); + } + + // coordinate wise standard deviation (step size) + sigma = 0.3; + //sigma = 1; + + /* Strategy parameter setting: Selection */ + + // population size, offspring number + int lambda = populationSize; + //lambda = 4+Math.floor(3*Math.log(N)); + + // number of parents/points for recombination + mu = (int) floor(lambda/2); + + // muXone array for weighted recombination + weights = new double[mu]; + double sum = 0; + for (int i=0; i distribution(0.0,1.0); - - int N = problem_->getNumberOfVariables(); - double * artmp = new double[N]; - double sum; - - for (int iNk = 0; iNk < populationSize; iNk++) { - - for (int i = 0; i < N; i++) { - //artmp[i] = diagD[i] * PseudoRandom::randDouble(-2, 2); - artmp[i] = diagD[i] * distribution(generator); + // B defines the coordinate system + B = new double*[N]; + // covariance matrix C + C = new double*[N]; + for (int i = 0; i < N; i++) + { + B[i] = new double[N]; + C[i] = new double[N]; } - for (int i = 0; i < N; i++) { - sum = 0.0; - for (int j = 0; j < N; j++) { - sum += B[i][j] * artmp[j]; - } - arx[iNk][i] = xmean[i] + sigma * sum; + + // C^-1/2 + invsqrtC = new double*[N]; + for (int i = 0; i < N; i++) + { + invsqrtC[i] = new double[N]; + pc[i] = 0; + ps[i] = 0; + diagD[i] = 1; + for (int j = 0; j < N; j++) + { + B[i][j] = 0; + invsqrtC[i][j] = 0; + } + for (int j = 0; j < i; j++) + { + C[i][j] = 0; + } + B[i][i] = 1; + C[i][i] = diagD[i] * diagD[i]; + invsqrtC[i][i] = 1; + } + + // track update of B and D + eigeneval = 0; + + chiN = sqrt(N) * ( 1 - 1/(4*N) + 1/(21*N*N) ); + + /* non-settable parameters */ + + xold = new double[N]; + arx = new double*[lambda]; + for (int i = 0; i < lambda; i++) + { + arx[i] = new double[N]; } - } - - delete [] artmp; - - return genoPhenoTransformation(arx); - + +} // init + + +SolutionSet * CMAES::samplePopulation() +{ + + default_random_engine generator; + normal_distribution distribution(0.0,1.0); + + int N = problem_->getNumberOfVariables(); + double * artmp = new double[N]; + double sum; + + for (int iNk = 0; iNk < populationSize; iNk++) + { + + for (int i = 0; i < N; i++) + { + //artmp[i] = diagD[i] * PseudoRandom::randDouble(-2, 2); + artmp[i] = diagD[i] * distribution(generator); + } + for (int i = 0; i < N; i++) + { + sum = 0.0; + for (int j = 0; j < N; j++) + { + sum += B[i][j] * artmp[j]; + } + arx[iNk][i] = xmean[i] + sigma * sum; + } + } + + delete [] artmp; + + return genoPhenoTransformation(arx); + } // samplePopulation -SolutionSet * CMAES::genoPhenoTransformation(double ** popx) { +SolutionSet * CMAES::genoPhenoTransformation(double ** popx) +{ - SolutionSet * population_ = new SolutionSet(populationSize); - for (int i = 0; i < populationSize; i++) { - Solution * solution = new Solution(problem_); - for (int j = 0; j < problem_->getNumberOfVariables(); j++) { - solution->getDecisionVariables()[j]->setValue(popx[i][j]); + SolutionSet * population_ = new SolutionSet(populationSize); + for (int i = 0; i < populationSize; i++) + { + Solution * solution = new Solution(problem_); + for (int j = 0; j < problem_->getNumberOfVariables(); j++) + { + solution->getDecisionVariables()[j]->setValue(popx[i][j]); + } + population_->add(solution); } - population_->add(solution); - } - return population_; + return population_; } // genoPhenoTransformation -bool CMAES::isFeasible(Solution * solution) { +bool CMAES::isFeasible(Solution * solution) +{ - bool res = true; - Variable ** x = solution->getDecisionVariables(); + bool res = true; + Variable ** x = solution->getDecisionVariables(); - for (int i = 0; i < problem_->getNumberOfVariables(); i++) { - double value = x[i]->getValue(); - if ((value < problem_->getLowerLimit(i)) || (value > problem_->getUpperLimit(i))) { - res = false; + for (int i = 0; i < problem_->getNumberOfVariables(); i++) + { + double value = x[i]->getValue(); + if ((value < problem_->getLowerLimit(i)) || (value > problem_->getUpperLimit(i))) + { + res = false; + } } - } - return res; + return res; } // isFeasible -Solution * CMAES::resampleSingle(int iNk) { +Solution * CMAES::resampleSingle(int iNk) +{ - for (int i = 0; i < problem_->getNumberOfVariables(); i++) { - if (arx[iNk][i] > problem_->getUpperLimit(i)) { - arx[iNk][i] = problem_->getUpperLimit(i); - } else if (arx[iNk][i] < problem_->getLowerLimit(i)) { - arx[iNk][i] = problem_->getLowerLimit(i); + for (int i = 0; i < problem_->getNumberOfVariables(); i++) + { + if (arx[iNk][i] > problem_->getUpperLimit(i)) + { + arx[iNk][i] = problem_->getUpperLimit(i); + } + else if (arx[iNk][i] < problem_->getLowerLimit(i)) + { + arx[iNk][i] = problem_->getLowerLimit(i); + } } - } - return genoPhenoTransformation(arx[iNk]); + return genoPhenoTransformation(arx[iNk]); } // resampleSingle -Solution * CMAES::genoPhenoTransformation(double * x) { +Solution * CMAES::genoPhenoTransformation(double * x) +{ - Solution * solution = new Solution(problem_); - for (int i = 0; i < problem_->getNumberOfVariables(); i++) { - solution->getDecisionVariables()[i]->setValue(x[i]); - } - return solution; + Solution * solution = new Solution(problem_); + for (int i = 0; i < problem_->getNumberOfVariables(); i++) + { + solution->getDecisionVariables()[i]->setValue(x[i]); + } + return solution; } // genoPhenoTransformation -void CMAES::storeBest(Comparator * comparator) { +void CMAES::storeBest(Comparator * comparator) +{ - Solution * bestInPopulation = new Solution(population_->best(comparator)); - if ((bestSolutionEver == NULL) || - (bestSolutionEver->getObjective(0) - > bestInPopulation->getObjective(0))) { - if (bestSolutionEver != NULL) { - delete bestSolutionEver; + Solution * bestInPopulation = new Solution(population_->best(comparator)); + if ((bestSolutionEver == NULL) || + (bestSolutionEver->getObjective(0) + > bestInPopulation->getObjective(0))) + { + if (bestSolutionEver != NULL) + { + delete bestSolutionEver; + } + bestSolutionEver = bestInPopulation; + } + else + { + delete bestInPopulation; } - bestSolutionEver = bestInPopulation; - } else { - delete bestInPopulation; - } } // storeBest - - -void CMAES::updateDistribution() { - - int N = problem_->getNumberOfVariables(); - int lambda = populationSize; - - double * arfitness = new double[lambda]; - int * arindex = new int[lambda]; - - /* Sort by fitness and compute weighted mean into xmean */ - - //minimization - for (int i = 0; i < lambda; i++) { - arfitness[i] = population_->get(i)->getObjective(0); - arindex[i] = i; - } - UtilsCMAES::minFastSort(arfitness, arindex, lambda); - - // calculate xmean and BDz~N(0,C) - for (int i = 0; i < N; i++) { - xold[i] = xmean[i]; - xmean[i] = 0.; - for (int iNk = 0; iNk < mu; iNk++) { - xmean[i] += weights[iNk] * arx[arindex[iNk]][i]; + + +void CMAES::updateDistribution() +{ + + int N = problem_->getNumberOfVariables(); + int lambda = populationSize; + + double * arfitness = new double[lambda]; + int * arindex = new int[lambda]; + + /* Sort by fitness and compute weighted mean into xmean */ + + //minimization + for (int i = 0; i < lambda; i++) + { + arfitness[i] = population_->get(i)->getObjective(0); + arindex[i] = i; } - //BDz[i] = sqrt(sp->getMueff()) * (xmean[i] - xold[i]) / sigma; - } - - /* Cumulation: Update evolution paths */ - - double * artmp = new double[N]; - for (int i = 0; i < N; i++) { - artmp[i] = 0; - //double value = (xmean[i] - xold[i]) / sigma; - for (int j = 0; j < N; j++) { - //artmp[i] += invsqrtC[i][j] * value; - artmp[i] += invsqrtC[i][j] * (xmean[j] - xold[j]) / sigma; + UtilsCMAES::minFastSort(arfitness, arindex, lambda); + + // calculate xmean and BDz~N(0,C) + for (int i = 0; i < N; i++) + { + xold[i] = xmean[i]; + xmean[i] = 0.; + for (int iNk = 0; iNk < mu; iNk++) + { + xmean[i] += weights[iNk] * arx[arindex[iNk]][i]; + } + //BDz[i] = sqrt(sp->getMueff()) * (xmean[i] - xold[i]) / sigma; } - } - // cumulation for sigma (ps) - for (int i = 0; i < N; i++) { - ps[i] = (1. - cs) * ps[i] - + sqrt(cs * (2. - cs) * mueff) - * artmp[i]; - } - - // calculate norm(ps)^2 - double psxps = 0.0; - for (int i = 0; i < N; i++) { - psxps += ps[i] * ps[i]; - } - - // cumulation for covariance matrix (pc) - int hsig = 0; - if ((sqrt(psxps) / sqrt(1. - pow(1. - cs, 2. * counteval/lambda)) / chiN) - < (1.4 + 2. / (N + 1.))) { - hsig = 1; - } - for (int i = 0; i < N; i++) { - pc[i] = (1. - cc) * pc[i] - + hsig * sqrt(cc * (2. - cc) * mueff) * (xmean[i] - xold[i]) / sigma; - } - - /* Adapt covariance matrix C */ - - for (int i = 0; i < N; i++) { - for (int j = 0; j <= i; j++) { - C[i][j] = (1 - c1 -cmu) - * C[i][j] - + c1 - * (pc[i] * pc[j] + (1 - hsig) * cc - * (2. - cc) * C[i][j]); - for (int k = 0; k < mu; k++) { - /* - * additional rank mu - * update - */ - C[i][j] += cmu - * weights[k] - * (arx[arindex[k]][i] - xold[i]) - * (arx[arindex[k]][j] - xold[j]) / sigma - / sigma; - } + + /* Cumulation: Update evolution paths */ + + double * artmp = new double[N]; + for (int i = 0; i < N; i++) + { + artmp[i] = 0; + //double value = (xmean[i] - xold[i]) / sigma; + for (int j = 0; j < N; j++) + { + //artmp[i] += invsqrtC[i][j] * value; + artmp[i] += invsqrtC[i][j] * (xmean[j] - xold[j]) / sigma; + } } - } - - /* Adapt step size sigma */ - - sigma *= exp((cs/damps) * (sqrt(psxps)/chiN - 1)); - - /* Decomposition of C into B*diag(D.^2)*B' (diagonalization) */ - - if (counteval - eigeneval > lambda /(c1+cmu)/N/10) { // to achieve O(N^2) - - eigeneval = counteval; - - // enforce symmetry - for (int i = 0; i < N; i++) { - for (int j = 0; j <= i; j++) { - B[i][j] = B[j][i] = C[i][j]; - } + // cumulation for sigma (ps) + for (int i = 0; i < N; i++) + { + ps[i] = (1. - cs) * ps[i] + + sqrt(cs * (2. - cs) * mueff) + * artmp[i]; } - - // eigen decomposition, B==normalized eigenvectors - double * offdiag = new double[N]; - UtilsCMAES::tred2(N, B, diagD, offdiag); - UtilsCMAES::tql2(N, diagD, offdiag, B); - if (UtilsCMAES::checkEigenSystem(N, C, diagD, B) > 0) { // for debugging - counteval = maxEvaluations; + + // calculate norm(ps)^2 + double psxps = 0.0; + for (int i = 0; i < N; i++) + { + psxps += ps[i] * ps[i]; } - - for (int i = 0; i < N; i++) { - if (diagD[i] < 0) { // numerical problem? - cerr << "CMAES::updateDistribution(): WARNING - an eigenvalue has become negative." << endl; - counteval = maxEvaluations; - //throw new JMException("Exception in CMAES.execute(): an eigenvalue has become negative.") ; - } - diagD[i] = sqrt(diagD[i]); + + // cumulation for covariance matrix (pc) + int hsig = 0; + if ((sqrt(psxps) / sqrt(1. - pow(1. - cs, 2. * counteval/lambda)) / chiN) + < (1.4 + 2. / (N + 1.))) + { + hsig = 1; } - // diagD is a vector of standard deviations now - - //invsqrtC = B * diag(D.^-1) * B'; - double ** artmp2 = new double*[N]; - for (int i = 0; i < N; i++) { - artmp2[i] = new double[N]; - //double value = (xmean[i] - xold[i]) / sigma; - for (int j = 0; j < N; j++) { - artmp2[i][j] = B[i][j] * (1/diagD[j]); - } + for (int i = 0; i < N; i++) + { + pc[i] = (1. - cc) * pc[i] + + hsig * sqrt(cc * (2. - cc) * mueff) * (xmean[i] - xold[i]) / sigma; } - for (int i = 0; i < N; i++) { - //double value = (xmean[i] - xold[i]) / sigma; - for (int j = 0; j < N; j++) { - invsqrtC[i][j] = 0.0; - for (int k = 0; k < N; k++) { - invsqrtC[i][j] += artmp2[i][k] * B[j][k]; + + /* Adapt covariance matrix C */ + + for (int i = 0; i < N; i++) + { + for (int j = 0; j <= i; j++) + { + C[i][j] = (1 - c1 -cmu) + * C[i][j] + + c1 + * (pc[i] * pc[j] + (1 - hsig) * cc + * (2. - cc) * C[i][j]); + for (int k = 0; k < mu; k++) + { + /* + * additional rank mu + * update + */ + C[i][j] += cmu + * weights[k] + * (arx[arindex[k]][i] - xold[i]) + * (arx[arindex[k]][j] - xold[j]) / sigma + / sigma; + } } - } } - - for (int i = 0; i < N; i++) { - delete [] artmp2[i]; + + /* Adapt step size sigma */ + + sigma *= exp((cs/damps) * (sqrt(psxps)/chiN - 1)); + + /* Decomposition of C into B*diag(D.^2)*B' (diagonalization) */ + + if (counteval - eigeneval > lambda /(c1+cmu)/N/10) // to achieve O(N^2) + { + + eigeneval = counteval; + + // enforce symmetry + for (int i = 0; i < N; i++) + { + for (int j = 0; j <= i; j++) + { + B[i][j] = B[j][i] = C[i][j]; + } + } + + // eigen decomposition, B==normalized eigenvectors + double * offdiag = new double[N]; + UtilsCMAES::tred2(N, B, diagD, offdiag); + UtilsCMAES::tql2(N, diagD, offdiag, B); + if (UtilsCMAES::checkEigenSystem(N, C, diagD, B) > 0) // for debugging + { + counteval = maxEvaluations; + } + + for (int i = 0; i < N; i++) + { + if (diagD[i] < 0) // numerical problem? + { + cerr << "CMAES::updateDistribution(): WARNING - an eigenvalue has become negative." << endl; + counteval = maxEvaluations; + //throw new JMException("Exception in CMAES.execute(): an eigenvalue has become negative.") ; + } + diagD[i] = sqrt(diagD[i]); + } + // diagD is a vector of standard deviations now + + //invsqrtC = B * diag(D.^-1) * B'; + double ** artmp2 = new double*[N]; + for (int i = 0; i < N; i++) + { + artmp2[i] = new double[N]; + //double value = (xmean[i] - xold[i]) / sigma; + for (int j = 0; j < N; j++) + { + artmp2[i][j] = B[i][j] * (1/diagD[j]); + } + } + for (int i = 0; i < N; i++) + { + //double value = (xmean[i] - xold[i]) / sigma; + for (int j = 0; j < N; j++) + { + invsqrtC[i][j] = 0.0; + for (int k = 0; k < N; k++) + { + invsqrtC[i][j] += artmp2[i][k] * B[j][k]; + } + } + } + + for (int i = 0; i < N; i++) + { + delete [] artmp2[i]; + } + delete [] offdiag; + delete [] artmp2; + } - delete [] offdiag; - delete [] artmp2; - } - - delete [] arfitness; - delete [] arindex; - delete [] artmp; + delete [] arfitness; + delete [] arindex; + delete [] artmp; } // updateDistribution() -void CMAES::deleteParams() { - int N = problem_->getNumberOfVariables(); - int lambda = populationSize; - delete [] xmean; - delete [] weights; - delete [] diagD; - delete [] pc; - delete [] ps; - for (int i = 0; i < N; i++) { - delete [] B[i]; - delete [] C[i]; - delete [] invsqrtC[i]; - } - delete [] B; - delete [] C; - delete [] invsqrtC; - delete [] xold; - for (int i = 0; i < lambda; i++) { - delete [] arx[i]; - } - delete [] arx; +void CMAES::deleteParams() +{ + int N = problem_->getNumberOfVariables(); + int lambda = populationSize; + delete [] xmean; + delete [] weights; + delete [] diagD; + delete [] pc; + delete [] ps; + for (int i = 0; i < N; i++) + { + delete [] B[i]; + delete [] C[i]; + delete [] invsqrtC[i]; + } + delete [] B; + delete [] C; + delete [] invsqrtC; + delete [] xold; + for (int i = 0; i < lambda; i++) + { + delete [] arx[i]; + } + delete [] arx; } // freeMemory diff --git a/src/metaheuristics/singleObjective/cmaes/CMAES.h b/src/metaheuristics/singleObjective/cmaes/CMAES.h index 7e007c8..e9e7f8d 100644 --- a/src/metaheuristics/singleObjective/cmaes/CMAES.h +++ b/src/metaheuristics/singleObjective/cmaes/CMAES.h @@ -37,30 +37,31 @@ * This class implements the CMA-ES algorithm. */ -class CMAES : public Algorithm { +class CMAES : public Algorithm +{ + +private: - private: - /** * Stores the population size */ int populationSize; - + int counteval; int maxEvaluations; - + double sigma; - + double * xmean; double * xold; - + /* * Strategy parameter setting: Selection */ int mu; double * weights; double mueff; - + /* * Strategy parameter setting: Adaptation */ @@ -69,7 +70,7 @@ class CMAES : public Algorithm { double c1; double cmu; double damps; - + /* * Dynamic (internal) strategy parameters and constants */ @@ -81,11 +82,11 @@ class CMAES : public Algorithm { double ** invsqrtC; int eigeneval; double chiN; - + double ** arx; SolutionSet * population_; Solution * bestSolutionEver; - + void init(); SolutionSet * samplePopulation(); SolutionSet * genoPhenoTransformation(double ** popx); @@ -95,8 +96,8 @@ class CMAES : public Algorithm { void storeBest(Comparator * comparator); void updateDistribution(); void deleteParams(); - - public: + +public: CMAES(Problem * problem); SolutionSet * execute(); diff --git a/src/metaheuristics/singleObjective/cmaes/utils/UtilsCMAES.cpp b/src/metaheuristics/singleObjective/cmaes/utils/UtilsCMAES.cpp index 70610e8..e523976 100644 --- a/src/metaheuristics/singleObjective/cmaes/utils/UtilsCMAES.cpp +++ b/src/metaheuristics/singleObjective/cmaes/utils/UtilsCMAES.cpp @@ -30,119 +30,144 @@ /** * Symmetric Householder reduction to tridiagonal form, taken from JAMA package. */ -void UtilsCMAES::tred2 (int n, double ** V, double * d, double * e) { +void UtilsCMAES::tred2 (int n, double ** V, double * d, double * e) +{ - // This is derived from the Algol procedures tred2 by - // Bowdler, Martin, Reinsch, and Wilkinson, Handbook for - // Auto. Comp., Vol.ii-Linear Algebra, and the corresponding - // Fortran subroutine in EISPACK. + // This is derived from the Algol procedures tred2 by + // Bowdler, Martin, Reinsch, and Wilkinson, Handbook for + // Auto. Comp., Vol.ii-Linear Algebra, and the corresponding + // Fortran subroutine in EISPACK. - for (int j = 0; j < n; j++) { - d[j] = V[n-1][j]; - } + for (int j = 0; j < n; j++) + { + d[j] = V[n-1][j]; + } - // Householder reduction to tridiagonal form. + // Householder reduction to tridiagonal form. - for (int i = n-1; i > 0; i--) { + for (int i = n-1; i > 0; i--) + { - // Scale to avoid under/overflow. + // Scale to avoid under/overflow. - double scale = 0.0; - double h = 0.0; - for (int k = 0; k < i; k++) { - scale = scale + fabs(d[k]); - } - if (scale == 0.0) { - e[i] = d[i-1]; - for (int j = 0; j < i; j++) { - d[j] = V[i-1][j]; - V[i][j] = 0.0; - V[j][i] = 0.0; - } - } else { - - // Generate Householder vector. - - for (int k = 0; k < i; k++) { - d[k] /= scale; - h += d[k] * d[k]; - } - double f = d[i-1]; - double g = sqrt(h); - if (f > 0) { - g = -g; - } - e[i] = scale * g; - h = h - f * g; - d[i-1] = f - g; - for (int j = 0; j < i; j++) { - e[j] = 0.0; - } - - // Apply similarity transformation to remaining columns. - - for (int j = 0; j < i; j++) { - f = d[j]; - V[j][i] = f; - g = e[j] + V[j][j] * f; - for (int k = j+1; k <= i-1; k++) { - g += V[k][j] * d[k]; - e[k] += V[k][j] * f; + double scale = 0.0; + double h = 0.0; + for (int k = 0; k < i; k++) + { + scale = scale + fabs(d[k]); + } + if (scale == 0.0) + { + e[i] = d[i-1]; + for (int j = 0; j < i; j++) + { + d[j] = V[i-1][j]; + V[i][j] = 0.0; + V[j][i] = 0.0; + } } - e[j] = g; - } - f = 0.0; - for (int j = 0; j < i; j++) { - e[j] /= h; - f += e[j] * d[j]; - } - double hh = f / (h + h); - for (int j = 0; j < i; j++) { - e[j] -= hh * d[j]; - } - for (int j = 0; j < i; j++) { - f = d[j]; - g = e[j]; - for (int k = j; k <= i-1; k++) { - V[k][j] -= (f * e[k] + g * d[k]); + else + { + + // Generate Householder vector. + + for (int k = 0; k < i; k++) + { + d[k] /= scale; + h += d[k] * d[k]; + } + double f = d[i-1]; + double g = sqrt(h); + if (f > 0) + { + g = -g; + } + e[i] = scale * g; + h = h - f * g; + d[i-1] = f - g; + for (int j = 0; j < i; j++) + { + e[j] = 0.0; + } + + // Apply similarity transformation to remaining columns. + + for (int j = 0; j < i; j++) + { + f = d[j]; + V[j][i] = f; + g = e[j] + V[j][j] * f; + for (int k = j+1; k <= i-1; k++) + { + g += V[k][j] * d[k]; + e[k] += V[k][j] * f; + } + e[j] = g; + } + f = 0.0; + for (int j = 0; j < i; j++) + { + e[j] /= h; + f += e[j] * d[j]; + } + double hh = f / (h + h); + for (int j = 0; j < i; j++) + { + e[j] -= hh * d[j]; + } + for (int j = 0; j < i; j++) + { + f = d[j]; + g = e[j]; + for (int k = j; k <= i-1; k++) + { + V[k][j] -= (f * e[k] + g * d[k]); + } + d[j] = V[i-1][j]; + V[i][j] = 0.0; + } } - d[j] = V[i-1][j]; - V[i][j] = 0.0; - } + d[i] = h; } - d[i] = h; - } - - // Accumulate transformations. - - for (int i = 0; i < n-1; i++) { - V[n-1][i] = V[i][i]; - V[i][i] = 1.0; - double h = d[i+1]; - if (h != 0.0) { - for (int k = 0; k <= i; k++) { - d[k] = V[k][i+1] / h; - } - for (int j = 0; j <= i; j++) { - double g = 0.0; - for (int k = 0; k <= i; k++) { - g += V[k][i+1] * V[k][j]; + + // Accumulate transformations. + + for (int i = 0; i < n-1; i++) + { + V[n-1][i] = V[i][i]; + V[i][i] = 1.0; + double h = d[i+1]; + if (h != 0.0) + { + for (int k = 0; k <= i; k++) + { + d[k] = V[k][i+1] / h; + } + for (int j = 0; j <= i; j++) + { + double g = 0.0; + for (int k = 0; k <= i; k++) + { + g += V[k][i+1] * V[k][j]; + } + for (int k = 0; k <= i; k++) + { + V[k][j] -= g * d[k]; + } + } } - for (int k = 0; k <= i; k++) { - V[k][j] -= g * d[k]; + for (int k = 0; k <= i; k++) + { + V[k][i+1] = 0.0; } - } } - for (int k = 0; k <= i; k++) { - V[k][i+1] = 0.0; + for (int j = 0; j < n; j++) + { + d[j] = V[n-1][j]; + V[n-1][j] = 0.0; } - } - for (int j = 0; j < n; j++) { - d[j] = V[n-1][j]; - V[n-1][j] = 0.0; - } - V[n-1][n-1] = 1.0; - e[0] = 0.0; + V[n-1][n-1] = 1.0; + e[0] = 0.0; } // tred2 @@ -150,207 +175,240 @@ void UtilsCMAES::tred2 (int n, double ** V, double * d, double * e) { /** * Symmetric tridiagonal QL algorithm, taken from JAMA package. */ -void UtilsCMAES::tql2 (int n, double * d, double * e, double ** V) { - - // This is derived from the Algol procedures tql2, by - // Bowdler, Martin, Reinsch, and Wilkinson, Handbook for - // Auto. Comp., Vol.ii-Linear Algebra, and the corresponding - // Fortran subroutine in EISPACK. - - for (int i = 1; i < n; i++) { - e[i-1] = e[i]; - } - e[n-1] = 0.0; - - double f = 0.0; - double tst1 = 0.0; - double eps = pow(2.0,-52.0); - for (int l = 0; l < n; l++) { - - // Find small subdiagonal element - - tst1 = fmax(tst1,fabs(d[l]) + fabs(e[l])); - int m = l; - while (m < n) { - if (fabs(e[m]) <= eps*tst1) { - break; - } - m++; - } - - // If m == l, d[l] is an eigenvalue, - // otherwise, iterate. +void UtilsCMAES::tql2 (int n, double * d, double * e, double ** V) +{ - if (m > l) { - int iter = 0; - do { - iter = iter + 1; // (Could check iteration count here.) + // This is derived from the Algol procedures tql2, by + // Bowdler, Martin, Reinsch, and Wilkinson, Handbook for + // Auto. Comp., Vol.ii-Linear Algebra, and the corresponding + // Fortran subroutine in EISPACK. - // Compute implicit shift + for (int i = 1; i < n; i++) + { + e[i-1] = e[i]; + } + e[n-1] = 0.0; + + double f = 0.0; + double tst1 = 0.0; + double eps = pow(2.0,-52.0); + for (int l = 0; l < n; l++) + { + + // Find small subdiagonal element + + tst1 = fmax(tst1,fabs(d[l]) + fabs(e[l])); + int m = l; + while (m < n) + { + if (fabs(e[m]) <= eps*tst1) + { + break; + } + m++; + } - double g = d[l]; - double p = (d[l+1] - g) / (2.0 * e[l]); - double r = hypot(p,1.0); - if (p < 0) { - r = -r; + // If m == l, d[l] is an eigenvalue, + // otherwise, iterate. + + if (m > l) + { + int iter = 0; + do + { + iter = iter + 1; // (Could check iteration count here.) + + // Compute implicit shift + + double g = d[l]; + double p = (d[l+1] - g) / (2.0 * e[l]); + double r = hypot(p,1.0); + if (p < 0) + { + r = -r; + } + d[l] = e[l] / (p + r); + d[l+1] = e[l] * (p + r); + double dl1 = d[l+1]; + double h = g - d[l]; + for (int i = l+2; i < n; i++) + { + d[i] -= h; + } + f = f + h; + + // Implicit QL transformation. + + p = d[m]; + double c = 1.0; + double c2 = c; + double c3 = c; + double el1 = e[l+1]; + double s = 0.0; + double s2 = 0.0; + for (int i = m-1; i >= l; i--) + { + c3 = c2; + c2 = c; + s2 = s; + g = c * e[i]; + h = c * p; + r = hypot(p,e[i]); + e[i+1] = s * r; + s = e[i] / r; + c = p / r; + p = c * d[i] - s * g; + d[i+1] = h + s * (c * g + s * d[i]); + + // Accumulate transformation. + + for (int k = 0; k < n; k++) + { + h = V[k][i+1]; + V[k][i+1] = s * V[k][i] + c * h; + V[k][i] = c * V[k][i] - s * h; + } + } + p = -s * s2 * c3 * el1 * e[l] / dl1; + e[l] = s * p; + d[l] = c * p; + + // Check for convergence. + + } + while (fabs(e[l]) > eps*tst1); } - d[l] = e[l] / (p + r); - d[l+1] = e[l] * (p + r); - double dl1 = d[l+1]; - double h = g - d[l]; - for (int i = l+2; i < n; i++) { - d[i] -= h; + d[l] = d[l] + f; + e[l] = 0.0; + } + + // Sort eigenvalues and corresponding vectors. + + for (int i = 0; i < n-1; i++) + { + int k = i; + double p = d[i]; + for (int j = i+1; j < n; j++) + { + if (d[j] < p) // NH find smallest k>i + { + k = j; + p = d[j]; + } } - f = f + h; - - // Implicit QL transformation. - - p = d[m]; - double c = 1.0; - double c2 = c; - double c3 = c; - double el1 = e[l+1]; - double s = 0.0; - double s2 = 0.0; - for (int i = m-1; i >= l; i--) { - c3 = c2; - c2 = c; - s2 = s; - g = c * e[i]; - h = c * p; - r = hypot(p,e[i]); - e[i+1] = s * r; - s = e[i] / r; - c = p / r; - p = c * d[i] - s * g; - d[i+1] = h + s * (c * g + s * d[i]); - - // Accumulate transformation. - - for (int k = 0; k < n; k++) { - h = V[k][i+1]; - V[k][i+1] = s * V[k][i] + c * h; - V[k][i] = c * V[k][i] - s * h; - } + if (k != i) + { + d[k] = d[i]; // swap k and i + d[i] = p; + for (int j = 0; j < n; j++) + { + p = V[j][i]; + V[j][i] = V[j][k]; + V[j][k] = p; + } } - p = -s * s2 * c3 * el1 * e[l] / dl1; - e[l] = s * p; - d[l] = c * p; - - // Check for convergence. - - } while (fabs(e[l]) > eps*tst1); - } - d[l] = d[l] + f; - e[l] = 0.0; - } - - // Sort eigenvalues and corresponding vectors. - - for (int i = 0; i < n-1; i++) { - int k = i; - double p = d[i]; - for (int j = i+1; j < n; j++) { - if (d[j] < p) { // NH find smallest k>i - k = j; - p = d[j]; - } - } - if (k != i) { - d[k] = d[i]; // swap k and i - d[i] = p; - for (int j = 0; j < n; j++) { - p = V[j][i]; - V[j][i] = V[j][k]; - V[j][k] = p; - } } - } } // tql2 /** * exhaustive test of the output of the eigendecomposition * needs O(n^3) operations - * + * * produces error * returns number of detected inaccuracies */ -int UtilsCMAES::checkEigenSystem (int N, double ** C, double * diag, double ** Q) { - - /* compute Q diag Q^T and Q Q^T to check */ - int i, j, k, res = 0; - double cc, dd; - string s; - - for (i=0; i < N; ++i) - for (j=0; j < N; ++j) { - for (cc=0.,dd=0., k=0; k < N; ++k) { - cc += diag[k] * Q[i][k] * Q[j][k]; - dd += Q[i][k] * Q[j][k]; - } - /* check here, is the normalization the right one? */ - if (fabs(cc - C[i>j?i:j][i>j?j:i])/sqrt(C[i][i]*C[j][j]) > 1e-10 - && fabs(cc - C[i>j?i:j][i>j?j:i]) > 1e-9) { /* quite large */ - ostringstream stringStream; - stringStream << " " << i << " " << j << " " << cc << " " << C[i>j?i:j][i>j?j:i] << " " << (cc-C[i>j?i:j][i>j?j:i]); - s = stringStream.str(); - cerr << "UtilsCMAES::checkEigenSystem(): WARNING - imprecise result detected " << s << endl; - ++res; - } - if (fabs(dd - (i==j?1:0)) > 1e-10) { - ostringstream stringStream; - stringStream << i << " " << j << " " << dd << endl; - s = stringStream.str(); - cerr << "UtilsCMAES::checkEigenSystem(): WARNING - imprecise result detected (Q not orthog.) " << s << endl; - ++res; - } - } - return res; - +int UtilsCMAES::checkEigenSystem (int N, double ** C, double * diag, double ** Q) +{ + + /* compute Q diag Q^T and Q Q^T to check */ + int i, j, k, res = 0; + double cc, dd; + string s; + + for (i=0; i < N; ++i) + for (j=0; j < N; ++j) + { + for (cc=0.,dd=0., k=0; k < N; ++k) + { + cc += diag[k] * Q[i][k] * Q[j][k]; + dd += Q[i][k] * Q[j][k]; + } + /* check here, is the normalization the right one? */ + if (fabs(cc - C[i>j?i:j][i>j?j:i])/sqrt(C[i][i]*C[j][j]) > 1e-10 + && fabs(cc - C[i>j?i:j][i>j?j:i]) > 1e-9) /* quite large */ + { + ostringstream stringStream; + stringStream << " " << i << " " << j << " " << cc << " " << C[i>j?i:j][i>j?j:i] << " " << (cc-C[i>j?i:j][i>j?j:i]); + s = stringStream.str(); + cerr << "UtilsCMAES::checkEigenSystem(): WARNING - imprecise result detected " << s << endl; + ++res; + } + if (fabs(dd - (i==j?1:0)) > 1e-10) + { + ostringstream stringStream; + stringStream << i << " " << j << " " << dd << endl; + s = stringStream.str(); + cerr << "UtilsCMAES::checkEigenSystem(): WARNING - imprecise result detected (Q not orthog.) " << s << endl; + ++res; + } + } + return res; + } // checkEigenSystem /** * sqrt(a^2 + b^2) without under/overflow. */ -double UtilsCMAES::hypot (double a, double b) { - - double r = 0; - if (fabs(a) > fabs(b)) { - r = b/a; - r = fabs(a)*sqrt(1+r*r); - } else if (b != 0) { - r = a/b; - r = fabs(b)*sqrt(1+r*r); - } - return r; - +double UtilsCMAES::hypot (double a, double b) +{ + + double r = 0; + if (fabs(a) > fabs(b)) + { + r = b/a; + r = fabs(a)*sqrt(1+r*r); + } + else if (b != 0) + { + r = a/b; + r = fabs(b)*sqrt(1+r*r); + } + return r; + } // hypot -void UtilsCMAES::minFastSort(double * x, int * idx, int size) { - - for (int i = 0; i < size; i++) { - for (int j = i + 1; j < size; j++) { - if (x[i] > x[j]) { - double temp = x[i]; - int tempIdx = idx[i]; - x[i] = x[j]; - x[j] = temp; - idx[i] = idx[j]; - idx[j] = tempIdx; - } else if (x[i] == x[j]) { - if (idx[i] > idx[j]) { - double temp = x[i]; - int tempIdx = idx[i]; - x[i] = x[j]; - x[j] = temp; - idx[i] = idx[j]; - idx[j] = tempIdx; +void UtilsCMAES::minFastSort(double * x, int * idx, int size) +{ + + for (int i = 0; i < size; i++) + { + for (int j = i + 1; j < size; j++) + { + if (x[i] > x[j]) + { + double temp = x[i]; + int tempIdx = idx[i]; + x[i] = x[j]; + x[j] = temp; + idx[i] = idx[j]; + idx[j] = tempIdx; + } + else if (x[i] == x[j]) + { + if (idx[i] > idx[j]) + { + double temp = x[i]; + int tempIdx = idx[i]; + x[i] = x[j]; + x[j] = temp; + idx[i] = idx[j]; + idx[j] = tempIdx; + } + } // if } - } // if - } - } // for - + } // for + } // minFastSort diff --git a/src/metaheuristics/singleObjective/cmaes/utils/UtilsCMAES.h b/src/metaheuristics/singleObjective/cmaes/utils/UtilsCMAES.h index 055cf34..8f744ce 100644 --- a/src/metaheuristics/singleObjective/cmaes/utils/UtilsCMAES.h +++ b/src/metaheuristics/singleObjective/cmaes/utils/UtilsCMAES.h @@ -36,15 +36,16 @@ using namespace std; */ -class UtilsCMAES { - +class UtilsCMAES +{ + public: - static void tred2 (int n, double ** V, double * d, double * e); - static void tql2 (int n, double * d, double * e, double ** V); - static int checkEigenSystem (int N, double ** C, double * diag, double ** Q); - static double hypot (double a, double b); - static void minFastSort (double * x, int * idx, int size); - + static void tred2 (int n, double ** V, double * d, double * e); + static void tql2 (int n, double * d, double * e, double ** V); + static int checkEigenSystem (int N, double ** C, double * diag, double ** Q); + static double hypot (double a, double b); + static void minFastSort (double * x, int * idx, int size); + }; diff --git a/src/metaheuristics/singleObjective/differentialEvolution/DE.cpp b/src/metaheuristics/singleObjective/differentialEvolution/DE.cpp index 09dac50..9b6a9b9 100644 --- a/src/metaheuristics/singleObjective/differentialEvolution/DE.cpp +++ b/src/metaheuristics/singleObjective/differentialEvolution/DE.cpp @@ -31,7 +31,8 @@ * Constructor * @param problem Problem to solve */ -DE::DE(Problem *problem) : Algorithm(problem) { +DE::DE(Problem *problem) : Algorithm(problem) +{ } // DE @@ -40,111 +41,120 @@ DE::DE(Problem *problem) : Algorithm(problem) { * @return a SolutionSet that is a set of non dominated solutions * as a result of the algorithm execution */ -SolutionSet * DE::execute() { - - int populationSize; - int maxEvaluations; - int evaluations; - - SolutionSet * population; - SolutionSet * offspringPopulation; - - Operator * selectionOperator; - Operator * crossoverOperator; - - Comparator * comparator; - comparator = new ObjectiveComparator(0); // Single objective comparator - - // Differential evolution parameters - int r1; - int r2; - int r3; - int jrand; - - Solution ** parent; - - //Read the parameters - populationSize = *(int *) getInputParameter("populationSize"); - maxEvaluations = *(int *) getInputParameter("maxEvaluations"); - - selectionOperator = operators_["selection"]; - crossoverOperator = operators_["crossover"]; - - //Initialize the variables - population = new SolutionSet(populationSize); - evaluations = 0; - - // Create the initial solutionSet - Solution * newSolution; - for (int i = 0; i < populationSize; i++) { - newSolution = new Solution(problem_); - problem_->evaluate(newSolution); - problem_->evaluateConstraints(newSolution); - evaluations++; - population->add(newSolution); - } //for - - // Generations ... - population->sort(comparator) ; - while (evaluations < maxEvaluations) { - - // Create the offSpring solutionSet - offspringPopulation = new SolutionSet(populationSize); - - //offspringPopulation.add(new Solution(population.get(0))) ; - - for (int i = 0; i < populationSize; i++) { - // Obtain parents. Two parameters are required: the population and the - // index of the current individual - void ** object1 = new void*[2]; - object1[0] = population; - object1[1] = &i; - parent = (Solution **) (selectionOperator->execute(object1)); - delete[] object1; - - Solution * child; - - // Crossover. Two parameters are required: the current individual and the - // array of parents - void ** object2 = new void*[2]; - object2[0] = population->get(i); - object2[1] = parent; - child = (Solution *) (crossoverOperator->execute(object2)); - delete[] object2; - delete[] parent; - - problem_->evaluate(child); - - evaluations++; - - if (comparator->compare(population->get(i), child) < 0) { - offspringPopulation->add(new Solution(population->get(i))); - delete child; - } else { - offspringPopulation->add(child); - } - } // for - - // The offspring population becomes the new current population - for (int i = 0; i < populationSize; i++) { - delete population->get(i); - } - population->clear(); - for (int i = 0; i < populationSize; i++) { - population->add(offspringPopulation->get(i)); - } - offspringPopulation->clear(); - delete offspringPopulation; - population->sort(comparator); - } // while - - delete comparator; - - // Return a population with the best individual - SolutionSet * resultPopulation = new SolutionSet(1); - resultPopulation->add(new Solution(population->get(0))); - delete population; - - return resultPopulation; +SolutionSet * DE::execute() +{ + + int populationSize; + int maxEvaluations; + int evaluations; + + SolutionSet * population; + SolutionSet * offspringPopulation; + + Operator * selectionOperator; + Operator * crossoverOperator; + + Comparator * comparator; + comparator = new ObjectiveComparator(0); // Single objective comparator + + // Differential evolution parameters + int r1; + int r2; + int r3; + int jrand; + + Solution ** parent; + + //Read the parameters + populationSize = *(int *) getInputParameter("populationSize"); + maxEvaluations = *(int *) getInputParameter("maxEvaluations"); + + selectionOperator = operators_["selection"]; + crossoverOperator = operators_["crossover"]; + + //Initialize the variables + population = new SolutionSet(populationSize); + evaluations = 0; + + // Create the initial solutionSet + Solution * newSolution; + for (int i = 0; i < populationSize; i++) + { + newSolution = new Solution(problem_); + problem_->evaluate(newSolution); + problem_->evaluateConstraints(newSolution); + evaluations++; + population->add(newSolution); + } //for + + // Generations ... + population->sort(comparator) ; + while (evaluations < maxEvaluations) + { + + // Create the offSpring solutionSet + offspringPopulation = new SolutionSet(populationSize); + + //offspringPopulation.add(new Solution(population.get(0))) ; + + for (int i = 0; i < populationSize; i++) + { + // Obtain parents. Two parameters are required: the population and the + // index of the current individual + void ** object1 = new void*[2]; + object1[0] = population; + object1[1] = &i; + parent = (Solution **) (selectionOperator->execute(object1)); + delete[] object1; + + Solution * child; + + // Crossover. Two parameters are required: the current individual and the + // array of parents + void ** object2 = new void*[2]; + object2[0] = population->get(i); + object2[1] = parent; + child = (Solution *) (crossoverOperator->execute(object2)); + delete[] object2; + delete[] parent; + + problem_->evaluate(child); + + evaluations++; + + if (comparator->compare(population->get(i), child) < 0) + { + offspringPopulation->add(new Solution(population->get(i))); + delete child; + } + else + { + offspringPopulation->add(child); + } + } // for + + // The offspring population becomes the new current population + for (int i = 0; i < populationSize; i++) + { + delete population->get(i); + } + population->clear(); + for (int i = 0; i < populationSize; i++) + { + population->add(offspringPopulation->get(i)); + } + offspringPopulation->clear(); + delete offspringPopulation; + population->sort(comparator); + } // while + + delete comparator; + + // Return a population with the best individual + SolutionSet * resultPopulation = new SolutionSet(1); + resultPopulation->add(new Solution(population->get(0))); + delete population; + + return resultPopulation; } // execute diff --git a/src/metaheuristics/singleObjective/differentialEvolution/DE.h b/src/metaheuristics/singleObjective/differentialEvolution/DE.h index 0e60ca7..3e78742 100644 --- a/src/metaheuristics/singleObjective/differentialEvolution/DE.h +++ b/src/metaheuristics/singleObjective/differentialEvolution/DE.h @@ -30,11 +30,12 @@ * This class implements a differential evolution algorithm. */ -class DE : public Algorithm { +class DE : public Algorithm +{ public: - DE(Problem * problem); - SolutionSet * execute(); + DE(Problem * problem); + SolutionSet * execute(); }; #endif /* __DE__ */ diff --git a/src/metaheuristics/singleObjective/geneticAlgorithm/gGA.cpp b/src/metaheuristics/singleObjective/geneticAlgorithm/gGA.cpp index d3c5a80..6b94511 100644 --- a/src/metaheuristics/singleObjective/geneticAlgorithm/gGA.cpp +++ b/src/metaheuristics/singleObjective/geneticAlgorithm/gGA.cpp @@ -29,7 +29,8 @@ * Constructor * @param problem Problem to solve */ -gGA::gGA(Problem *problem) : Algorithm(problem) { +gGA::gGA(Problem *problem) : Algorithm(problem) +{ } // gGA @@ -38,108 +39,114 @@ gGA::gGA(Problem *problem) : Algorithm(problem) { * @return a SolutionSet that is a set of non dominated solutions * as a result of the algorithm execution */ -SolutionSet * gGA::execute() { +SolutionSet * gGA::execute() +{ - int populationSize; - int maxEvaluations; - int evaluations; + int populationSize; + int maxEvaluations; + int evaluations; - SolutionSet * population; - SolutionSet * offspringPopulation; + SolutionSet * population; + SolutionSet * offspringPopulation; - Operator * mutationOperator; - Operator * crossoverOperator; - Operator * selectionOperator; + Operator * mutationOperator; + Operator * crossoverOperator; + Operator * selectionOperator; - Comparator * comparator = new ObjectiveComparator(0) ; + Comparator * comparator = new ObjectiveComparator(0) ; - //Read the parameters - populationSize = *(int *) getInputParameter("populationSize"); - maxEvaluations = *(int *) getInputParameter("maxEvaluations"); - // TODO: indicators = (QualityIndicator) getInputParameter("indicators"); + //Read the parameters + populationSize = *(int *) getInputParameter("populationSize"); + maxEvaluations = *(int *) getInputParameter("maxEvaluations"); + // TODO: indicators = (QualityIndicator) getInputParameter("indicators"); // cout << "populationSize = " << populationSize << endl; // cout << "maxEvaluations = " << maxEvaluations << endl; - //Initialize the variables - population = new SolutionSet(populationSize); - evaluations = 0; + //Initialize the variables + population = new SolutionSet(populationSize); + evaluations = 0; // cout << "Poblacion inicializada con maxsize = " << population->getMaxSize() << endl; // cout << "Poblacion inicializada con size = " << population->size() << endl; // cout << "Problema: " << problem_->getName() << endl; - //Read the operators - mutationOperator = operators_["mutation"]; - crossoverOperator = operators_["crossover"]; - selectionOperator = operators_["selection"]; + //Read the operators + mutationOperator = operators_["mutation"]; + crossoverOperator = operators_["crossover"]; + selectionOperator = operators_["selection"]; // cout << "Comienza la inicializacion de la poblacion con size " << populationSize << endl; - // Create the initial solutionSet - Solution * newSolution; - for (int i = 0; i < populationSize; i++) { - newSolution = new Solution(problem_); - problem_->evaluate(newSolution); - problem_->evaluateConstraints(newSolution); - evaluations++; - population->add(newSolution); - } //for + // Create the initial solutionSet + Solution * newSolution; + for (int i = 0; i < populationSize; i++) + { + newSolution = new Solution(problem_); + problem_->evaluate(newSolution); + problem_->evaluateConstraints(newSolution); + evaluations++; + population->add(newSolution); + } //for // cout << "gGA: Poblacion inicializada con size = " << population->size() << endl; // cout << "gGA: Maximo de evaluaciones: " << maxEvaluations << endl; - // Generations - while (evaluations < maxEvaluations) { - - // Create the offSpring solutionSet - offspringPopulation = new SolutionSet(populationSize); - Solution ** parents = new Solution*[2]; - - for (int i = 0; i < (populationSize / 2); i++) { - if (evaluations < maxEvaluations) { - //obtain parents - parents[0] = (Solution *) (selectionOperator->execute(population)); - parents[1] = (Solution *) (selectionOperator->execute(population)); - Solution ** offSpring = (Solution **) (crossoverOperator->execute(parents)); - mutationOperator->execute(offSpring[0]); - mutationOperator->execute(offSpring[1]); - problem_->evaluate(offSpring[0]); - problem_->evaluateConstraints(offSpring[0]); - problem_->evaluate(offSpring[1]); - problem_->evaluateConstraints(offSpring[1]); - - offspringPopulation->add(offSpring[0]); - offspringPopulation->add(offSpring[1]); - evaluations += 2; - delete[] offSpring; - } // if - } // for - delete[] parents; - - population->sort(comparator) ; - offspringPopulation->sort(comparator) ; - - delete offspringPopulation->get(offspringPopulation->size()-1); - delete offspringPopulation->get(offspringPopulation->size()-2); - offspringPopulation->replace(offspringPopulation->size()-1, new Solution(population->get(0))) ; - offspringPopulation->replace(offspringPopulation->size()-2, new Solution(population->get(1))) ; - - for (int i=0;isize();i++) { - delete population->get(i); + // Generations + while (evaluations < maxEvaluations) + { + + // Create the offSpring solutionSet + offspringPopulation = new SolutionSet(populationSize); + Solution ** parents = new Solution*[2]; + + for (int i = 0; i < (populationSize / 2); i++) + { + if (evaluations < maxEvaluations) + { + //obtain parents + parents[0] = (Solution *) (selectionOperator->execute(population)); + parents[1] = (Solution *) (selectionOperator->execute(population)); + Solution ** offSpring = (Solution **) (crossoverOperator->execute(parents)); + mutationOperator->execute(offSpring[0]); + mutationOperator->execute(offSpring[1]); + problem_->evaluate(offSpring[0]); + problem_->evaluateConstraints(offSpring[0]); + problem_->evaluate(offSpring[1]); + problem_->evaluateConstraints(offSpring[1]); + + offspringPopulation->add(offSpring[0]); + offspringPopulation->add(offSpring[1]); + evaluations += 2; + delete[] offSpring; + } // if + } // for + delete[] parents; + + population->sort(comparator) ; + offspringPopulation->sort(comparator) ; + + delete offspringPopulation->get(offspringPopulation->size()-1); + delete offspringPopulation->get(offspringPopulation->size()-2); + offspringPopulation->replace(offspringPopulation->size()-1, new Solution(population->get(0))) ; + offspringPopulation->replace(offspringPopulation->size()-2, new Solution(population->get(1))) ; + + for (int i=0; isize(); i++) + { + delete population->get(i); + } + population->clear() ; + + for (int i = 0; i < offspringPopulation->size(); i++) + population->add(offspringPopulation->get(i)) ; + offspringPopulation->clear() ; + delete offspringPopulation; } - population->clear() ; - for (int i = 0; i < offspringPopulation->size(); i++) - population->add(offspringPopulation->get(i)) ; - offspringPopulation->clear() ; - delete offspringPopulation; - } + delete comparator; - delete comparator; + SolutionSet * resultPopulation = new SolutionSet(1) ; + resultPopulation->add(new Solution(population->get(0))) ; + delete population; - SolutionSet * resultPopulation = new SolutionSet(1) ; - resultPopulation->add(new Solution(population->get(0))) ; - delete population; - - return resultPopulation ; + return resultPopulation ; } // execute diff --git a/src/metaheuristics/singleObjective/geneticAlgorithm/gGA.h b/src/metaheuristics/singleObjective/geneticAlgorithm/gGA.h index 55d244b..287d0ff 100644 --- a/src/metaheuristics/singleObjective/geneticAlgorithm/gGA.h +++ b/src/metaheuristics/singleObjective/geneticAlgorithm/gGA.h @@ -26,13 +26,14 @@ #include #include -class gGA : public Algorithm { +class gGA : public Algorithm +{ private: - int populationSize_; - int maxEvaluations_; + int populationSize_; + int maxEvaluations_; public: - gGA(Problem * problem); - SolutionSet * execute(); + gGA(Problem * problem); + SolutionSet * execute(); }; #endif /* GGA_H_ */ diff --git a/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.cpp b/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.cpp index 6a0b0c3..761913d 100644 --- a/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.cpp +++ b/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.cpp @@ -32,100 +32,105 @@ * Create a new SSGA instance. * @param problem Problem to solve */ -ssGA::ssGA(Problem *problem) : Algorithm(problem) { +ssGA::ssGA(Problem *problem) : Algorithm(problem) +{ } // ssGA /* * Execute the SSGA algorithm */ -SolutionSet * ssGA::execute() { +SolutionSet * ssGA::execute() +{ - int populationSize; - int maxEvaluations; - int evaluations; + int populationSize; + int maxEvaluations; + int evaluations; - SolutionSet * population; + SolutionSet * population; - Operator * mutationOperator; - Operator * crossoverOperator; - Operator * selectionOperator; + Operator * mutationOperator; + Operator * crossoverOperator; + Operator * selectionOperator; - Comparator * comparator = new ObjectiveComparator(0); // Single objective comparator + Comparator * comparator = new ObjectiveComparator(0); // Single objective comparator - Operator * findWorstSolution; - map parameters; // Operator parameters - parameters["comparator"] = comparator; + Operator * findWorstSolution; + map parameters; // Operator parameters + parameters["comparator"] = comparator; - findWorstSolution = new WorstSolutionSelection(parameters) ; + findWorstSolution = new WorstSolutionSelection(parameters) ; - //Read the parameters - populationSize = *(int *) getInputParameter("populationSize"); - maxEvaluations = *(int *) getInputParameter("maxEvaluations"); + //Read the parameters + populationSize = *(int *) getInputParameter("populationSize"); + maxEvaluations = *(int *) getInputParameter("maxEvaluations"); - //Initialize the variables - population = new SolutionSet(populationSize); - evaluations = 0; + //Initialize the variables + population = new SolutionSet(populationSize); + evaluations = 0; - //Read the operators - mutationOperator = operators_["mutation"]; - crossoverOperator = operators_["crossover"]; - selectionOperator = operators_["selection"]; + //Read the operators + mutationOperator = operators_["mutation"]; + crossoverOperator = operators_["crossover"]; + selectionOperator = operators_["selection"]; - // Create the initial population - Solution * newIndividual; - for (int i = 0; i < populationSize; i++) { - newIndividual = new Solution(problem_); - problem_->evaluate(newIndividual); - evaluations++; - population->add(newIndividual); - } // for + // Create the initial population + Solution * newIndividual; + for (int i = 0; i < populationSize; i++) + { + newIndividual = new Solution(problem_); + problem_->evaluate(newIndividual); + evaluations++; + population->add(newIndividual); + } // for - // main loop - while (evaluations < maxEvaluations) { - Solution ** parents = new Solution*[2]; + // main loop + while (evaluations < maxEvaluations) + { + Solution ** parents = new Solution*[2]; - // Selection - parents[0] = (Solution*)selectionOperator->execute(population); - parents[1] = (Solution*)selectionOperator->execute(population); + // Selection + parents[0] = (Solution*)selectionOperator->execute(population); + parents[1] = (Solution*)selectionOperator->execute(population); - // Crossover - Solution ** offspring = (Solution **) crossoverOperator->execute(parents); + // Crossover + Solution ** offspring = (Solution **) crossoverOperator->execute(parents); - // Mutation - mutationOperator->execute(offspring[0]); + // Mutation + mutationOperator->execute(offspring[0]); - // Evaluation of the new individual - problem_->evaluate(offspring[0]); + // Evaluation of the new individual + problem_->evaluate(offspring[0]); - evaluations ++; + evaluations ++; - // Replacement: replace the last individual is the new one is better - int * worstIndividualPtr = (int *) findWorstSolution->execute(population); - int worstIndividual = *worstIndividualPtr; - delete worstIndividualPtr; + // Replacement: replace the last individual is the new one is better + int * worstIndividualPtr = (int *) findWorstSolution->execute(population); + int worstIndividual = *worstIndividualPtr; + delete worstIndividualPtr; - if (comparator->compare(population->get(worstIndividual), offspring[0]) > 0) { - delete population->get(worstIndividual); - population->remove(worstIndividual); - population->add(new Solution(offspring[0])); - } // if + if (comparator->compare(population->get(worstIndividual), offspring[0]) > 0) + { + delete population->get(worstIndividual); + population->remove(worstIndividual); + population->add(new Solution(offspring[0])); + } // if - delete offspring[0]; - delete offspring[1]; - delete [] offspring; - delete [] parents; + delete offspring[0]; + delete offspring[1]; + delete [] offspring; + delete [] parents; - } // while + } // while - // Return a population with the best individual + // Return a population with the best individual - SolutionSet * resultPopulation = new SolutionSet(1); - resultPopulation->add(new Solution(population->best(comparator))); + SolutionSet * resultPopulation = new SolutionSet(1); + resultPopulation->add(new Solution(population->best(comparator))); - delete population; - delete comparator; - delete findWorstSolution; + delete population; + delete comparator; + delete findWorstSolution; - return resultPopulation; + return resultPopulation; } // execute diff --git a/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.h b/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.h index a374f86..ffca3ff 100644 --- a/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.h +++ b/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.h @@ -30,11 +30,12 @@ /** * Class implementing a steady-state genetic algorithm */ -class ssGA : public Algorithm { +class ssGA : public Algorithm +{ public: - ssGA(Problem * problem); - SolutionSet * execute(); + ssGA(Problem * problem); + SolutionSet * execute(); }; diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp b/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp index 9bbd282..638bac2 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp @@ -31,28 +31,29 @@ * Constructor * @param problem Problem to solve */ -PSO::PSO(Problem *problem) : Algorithm(problem) { - - r1Max_ = 1.0; - r1Min_ = 0.0; - r2Max_ = 1.0; - r2Min_ = 0.0; - C1Max_ = 1.5; - C1Min_ = 1.5; - C2Max_ = 1.5; - C2Min_ = 1.5; - WMax_ = 0.9; - WMin_ = 0.9; - ChVel1_ = 1.0; - ChVel2_ = 1.0; - - comparator_ = new ObjectiveComparator(0); // Single objective comparator - map parameters; // Operator parameters - - parameters["comparator"] = comparator_; - findBestSolution_ = new BestSolutionSelection(parameters); - - evaluations_ = 0; +PSO::PSO(Problem *problem) : Algorithm(problem) +{ + + r1Max_ = 1.0; + r1Min_ = 0.0; + r2Max_ = 1.0; + r2Min_ = 0.0; + C1Max_ = 1.5; + C1Min_ = 1.5; + C2Max_ = 1.5; + C2Min_ = 1.5; + WMax_ = 0.9; + WMin_ = 0.9; + ChVel1_ = 1.0; + ChVel2_ = 1.0; + + comparator_ = new ObjectiveComparator(0); // Single objective comparator + map parameters; // Operator parameters + + parameters["comparator"] = comparator_; + findBestSolution_ = new BestSolutionSelection(parameters); + + evaluations_ = 0; } // PSO @@ -60,153 +61,167 @@ PSO::PSO(Problem *problem) : Algorithm(problem) { /** * Initialize all parameter of the algorithm */ -void PSO::initParams() { - particlesSize_ = *(int *) getInputParameter("swarmSize"); - maxIterations_ = *(int *) getInputParameter("maxIterations"); +void PSO::initParams() +{ + particlesSize_ = *(int *) getInputParameter("swarmSize"); + maxIterations_ = *(int *) getInputParameter("maxIterations"); - polynomialMutation_ = operators_["mutation"]; + polynomialMutation_ = operators_["mutation"]; - iteration_ = 0; + iteration_ = 0; - success_ = false; + success_ = false; - particles_ = new SolutionSet(particlesSize_); - localBest_ = new Solution*[particlesSize_]; + particles_ = new SolutionSet(particlesSize_); + localBest_ = new Solution*[particlesSize_]; - // Create the speed_ vector - speed_ = new double*[particlesSize_]; + // Create the speed_ vector + speed_ = new double*[particlesSize_]; - deltaMax_ = new double[problem_->getNumberOfVariables()]; - deltaMin_ = new double[problem_->getNumberOfVariables()]; - for (int i = 0; i < problem_->getNumberOfVariables(); i++) { - deltaMax_[i] = (problem_->getUpperLimit(i) - - problem_->getLowerLimit(i)) / 2.0; - deltaMin_[i] = -deltaMax_[i]; - } // for + deltaMax_ = new double[problem_->getNumberOfVariables()]; + deltaMin_ = new double[problem_->getNumberOfVariables()]; + for (int i = 0; i < problem_->getNumberOfVariables(); i++) + { + deltaMax_[i] = (problem_->getUpperLimit(i) - + problem_->getLowerLimit(i)) / 2.0; + deltaMin_[i] = -deltaMax_[i]; + } // for } // initParams /** * Initialize all parameter of the algorithm */ -void PSO::deleteParams() { - - for (int i = 0; i < particlesSize_; i++) { - delete [] speed_[i]; - } - delete [] speed_; - delete [] deltaMax_; - delete [] deltaMin_; - for (int i = 0; i < particles_->size(); i++) { - delete localBest_[i]; - } - delete [] localBest_; - delete globalBest_; - delete particles_; - delete findBestSolution_; - delete comparator_; +void PSO::deleteParams() +{ + + for (int i = 0; i < particlesSize_; i++) + { + delete [] speed_[i]; + } + delete [] speed_; + delete [] deltaMax_; + delete [] deltaMin_; + for (int i = 0; i < particles_->size(); i++) + { + delete localBest_[i]; + } + delete [] localBest_; + delete globalBest_; + delete particles_; + delete findBestSolution_; + delete comparator_; } // deleteParams // Adaptive inertia -double PSO::inertiaWeight(int iter, int miter, double wmax, double wmin) { - //return wmax; - return wmax - (((wmax-wmin)*(double)iter)/(double)miter); +double PSO::inertiaWeight(int iter, int miter, double wmax, double wmin) +{ + //return wmax; + return wmax - (((wmax-wmin)*(double)iter)/(double)miter); } // inertiaWeight // constriction coefficient (M. Clerc) -double PSO::constrictionCoefficient(double c1, double c2) { - double rho = c1 + c2; - //rho = 1.0 ; - if (rho <= 4) { - return 1.0; - } else { - return 2 / fabs((2 - rho - sqrt(pow(rho, 2.0) - 4.0 * rho))); - } +double PSO::constrictionCoefficient(double c1, double c2) +{ + double rho = c1 + c2; + //rho = 1.0 ; + if (rho <= 4) + { + return 1.0; + } + else + { + return 2 / fabs((2 - rho - sqrt(pow(rho, 2.0) - 4.0 * rho))); + } } // constrictionCoefficient // velocity bounds double PSO::velocityConstriction(double v, double * deltaMax, - double * deltaMin, int variableIndex, - int particleIndex) { + double * deltaMin, int variableIndex, + int particleIndex) +{ - return v; - /* - double result; + return v; + /* + double result; - double dmax = deltaMax[variableIndex]; - double dmin = deltaMin[variableIndex]; + double dmax = deltaMax[variableIndex]; + double dmin = deltaMin[variableIndex]; - result = v; + result = v; - if (v > dmax) { - result = dmax; - } + if (v > dmax) { + result = dmax; + } - if (v < dmin) { - result = dmin; - } + if (v < dmin) { + result = dmin; + } - return result; - */ + return result; + */ } // velocityConstriction /** * Update the speed of each particle */ -void PSO::computeSpeed(int iter, int miter) { - double r1, r2; - //double W ; - double C1, C2; - double wmax, wmin, deltaMax, deltaMin; - XReal * bestGlobal; - - bestGlobal = new XReal(globalBest_) ; - - for (int i = 0; i < particlesSize_; i++) { - XReal * particle = new XReal(particles_->get(i)) ; - XReal * bestParticle = new XReal(localBest_[i]) ; - - //int bestIndividual = findBestSolution_->execute(particles_) ; - - r1 = PseudoRandom::randDouble(r1Min_, r1Max_); - r2 = PseudoRandom::randDouble(r2Min_, r2Max_); - //C1 = PseudoRandom::randDouble(C1Min_, C1Max_); - //C2 = PseudoRandom::randDouble(C2Min_, C2Max_); - C1 = 2.05; - C2 = 2.05; - //W = PseudoRandom.randDouble(WMin_, WMax_); - - wmax = WMax_; - wmin = WMin_; - - for (int var = 0; var < particle->size(); var++) { - //Computing the velocity of this particle - speed_[i][var] = constrictionCoefficient(C1, C2) * - (speed_[i][var] + - C1 * r1 * (bestParticle->getValue(var) - particle->getValue(var)) + - C2 * r2 * (bestGlobal->getValue(var) - particle->getValue(var))); - } +void PSO::computeSpeed(int iter, int miter) +{ + double r1, r2; + //double W ; + double C1, C2; + double wmax, wmin, deltaMax, deltaMin; + XReal * bestGlobal; + + bestGlobal = new XReal(globalBest_) ; + + for (int i = 0; i < particlesSize_; i++) + { + XReal * particle = new XReal(particles_->get(i)) ; + XReal * bestParticle = new XReal(localBest_[i]) ; + + //int bestIndividual = findBestSolution_->execute(particles_) ; + + r1 = PseudoRandom::randDouble(r1Min_, r1Max_); + r2 = PseudoRandom::randDouble(r2Min_, r2Max_); + //C1 = PseudoRandom::randDouble(C1Min_, C1Max_); + //C2 = PseudoRandom::randDouble(C2Min_, C2Max_); + C1 = 2.05; + C2 = 2.05; + //W = PseudoRandom.randDouble(WMin_, WMax_); + + wmax = WMax_; + wmin = WMin_; + + for (int var = 0; var < particle->size(); var++) + { + //Computing the velocity of this particle + speed_[i][var] = constrictionCoefficient(C1, C2) * + (speed_[i][var] + + C1 * r1 * (bestParticle->getValue(var) - particle->getValue(var)) + + C2 * r2 * (bestGlobal->getValue(var) - particle->getValue(var))); + } + + /* + for (int var = 0; var < particle->size(); var++) { + //Computing the velocity of this particle + speed_[i][var] = inertiaWeight(iter, miter, wmax, wmin) * speed_[i][var] + + C1 * r1 * (bestParticle->getValue(var) - particle->getValue(var)) + + C2 * r2 * (bestGlobal->getValue(var) - particle->getValue(var)) ; + } + */ + + delete particle; + delete bestParticle; - /* - for (int var = 0; var < particle->size(); var++) { - //Computing the velocity of this particle - speed_[i][var] = inertiaWeight(iter, miter, wmax, wmin) * speed_[i][var] + - C1 * r1 * (bestParticle->getValue(var) - particle->getValue(var)) + - C2 * r2 * (bestGlobal->getValue(var) - particle->getValue(var)) ; } - */ - - delete particle; - delete bestParticle; - } - - delete bestGlobal; + delete bestGlobal; } // computeSpeed @@ -214,43 +229,50 @@ void PSO::computeSpeed(int iter, int miter) { /** * Update the position of each particle */ -void PSO::computeNewPositions() { - for (int i = 0; i < particlesSize_; i++) { - //Variable ** particle = particles_->get(i)->getDecisionVariables(); - XReal * particle = new XReal(particles_->get(i)) ; - //particle->move(speed_[i]); - for (int var = 0; var < particle->size(); var++) { - particle->setValue(var, particle->getValue(var) + speed_[i][var]) ; - - if (particle->getValue(var) < problem_->getLowerLimit(var)) { - particle->setValue(var, problem_->getLowerLimit(var)); - speed_[i][var] = speed_[i][var] * ChVel1_; // - } - if (particle->getValue(var) > problem_->getUpperLimit(var)) { - particle->setValue(var, problem_->getUpperLimit(var)); - speed_[i][var] = speed_[i][var] * ChVel2_; // - } - +void PSO::computeNewPositions() +{ + for (int i = 0; i < particlesSize_; i++) + { + //Variable ** particle = particles_->get(i)->getDecisionVariables(); + XReal * particle = new XReal(particles_->get(i)) ; + //particle->move(speed_[i]); + for (int var = 0; var < particle->size(); var++) + { + particle->setValue(var, particle->getValue(var) + speed_[i][var]) ; + + if (particle->getValue(var) < problem_->getLowerLimit(var)) + { + particle->setValue(var, problem_->getLowerLimit(var)); + speed_[i][var] = speed_[i][var] * ChVel1_; // + } + if (particle->getValue(var) > problem_->getUpperLimit(var)) + { + particle->setValue(var, problem_->getUpperLimit(var)); + speed_[i][var] = speed_[i][var] * ChVel2_; // + } + + } + delete particle; } - delete particle; - } } // computeNewPositions /** * Apply a mutation operator to some particles in the swarm */ -void PSO::mopsoMutation(int actualIteration, int totalIterations) { - for (int i = 0; i < particles_->size(); i++) { - if ( (i % 6) == 0) - polynomialMutation_->execute(particles_->get(i)); - //if (i % 3 == 0) { //particles_ mutated with a non-uniform mutation %3 - // nonUniformMutation_.execute(particles_.get(i)); - //} else if (i % 3 == 1) { //particles_ mutated with a uniform mutation operator - // uniformMutation_.execute(particles_.get(i)); - //} else //particles_ without mutation - //; - } +void PSO::mopsoMutation(int actualIteration, int totalIterations) +{ + for (int i = 0; i < particles_->size(); i++) + { + if ( (i % 6) == 0) + polynomialMutation_->execute(particles_->get(i)); + //if (i % 3 == 0) { //particles_ mutated with a non-uniform mutation %3 + // nonUniformMutation_.execute(particles_.get(i)); + //} else if (i % 3 == 1) { //particles_ mutated with a uniform mutation operator + // uniformMutation_.execute(particles_.get(i)); + //} else //particles_ without mutation + //; + } } // mopsoMutation @@ -259,90 +281,102 @@ void PSO::mopsoMutation(int actualIteration, int totalIterations) { * @return a SolutionSet that is a set of non dominated solutions * as a result of the algorithm execution */ -SolutionSet * PSO::execute() { - - initParams(); - - success_ = false; - globalBest_ = NULL; - - //->Step 1 (and 3) Create the initial population and evaluate - for (int i = 0; i < particlesSize_; i++) { - Solution * particle = new Solution(problem_); - problem_->evaluate(particle); - evaluations_ ++; - particles_->add(particle); - if ((globalBest_ == NULL) || (particle->getObjective(0) < globalBest_->getObjective(0))) { - if (globalBest_!= NULL) { - delete globalBest_; - } - globalBest_ = new Solution(particle); +SolutionSet * PSO::execute() +{ + + initParams(); + + success_ = false; + globalBest_ = NULL; + + //->Step 1 (and 3) Create the initial population and evaluate + for (int i = 0; i < particlesSize_; i++) + { + Solution * particle = new Solution(problem_); + problem_->evaluate(particle); + evaluations_ ++; + particles_->add(particle); + if ((globalBest_ == NULL) || (particle->getObjective(0) < globalBest_->getObjective(0))) + { + if (globalBest_!= NULL) + { + delete globalBest_; + } + globalBest_ = new Solution(particle); + } } - } - //-> Step2. Initialize the speed_ of each particle to 0 - for (int i = 0; i < particlesSize_; i++) { - speed_[i] = new double[problem_->getNumberOfVariables()]; - for (int j = 0; j < problem_->getNumberOfVariables(); j++) { - speed_[i][j] = 0.0; - } - } - - //-> Step 6. Initialize the memory of each particle - for (int i = 0; i < particles_->size(); i++) { - Solution * particle = new Solution(particles_->get(i)); - localBest_[i] = particle; - } - - //-> Step 7. Iterations .. - while (iteration_ < maxIterations_) { - int * bestIndividualPtr = (int*)findBestSolution_->execute(particles_); - int bestIndividual = *bestIndividualPtr; - delete bestIndividualPtr; - computeSpeed(iteration_, maxIterations_); - - //Compute the new positions for the particles_ - computeNewPositions(); - - //Mutate the particles_ - //mopsoMutation(iteration_, maxIterations_); - - //Evaluate the new particles_ in new positions - for (int i = 0; i < particles_->size(); i++) { - Solution * particle = particles_->get(i); - problem_->evaluate(particle); - evaluations_ ++; + //-> Step2. Initialize the speed_ of each particle to 0 + for (int i = 0; i < particlesSize_; i++) + { + speed_[i] = new double[problem_->getNumberOfVariables()]; + for (int j = 0; j < problem_->getNumberOfVariables(); j++) + { + speed_[i][j] = 0.0; + } } - //Actualize the memory of this particle - for (int i = 0; i < particles_->size(); i++) { - //int flag = comparator_.compare(particles_.get(i), localBest_[i]); - //if (flag < 0) { // the new particle is best_ than the older remember - if ((particles_->get(i)->getObjective(0) < localBest_[i]->getObjective(0))) { - Solution * particle = new Solution(particles_->get(i)); - delete localBest_[i]; - localBest_[i] = particle; - } // if - if ((particles_->get(i)->getObjective(0) < globalBest_->getObjective(0))) { - Solution * particle = new Solution(particles_->get(i)); - delete globalBest_; - globalBest_ = particle; - } // if + //-> Step 6. Initialize the memory of each particle + for (int i = 0; i < particles_->size(); i++) + { + Solution * particle = new Solution(particles_->get(i)); + localBest_[i] = particle; + } + //-> Step 7. Iterations .. + while (iteration_ < maxIterations_) + { + int * bestIndividualPtr = (int*)findBestSolution_->execute(particles_); + int bestIndividual = *bestIndividualPtr; + delete bestIndividualPtr; + computeSpeed(iteration_, maxIterations_); + + //Compute the new positions for the particles_ + computeNewPositions(); + + //Mutate the particles_ + //mopsoMutation(iteration_, maxIterations_); + + //Evaluate the new particles_ in new positions + for (int i = 0; i < particles_->size(); i++) + { + Solution * particle = particles_->get(i); + problem_->evaluate(particle); + evaluations_ ++; + } + + //Actualize the memory of this particle + for (int i = 0; i < particles_->size(); i++) + { + //int flag = comparator_.compare(particles_.get(i), localBest_[i]); + //if (flag < 0) { // the new particle is best_ than the older remember + if ((particles_->get(i)->getObjective(0) < localBest_[i]->getObjective(0))) + { + Solution * particle = new Solution(particles_->get(i)); + delete localBest_[i]; + localBest_[i] = particle; + } // if + if ((particles_->get(i)->getObjective(0) < globalBest_->getObjective(0))) + { + Solution * particle = new Solution(particles_->get(i)); + delete globalBest_; + globalBest_ = particle; + } // if + + } + iteration_++; } - iteration_++; - } - // Return a population with the best individual - SolutionSet * resultPopulation = new SolutionSet(1); - int * bestIndexPtr = (int *)findBestSolution_->execute(particles_); - int bestIndex = *bestIndexPtr; - delete bestIndexPtr; - Solution * s = particles_->get(bestIndex); - resultPopulation->add(new Solution(s)); + // Return a population with the best individual + SolutionSet * resultPopulation = new SolutionSet(1); + int * bestIndexPtr = (int *)findBestSolution_->execute(particles_); + int bestIndex = *bestIndexPtr; + delete bestIndexPtr; + Solution * s = particles_->get(bestIndex); + resultPopulation->add(new Solution(s)); - // Free memory - deleteParams(); + // Free memory + deleteParams(); - return resultPopulation; + return resultPopulation; } // execute diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.h b/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.h index 6ebb57b..a12936a 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.h +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.h @@ -36,86 +36,87 @@ * Class implementing a single-objective PSO algorithm */ -class PSO : public Algorithm { +class PSO : public Algorithm +{ private: - /** - * Stores the number of particles_ used - */ - int particlesSize_; - /** - * Stores the maximum number of iteration_ - */ - int maxIterations_; - /** - * Stores the current number of iteration_ - */ - int iteration_; - /** - * Stores the particles - */ - SolutionSet * particles_; - /** - * Stores the local best solutions found so far for each particles - */ - Solution ** localBest_; - /** - * Stores the global best solution found - */ - Solution * globalBest_; - /** - * Stores the speed_ of each particle - */ - double ** speed_; - /** - * Stores a operator for non uniform mutations - */ - Operator * polynomialMutation_; + /** + * Stores the number of particles_ used + */ + int particlesSize_; + /** + * Stores the maximum number of iteration_ + */ + int maxIterations_; + /** + * Stores the current number of iteration_ + */ + int iteration_; + /** + * Stores the particles + */ + SolutionSet * particles_; + /** + * Stores the local best solutions found so far for each particles + */ + Solution ** localBest_; + /** + * Stores the global best solution found + */ + Solution * globalBest_; + /** + * Stores the speed_ of each particle + */ + double ** speed_; + /** + * Stores a operator for non uniform mutations + */ + Operator * polynomialMutation_; - int evaluations_ ; + int evaluations_ ; - /** - * Comparator object - */ - Comparator * comparator_ ; + /** + * Comparator object + */ + Comparator * comparator_ ; - Operator * findBestSolution_ ; + Operator * findBestSolution_ ; - double r1Max_; - double r1Min_; - double r2Max_; - double r2Min_; - double C1Max_; - double C1Min_; - double C2Max_; - double C2Min_; - double WMax_; - double WMin_; - double ChVel1_; - double ChVel2_; + double r1Max_; + double r1Min_; + double r2Max_; + double r2Min_; + double C1Max_; + double C1Min_; + double C2Max_; + double C2Min_; + double WMax_; + double WMin_; + double ChVel1_; + double ChVel2_; - SolutionSet * trueFront_; - double * deltaMax_; - double * deltaMin_; - bool success_; + SolutionSet * trueFront_; + double * deltaMax_; + double * deltaMin_; + bool success_; - double inertiaWeight(int iter, int miter, double wmax, - double wmin); - double constrictionCoefficient(double c1, double c2); - double velocityConstriction(double v, double * deltaMax, - double * deltaMin, - int variableIndex, - int particleIndex); - void computeSpeed(int iter, int miter); - void computeNewPositions(); - void mopsoMutation(int actualIteration, int totalIterations); - void initParams(); - void deleteParams(); + double inertiaWeight(int iter, int miter, double wmax, + double wmin); + double constrictionCoefficient(double c1, double c2); + double velocityConstriction(double v, double * deltaMax, + double * deltaMin, + int variableIndex, + int particleIndex); + void computeSpeed(int iter, int miter); + void computeNewPositions(); + void mopsoMutation(int actualIteration, int totalIterations); + void initParams(); + void deleteParams(); public: - PSO(Problem * problem); - SolutionSet * execute(); + PSO(Problem * problem); + SolutionSet * execute(); }; diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp index 66d60b0..5d3563b 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp @@ -32,142 +32,162 @@ * Constructor * @param problem Problem to solve */ -StandardPSO2007::StandardPSO2007(Problem * problem) : Algorithm(problem) { +StandardPSO2007::StandardPSO2007(Problem * problem) : Algorithm(problem) +{ - W_ = 1.0/(2.0 * log(2)) ; //0.721; - C_ = 1.0/2.0 + log(2) ; //1.193; + W_ = 1.0/(2.0 * log(2)) ; //0.721; + C_ = 1.0/2.0 + log(2) ; //1.193; - comparator_ = new ObjectiveComparator(0) ; // Single objective comparator - map parameters ; // Operator parameters + comparator_ = new ObjectiveComparator(0) ; // Single objective comparator + map parameters ; // Operator parameters - parameters["comparator"] = comparator_; - findBestSolution_ = new BestSolutionSelection(parameters) ; + parameters["comparator"] = comparator_; + findBestSolution_ = new BestSolutionSelection(parameters) ; - evaluations_ = 0 ; + evaluations_ = 0 ; } // StandardPSO2007 /** * Destructor */ -StandardPSO2007::~StandardPSO2007() { - delete comparator_; - delete findBestSolution_; +StandardPSO2007::~StandardPSO2007() +{ + delete comparator_; + delete findBestSolution_; } // ~StandardPSO2007 -double StandardPSO2007::getW() { - return W_; +double StandardPSO2007::getW() +{ + return W_; } // getW -double StandardPSO2007::getC() { - return C_; +double StandardPSO2007::getC() +{ + return C_; } // getC /** * Initialize all parameters of the algorithm */ -void StandardPSO2007::initParams() { - swarmSize_ = *(int *) getInputParameter("swarmSize"); - maxIterations_ = *(int *) getInputParameter("maxIterations"); - numberOfParticlesToInform_ = *(int *) getInputParameter("numberOfParticlesToInform"); +void StandardPSO2007::initParams() +{ + swarmSize_ = *(int *) getInputParameter("swarmSize"); + maxIterations_ = *(int *) getInputParameter("maxIterations"); + numberOfParticlesToInform_ = *(int *) getInputParameter("numberOfParticlesToInform"); - cout << "Swarm size: " << swarmSize_ << endl; + cout << "Swarm size: " << swarmSize_ << endl; - iteration_ = 0; + iteration_ = 0; - swarm_ = new SolutionSet(swarmSize_); - localBest_ = new Solution*[swarmSize_]; - neighborhoodBest_ = new Solution*[swarmSize_]; + swarm_ = new SolutionSet(swarmSize_); + localBest_ = new Solution*[swarmSize_]; + neighborhoodBest_ = new Solution*[swarmSize_]; - // Create the speed_ vector - speed_ = new double*[swarmSize_]; + // Create the speed_ vector + speed_ = new double*[swarmSize_]; } // initParams /** * Delete all parameters of the algorithm */ -void StandardPSO2007::deleteParams() { - delete swarm_; - delete [] localBest_; - delete [] neighborhoodBest_; - delete [] speed_; +void StandardPSO2007::deleteParams() +{ + delete swarm_; + delete [] localBest_; + delete [] neighborhoodBest_; + delete [] speed_; } // deleteParams -Solution * StandardPSO2007::getNeighborBest(int i) { - Solution * bestLocalBestSolution = NULL ; +Solution * StandardPSO2007::getNeighborBest(int i) +{ + Solution * bestLocalBestSolution = NULL ; - for (int index : neighborhood_->getNeighbors(i)) { - if ((bestLocalBestSolution == NULL) || (bestLocalBestSolution->getObjective(0) > localBest_[index]->getObjective(0))) { - bestLocalBestSolution = localBest_[index] ; + for (int index : neighborhood_->getNeighbors(i)) + { + if ((bestLocalBestSolution == NULL) || (bestLocalBestSolution->getObjective(0) > localBest_[index]->getObjective(0))) + { + bestLocalBestSolution = localBest_[index] ; + } } - } - return bestLocalBestSolution ; + return bestLocalBestSolution ; } // getNeighborBest -void StandardPSO2007::computeSpeed() { - double r1, r2 ; +void StandardPSO2007::computeSpeed() +{ + double r1, r2 ; + + for (int i = 0; i < swarmSize_; i++) + { + + XReal * particle = new XReal(swarm_->get(i)) ; + XReal * localBest = new XReal(localBest_[i]) ; + XReal * neighborhoodBest = new XReal(neighborhoodBest_[i]) ; + //XReal * neighborhoodBest = new XReal(globalBest_) ; + + r1 = PseudoRandom::randDouble(0, C_); + r2 = PseudoRandom::randDouble(0, C_); + + //W_ = 0.9 ; + if (localBest_[i] != neighborhoodBest_[i]) + { + for (int var = 0; var < particle->getNumberOfDecisionVariables(); var++) + { + speed_[i][var] = W_ * speed_[i][var] + + r1 * (localBest->getValue(var) - particle->getValue(var)) + + r2 * (neighborhoodBest->getValue(var) - particle->getValue(var)); + } + } + else + { + for (int var = 0; var < particle->getNumberOfDecisionVariables(); var++) + { + speed_[i][var] = W_* speed_[i][var] + + r1 * (localBest->getValue(var) - particle->getValue(var)) ; + } + } + + delete particle; + delete localBest; + delete neighborhoodBest; - for (int i = 0; i < swarmSize_; i++) { - - XReal * particle = new XReal(swarm_->get(i)) ; - XReal * localBest = new XReal(localBest_[i]) ; - XReal * neighborhoodBest = new XReal(neighborhoodBest_[i]) ; - //XReal * neighborhoodBest = new XReal(globalBest_) ; - - r1 = PseudoRandom::randDouble(0, C_); - r2 = PseudoRandom::randDouble(0, C_); - - //W_ = 0.9 ; - if (localBest_[i] != neighborhoodBest_[i]) { - for (int var = 0; var < particle->getNumberOfDecisionVariables(); var++) { - speed_[i][var] = W_ * speed_[i][var] + - r1 * (localBest->getValue(var) - particle->getValue(var)) + - r2 * (neighborhoodBest->getValue(var) - particle->getValue(var)); - } - } - else { - for (int var = 0; var < particle->getNumberOfDecisionVariables(); var++) { - speed_[i][var] = W_* speed_[i][var] + - r1 * (localBest->getValue(var) - particle->getValue(var)) ; - } } - - delete particle; - delete localBest; - delete neighborhoodBest; - - } } // computeSpeed /** * Update the position of each particle */ -void StandardPSO2007::computeNewPositions() { - for (int i = 0; i < swarmSize_; i++) { - //Variable[] particle = swarm_.get(i).getDecisionVariables(); - XReal * particle = new XReal(swarm_->get(i)) ; - //particle.move(speed_[i]); - for (int var = 0; var < particle->size(); var++) { - particle->setValue(var, particle->getValue(var) + speed_[i][var]) ; - if (particle->getValue(var) < problem_->getLowerLimit(var)) { - particle->setValue(var, problem_->getLowerLimit(var)); - speed_[i][var] = 0; - } - if (particle->getValue(var) > problem_->getUpperLimit(var)) { - particle->setValue(var, problem_->getUpperLimit(var)); - speed_[i][var] = 0; - } +void StandardPSO2007::computeNewPositions() +{ + for (int i = 0; i < swarmSize_; i++) + { + //Variable[] particle = swarm_.get(i).getDecisionVariables(); + XReal * particle = new XReal(swarm_->get(i)) ; + //particle.move(speed_[i]); + for (int var = 0; var < particle->size(); var++) + { + particle->setValue(var, particle->getValue(var) + speed_[i][var]) ; + if (particle->getValue(var) < problem_->getLowerLimit(var)) + { + particle->setValue(var, problem_->getLowerLimit(var)); + speed_[i][var] = 0; + } + if (particle->getValue(var) > problem_->getUpperLimit(var)) + { + particle->setValue(var, problem_->getUpperLimit(var)); + speed_[i][var] = 0; + } + } + delete particle; } - delete particle; - } } // computeNewPositions @@ -176,121 +196,138 @@ void StandardPSO2007::computeNewPositions() { * @return a SolutionSet that is a set of non dominated solutions * as a result of the algorithm execution */ -SolutionSet * StandardPSO2007::execute() { - initParams(); - - // Step 1 Create the initial population and evaluate - for (int i = 0; i < swarmSize_; i++) { - Solution * particle = new Solution(problem_); - problem_->evaluate(particle); - evaluations_ ++ ; - swarm_->add(particle); - } - - neighborhood_ = new AdaptiveRandomNeighborhood(swarm_, numberOfParticlesToInform_) ; - - cout << "SwarmSize: " << swarmSize_ << endl; - cout << "Swarm size: " << swarm_->size() << endl; - cout << "list size: " << neighborhood_->getNeighborhood().size() << endl; - - //-> Step2. Initialize the speed_ of each particle - for (int i = 0; i < swarmSize_; i++) { - XReal * particle = new XReal(swarm_->get(i)) ; - speed_[i] = new double[problem_->getNumberOfVariables()]; - for (int j = 0; j < problem_->getNumberOfVariables(); j++) { - speed_[i][j] = (PseudoRandom::randDouble(particle->getLowerBound(j),particle->getUpperBound(j)) - - particle->getValue(j))/2.0 ; +SolutionSet * StandardPSO2007::execute() +{ + initParams(); + + // Step 1 Create the initial population and evaluate + for (int i = 0; i < swarmSize_; i++) + { + Solution * particle = new Solution(problem_); + problem_->evaluate(particle); + evaluations_ ++ ; + swarm_->add(particle); } - delete particle; - } - - //-> Step 6. Initialize the memory of each particle - for (int i = 0; i < swarm_->size(); i++) { - Solution * particle = new Solution(swarm_->get(i)); - localBest_[i] = particle; - } - - for (int i = 0; i < swarm_->size(); i++) { - neighborhoodBest_[i] = getNeighborBest(i) ; - } - - //cout << "neighborhood_i " << neighborhood_->getNeighbors(0) << endl; - cout << "["; - for (int i = 0; i < neighborhood_->getNeighbors(0).size()-1; i++) { - cout << neighborhood_->getNeighbors(0).at(i) << ","; - } - cout << neighborhood_->getNeighbors(0).back() << "]" << endl; - for (int s : neighborhood_->getNeighbors(0)) { - cout << s << ": " << localBest_[s]->getObjective(0) << endl; - } - - cout << "localBest_i " << localBest_[0]->getObjective(0) << endl; - cout << "neighborhoodBest_i " << getNeighborBest(0)->getObjective(0) << endl; - - cout << "Swarm: " << swarm_ << endl; - swarm_->printObjectives(); - double b = swarm_->best(comparator_)->getObjective(0) ; - cout << "Best: " << b << endl; - - double bestFoundFitness = numeric_limits::max(); - - while (iteration_ < maxIterations_) { - //Compute the speed - computeSpeed() ; - - //Compute the new positions for the swarm - computeNewPositions(); - - //Evaluate the new swarm_ in new positions - for (int i = 0; i < swarm_->size(); i++) { - Solution * particle = swarm_->get(i); - problem_->evaluate(particle); - evaluations_ ++ ; + + neighborhood_ = new AdaptiveRandomNeighborhood(swarm_, numberOfParticlesToInform_) ; + + cout << "SwarmSize: " << swarmSize_ << endl; + cout << "Swarm size: " << swarm_->size() << endl; + cout << "list size: " << neighborhood_->getNeighborhood().size() << endl; + + //-> Step2. Initialize the speed_ of each particle + for (int i = 0; i < swarmSize_; i++) + { + XReal * particle = new XReal(swarm_->get(i)) ; + speed_[i] = new double[problem_->getNumberOfVariables()]; + for (int j = 0; j < problem_->getNumberOfVariables(); j++) + { + speed_[i][j] = (PseudoRandom::randDouble(particle->getLowerBound(j),particle->getUpperBound(j)) + - particle->getValue(j))/2.0 ; + } + delete particle; } - //Update the memory of the particles - for (int i = 0; i < swarm_->size(); i++) { - if ((swarm_->get(i)->getObjective(0) < localBest_[i]->getObjective(0))) { + //-> Step 6. Initialize the memory of each particle + for (int i = 0; i < swarm_->size(); i++) + { Solution * particle = new Solution(swarm_->get(i)); - delete localBest_[i]; localBest_[i] = particle; - } // if } - for (int i = 0; i < swarm_->size(); i++) { - neighborhoodBest_[i] = getNeighborBest(i) ; + + for (int i = 0; i < swarm_->size(); i++) + { + neighborhoodBest_[i] = getNeighborBest(i) ; } - iteration_++; - //System.out.println("Swarm( " + iteration_+ "): " + swarm_) ; - //swarm_.printObjectives(); - double bestCurrentFitness = swarm_->best(comparator_)->getObjective(0) ; - cout << "Best: " << bestCurrentFitness << endl; + //cout << "neighborhood_i " << neighborhood_->getNeighbors(0) << endl; + cout << "["; + for (int i = 0; i < neighborhood_->getNeighbors(0).size()-1; i++) + { + cout << neighborhood_->getNeighbors(0).at(i) << ","; + } + cout << neighborhood_->getNeighbors(0).back() << "]" << endl; + for (int s : neighborhood_->getNeighbors(0)) + { + cout << s << ": " << localBest_[s]->getObjective(0) << endl; + } - if (bestCurrentFitness == bestFoundFitness) { - cout << "Recomputing" << endl; - neighborhood_->recompute(); + cout << "localBest_i " << localBest_[0]->getObjective(0) << endl; + cout << "neighborhoodBest_i " << getNeighborBest(0)->getObjective(0) << endl; + + cout << "Swarm: " << swarm_ << endl; + swarm_->printObjectives(); + double b = swarm_->best(comparator_)->getObjective(0) ; + cout << "Best: " << b << endl; + + double bestFoundFitness = numeric_limits::max(); + + while (iteration_ < maxIterations_) + { + //Compute the speed + computeSpeed() ; + + //Compute the new positions for the swarm + computeNewPositions(); + + //Evaluate the new swarm_ in new positions + for (int i = 0; i < swarm_->size(); i++) + { + Solution * particle = swarm_->get(i); + problem_->evaluate(particle); + evaluations_ ++ ; + } + + //Update the memory of the particles + for (int i = 0; i < swarm_->size(); i++) + { + if ((swarm_->get(i)->getObjective(0) < localBest_[i]->getObjective(0))) + { + Solution * particle = new Solution(swarm_->get(i)); + delete localBest_[i]; + localBest_[i] = particle; + } // if + } + for (int i = 0; i < swarm_->size(); i++) + { + neighborhoodBest_[i] = getNeighborBest(i) ; + } + + iteration_++; + //System.out.println("Swarm( " + iteration_+ "): " + swarm_) ; + //swarm_.printObjectives(); + double bestCurrentFitness = swarm_->best(comparator_)->getObjective(0) ; + cout << "Best: " << bestCurrentFitness << endl; + + if (bestCurrentFitness == bestFoundFitness) + { + cout << "Recomputing" << endl; + neighborhood_->recompute(); + } + + if (bestCurrentFitness < bestFoundFitness) + { + bestFoundFitness = bestCurrentFitness ; + } } - if (bestCurrentFitness < bestFoundFitness) { - bestFoundFitness = bestCurrentFitness ; + // Return a population with the best individual + SolutionSet * resultPopulation = new SolutionSet(1) ; + int * bestSolutionIdx = (int *) findBestSolution_->execute(swarm_); + resultPopulation->add(new Solution(swarm_->get(* bestSolutionIdx))) ; + delete bestSolutionIdx; + + // Free memory + for (int i = 0; i < swarmSize_; i++) + { + delete [] speed_[i]; } - } - - // Return a population with the best individual - SolutionSet * resultPopulation = new SolutionSet(1) ; - int * bestSolutionIdx = (int *) findBestSolution_->execute(swarm_); - resultPopulation->add(new Solution(swarm_->get(* bestSolutionIdx))) ; - delete bestSolutionIdx; - - // Free memory - for (int i = 0; i < swarmSize_; i++) { - delete [] speed_[i]; - } - for (int i = 0; i < swarm_->size(); i++) { - delete localBest_[i]; - } - delete neighborhood_; - deleteParams(); - - return resultPopulation ; + for (int i = 0; i < swarm_->size(); i++) + { + delete localBest_[i]; + } + delete neighborhood_; + deleteParams(); + + return resultPopulation ; } // execute diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.h b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.h index e0ce910..9b17fdb 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.h +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.h @@ -36,46 +36,47 @@ /** * Class implementing a Standard PSO 2007 algorithm */ -class StandardPSO2007 : public Algorithm { +class StandardPSO2007 : public Algorithm +{ private: - SolutionSet * swarm_; - int swarmSize_; - int maxIterations_; - int iteration_; - int numberOfParticlesToInform_ ; // Referred a K in the SPSO document - Solution ** localBest_; - Solution ** neighborhoodBest_; - double ** speed_; - AdaptiveRandomNeighborhood * neighborhood_ ; + SolutionSet * swarm_; + int swarmSize_; + int maxIterations_; + int iteration_; + int numberOfParticlesToInform_ ; // Referred a K in the SPSO document + Solution ** localBest_; + Solution ** neighborhoodBest_; + double ** speed_; + AdaptiveRandomNeighborhood * neighborhood_ ; - int evaluations_ ; + int evaluations_ ; - /** - * Comparator object - */ - Comparator * comparator_ ; + /** + * Comparator object + */ + Comparator * comparator_ ; - Operator * findBestSolution_ ; + Operator * findBestSolution_ ; - double W_; - double C_; + double W_; + double C_; - void initParams(); - void deleteParams(); - Solution * getNeighborBest(int i); - void computeSpeed(); - void computeNewPositions(); + void initParams(); + void deleteParams(); + Solution * getNeighborBest(int i); + void computeSpeed(); + void computeNewPositions(); public: - double getW(); - double getC(); + double getW(); + double getC(); - StandardPSO2007(Problem * problem); - ~StandardPSO2007(); - SolutionSet * execute(); + StandardPSO2007(Problem * problem); + ~StandardPSO2007(); + SolutionSet * execute(); }; // StandardPSO2007 diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp index 56448dc..d29060e 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp @@ -32,165 +32,188 @@ * Constructor * @param problem Problem to solve */ -StandardPSO2011::StandardPSO2011(Problem * problem) : Algorithm(problem) { +StandardPSO2011::StandardPSO2011(Problem * problem) : Algorithm(problem) +{ - W_ = 1.0/(2.0 * log(2)) ; //0.721; - C_ = 1.0/2.0 + log(2) ; //1.193; - ChVel_ = -0.5 ; + W_ = 1.0/(2.0 * log(2)) ; //0.721; + C_ = 1.0/2.0 + log(2) ; //1.193; + ChVel_ = -0.5 ; - comparator_ = new ObjectiveComparator(0) ; // Single objective comparator - map parameters ; // Operator parameters + comparator_ = new ObjectiveComparator(0) ; // Single objective comparator + map parameters ; // Operator parameters - parameters["comparator"] = comparator_; - findBestSolution_ = new BestSolutionSelection(parameters) ; + parameters["comparator"] = comparator_; + findBestSolution_ = new BestSolutionSelection(parameters) ; - evaluations_ = 0 ; + evaluations_ = 0 ; } // StandardPSO2011 /** * Destructor */ -StandardPSO2011::~StandardPSO2011() { - delete comparator_; - delete findBestSolution_; +StandardPSO2011::~StandardPSO2011() +{ + delete comparator_; + delete findBestSolution_; } // ~StandardPSO2011 -double StandardPSO2011::getW() { - return W_; +double StandardPSO2011::getW() +{ + return W_; } // getW -double StandardPSO2011::getC() { - return C_; +double StandardPSO2011::getC() +{ + return C_; } // getC /** * Initialize all parameters of the algorithm */ -void StandardPSO2011::initParams() { - swarmSize_ = *(int *) getInputParameter("swarmSize"); - maxIterations_ = *(int *) getInputParameter("maxIterations"); - numberOfParticlesToInform_ = *(int *) getInputParameter("numberOfParticlesToInform"); +void StandardPSO2011::initParams() +{ + swarmSize_ = *(int *) getInputParameter("swarmSize"); + maxIterations_ = *(int *) getInputParameter("maxIterations"); + numberOfParticlesToInform_ = *(int *) getInputParameter("numberOfParticlesToInform"); - cout << "Swarm size: " << swarmSize_ << endl; + cout << "Swarm size: " << swarmSize_ << endl; - iteration_ = 0; + iteration_ = 0; - swarm_ = new SolutionSet(swarmSize_); - localBest_ = new Solution*[swarmSize_]; - neighborhoodBest_ = new Solution*[swarmSize_]; + swarm_ = new SolutionSet(swarmSize_); + localBest_ = new Solution*[swarmSize_]; + neighborhoodBest_ = new Solution*[swarmSize_]; - // Create the speed_ vector - speed_ = new double*[swarmSize_]; + // Create the speed_ vector + speed_ = new double*[swarmSize_]; } // initParams /** * Delete all parameters of the algorithm */ -void StandardPSO2011::deleteParams() { - delete swarm_; - delete [] localBest_; - delete [] neighborhoodBest_; - delete [] speed_; +void StandardPSO2011::deleteParams() +{ + delete swarm_; + delete [] localBest_; + delete [] neighborhoodBest_; + delete [] speed_; } // deleteParams -Solution * StandardPSO2011::getNeighborBest(int i) { - Solution * bestLocalBestSolution = NULL ; +Solution * StandardPSO2011::getNeighborBest(int i) +{ + Solution * bestLocalBestSolution = NULL ; - for (int index : neighborhood_->getNeighbors(i)) { - if ((bestLocalBestSolution == NULL) || (bestLocalBestSolution->getObjective(0) > localBest_[index]->getObjective(0))) { - bestLocalBestSolution = localBest_[index] ; + for (int index : neighborhood_->getNeighbors(i)) + { + if ((bestLocalBestSolution == NULL) || (bestLocalBestSolution->getObjective(0) > localBest_[index]->getObjective(0))) + { + bestLocalBestSolution = localBest_[index] ; + } } - } - return bestLocalBestSolution ; + return bestLocalBestSolution ; } // getNeighborBest -void StandardPSO2011::computeSpeed() { +void StandardPSO2011::computeSpeed() +{ + + for (int i = 0; i < swarmSize_; i++) + { + XReal * particle = new XReal(swarm_->get(i)) ; + XReal * localBest = new XReal(localBest_[i]) ; + XReal * neighborhoodBest = new XReal(neighborhoodBest_[i]) ; + + Solution * gravityCenterSolution = new Solution(problem_); + XReal * gravityCenter = new XReal(gravityCenterSolution) ; + Solution * randomParticleSolution = new Solution(swarm_->get(i)); + XReal * randomParticle = new XReal (randomParticleSolution) ; + + if (localBest_[i] != neighborhoodBest_[i]) + { + for (int var = 0; var < particle->size(); var++) + { + double G; + G = particle->getValue(var) + + C_ * (localBest->getValue(var) + neighborhoodBest->getValue(var) - 2 * particle->getValue(var)) / 3.0; + + gravityCenter->setValue(var, G); + } + } + else + { + for (int var = 0; var < particle->size(); var++) + { + double G; + G = particle->getValue(var) + + C_ * (localBest->getValue(var) - particle->getValue(var)) / 2.0; + + gravityCenter->setValue(var, G); + } + } + + double radius = 0; + Distance * distance = new Distance(); + radius = distance->distanceBetweenSolutions(gravityCenter->getSolution(), particle->getSolution()); + delete distance; + + double * random = PseudoRandom::randSphere(problem_->getNumberOfVariables()) ; + for (int var = 0; var < particle->size(); var++) + { + randomParticle->setValue(var, gravityCenter->getValue(var) + radius*random[var]) ; + } + delete [] random; + + for (int var = 0; var < particle->getNumberOfDecisionVariables(); var++) + { + speed_[i][var] = W_*speed_[i][var] + randomParticle->getValue(var) - particle->getValue(var); + } + + delete particle; + delete localBest; + delete neighborhoodBest; + + delete gravityCenterSolution; + delete gravityCenter; + delete randomParticleSolution; + delete randomParticle; - for (int i = 0; i < swarmSize_; i++) { - XReal * particle = new XReal(swarm_->get(i)) ; - XReal * localBest = new XReal(localBest_[i]) ; - XReal * neighborhoodBest = new XReal(neighborhoodBest_[i]) ; - - Solution * gravityCenterSolution = new Solution(problem_); - XReal * gravityCenter = new XReal(gravityCenterSolution) ; - Solution * randomParticleSolution = new Solution(swarm_->get(i)); - XReal * randomParticle = new XReal (randomParticleSolution) ; - - if (localBest_[i] != neighborhoodBest_[i]) { - for (int var = 0; var < particle->size(); var++) { - double G; - G = particle->getValue(var) + - C_ * (localBest->getValue(var) + neighborhoodBest->getValue(var) - 2 * particle->getValue(var)) / 3.0; - - gravityCenter->setValue(var, G); - } - } else { - for (int var = 0; var < particle->size(); var++) { - double G; - G = particle->getValue(var) + - C_ * (localBest->getValue(var) - particle->getValue(var)) / 2.0; - - gravityCenter->setValue(var, G); - } } - - double radius = 0; - Distance * distance = new Distance(); - radius = distance->distanceBetweenSolutions(gravityCenter->getSolution(), particle->getSolution()); - delete distance; - - double * random = PseudoRandom::randSphere(problem_->getNumberOfVariables()) ; - for (int var = 0; var < particle->size(); var++) { - randomParticle->setValue(var, gravityCenter->getValue(var) + radius*random[var]) ; - } - delete [] random; - - for (int var = 0; var < particle->getNumberOfDecisionVariables(); var++) { - speed_[i][var] = W_*speed_[i][var] + randomParticle->getValue(var) - particle->getValue(var); - } - - delete particle; - delete localBest; - delete neighborhoodBest; - - delete gravityCenterSolution; - delete gravityCenter; - delete randomParticleSolution; - delete randomParticle; - - } } // computeSpeed /** * Update the position of each particle */ -void StandardPSO2011::computeNewPositions() { - for (int i = 0; i < swarmSize_; i++) { - //Variable[] particle = swarm_.get(i).getDecisionVariables(); - XReal * particle = new XReal(swarm_->get(i)) ; - //particle.move(speed_[i]); - for (int var = 0; var < particle->size(); var++) { - particle->setValue(var, particle->getValue(var) + speed_[i][var]) ; - if (particle->getValue(var) < problem_->getLowerLimit(var)) { - particle->setValue(var, problem_->getLowerLimit(var)); - speed_[i][var] = ChVel_ * speed_[i][var]; - } - if (particle->getValue(var) > problem_->getUpperLimit(var)) { - particle->setValue(var, problem_->getUpperLimit(var)); - speed_[i][var] = ChVel_ * speed_[i][var]; - } +void StandardPSO2011::computeNewPositions() +{ + for (int i = 0; i < swarmSize_; i++) + { + //Variable[] particle = swarm_.get(i).getDecisionVariables(); + XReal * particle = new XReal(swarm_->get(i)) ; + //particle.move(speed_[i]); + for (int var = 0; var < particle->size(); var++) + { + particle->setValue(var, particle->getValue(var) + speed_[i][var]) ; + if (particle->getValue(var) < problem_->getLowerLimit(var)) + { + particle->setValue(var, problem_->getLowerLimit(var)); + speed_[i][var] = ChVel_ * speed_[i][var]; + } + if (particle->getValue(var) > problem_->getUpperLimit(var)) + { + particle->setValue(var, problem_->getUpperLimit(var)); + speed_[i][var] = ChVel_ * speed_[i][var]; + } + } + delete particle; } - delete particle; - } } // computeNewPositions @@ -199,122 +222,139 @@ void StandardPSO2011::computeNewPositions() { * @return a SolutionSet that is a set of non dominated solutions * as a result of the algorithm execution */ -SolutionSet * StandardPSO2011::execute() { - initParams(); - - // Step 1 Create the initial population and evaluate - for (int i = 0; i < swarmSize_; i++) { - Solution * particle = new Solution(problem_); - problem_->evaluate(particle); - evaluations_ ++ ; - swarm_->add(particle); - } - - neighborhood_ = new AdaptiveRandomNeighborhood(swarm_, numberOfParticlesToInform_) ; - - cout << "SwarmSize: " << swarmSize_ << endl; - cout << "Swarm size: " << swarm_->size() << endl; - cout << "list size: " << neighborhood_->getNeighborhood().size() << endl; - - //-> Step2. Initialize the speed_ of each particle - for (int i = 0; i < swarmSize_; i++) { - XReal * particle = new XReal(swarm_->get(i)) ; - speed_[i] = new double[problem_->getNumberOfVariables()]; - for (int j = 0; j < problem_->getNumberOfVariables(); j++) { - speed_[i][j] = (PseudoRandom::randDouble( - particle->getLowerBound(j) - particle->getValue(0), - particle->getUpperBound(j) - particle->getValue(0))) ; +SolutionSet * StandardPSO2011::execute() +{ + initParams(); + + // Step 1 Create the initial population and evaluate + for (int i = 0; i < swarmSize_; i++) + { + Solution * particle = new Solution(problem_); + problem_->evaluate(particle); + evaluations_ ++ ; + swarm_->add(particle); } - delete particle; - } - - //-> Step 6. Initialize the memory of each particle - for (int i = 0; i < swarm_->size(); i++) { - Solution * particle = new Solution(swarm_->get(i)); - localBest_[i] = particle; - } - - for (int i = 0; i < swarm_->size(); i++) { - neighborhoodBest_[i] = getNeighborBest(i) ; - } - - //cout << "neighborhood_i " << neighborhood_->getNeighbors(0) << endl; - cout << "["; - for (int i = 0; i < neighborhood_->getNeighbors(0).size()-1; i++) { - cout << neighborhood_->getNeighbors(0).at(i) << ","; - } - cout << neighborhood_->getNeighbors(0).back() << "]" << endl; - for (int s : neighborhood_->getNeighbors(0)) { - cout << s << ": " << localBest_[s]->getObjective(0) << endl; - } - - cout << "localBest_i " << localBest_[0]->getObjective(0) << endl; - cout << "neighborhoodBest_i " << getNeighborBest(0)->getObjective(0) << endl; - - cout << "Swarm: " << swarm_ << endl; - swarm_->printObjectives(); - double b = swarm_->best(comparator_)->getObjective(0) ; - cout << "Best: " << b << endl; - - double bestFoundFitness = numeric_limits::max(); - - while (iteration_ < maxIterations_) { - //Compute the speed - computeSpeed() ; - - //Compute the new positions for the swarm - computeNewPositions(); - - //Evaluate the new swarm_ in new positions - for (int i = 0; i < swarm_->size(); i++) { - Solution * particle = swarm_->get(i); - problem_->evaluate(particle); - evaluations_ ++ ; + + neighborhood_ = new AdaptiveRandomNeighborhood(swarm_, numberOfParticlesToInform_) ; + + cout << "SwarmSize: " << swarmSize_ << endl; + cout << "Swarm size: " << swarm_->size() << endl; + cout << "list size: " << neighborhood_->getNeighborhood().size() << endl; + + //-> Step2. Initialize the speed_ of each particle + for (int i = 0; i < swarmSize_; i++) + { + XReal * particle = new XReal(swarm_->get(i)) ; + speed_[i] = new double[problem_->getNumberOfVariables()]; + for (int j = 0; j < problem_->getNumberOfVariables(); j++) + { + speed_[i][j] = (PseudoRandom::randDouble( + particle->getLowerBound(j) - particle->getValue(0), + particle->getUpperBound(j) - particle->getValue(0))) ; + } + delete particle; } - //Update the memory of the particles - for (int i = 0; i < swarm_->size(); i++) { - if ((swarm_->get(i)->getObjective(0) < localBest_[i]->getObjective(0))) { + //-> Step 6. Initialize the memory of each particle + for (int i = 0; i < swarm_->size(); i++) + { Solution * particle = new Solution(swarm_->get(i)); - delete localBest_[i]; localBest_[i] = particle; - } // if } - for (int i = 0; i < swarm_->size(); i++) { - neighborhoodBest_[i] = getNeighborBest(i) ; + + for (int i = 0; i < swarm_->size(); i++) + { + neighborhoodBest_[i] = getNeighborBest(i) ; } - iteration_++; - //System.out.println("Swarm( " + iteration_+ "): " + swarm_) ; - //swarm_.printObjectives(); - double bestCurrentFitness = swarm_->best(comparator_)->getObjective(0) ; - //cout << "Best: " << bestCurrentFitness << endl; + //cout << "neighborhood_i " << neighborhood_->getNeighbors(0) << endl; + cout << "["; + for (int i = 0; i < neighborhood_->getNeighbors(0).size()-1; i++) + { + cout << neighborhood_->getNeighbors(0).at(i) << ","; + } + cout << neighborhood_->getNeighbors(0).back() << "]" << endl; + for (int s : neighborhood_->getNeighbors(0)) + { + cout << s << ": " << localBest_[s]->getObjective(0) << endl; + } - if (bestCurrentFitness == bestFoundFitness) { - //cout << "Recomputing" << endl; - neighborhood_->recompute(); + cout << "localBest_i " << localBest_[0]->getObjective(0) << endl; + cout << "neighborhoodBest_i " << getNeighborBest(0)->getObjective(0) << endl; + + cout << "Swarm: " << swarm_ << endl; + swarm_->printObjectives(); + double b = swarm_->best(comparator_)->getObjective(0) ; + cout << "Best: " << b << endl; + + double bestFoundFitness = numeric_limits::max(); + + while (iteration_ < maxIterations_) + { + //Compute the speed + computeSpeed() ; + + //Compute the new positions for the swarm + computeNewPositions(); + + //Evaluate the new swarm_ in new positions + for (int i = 0; i < swarm_->size(); i++) + { + Solution * particle = swarm_->get(i); + problem_->evaluate(particle); + evaluations_ ++ ; + } + + //Update the memory of the particles + for (int i = 0; i < swarm_->size(); i++) + { + if ((swarm_->get(i)->getObjective(0) < localBest_[i]->getObjective(0))) + { + Solution * particle = new Solution(swarm_->get(i)); + delete localBest_[i]; + localBest_[i] = particle; + } // if + } + for (int i = 0; i < swarm_->size(); i++) + { + neighborhoodBest_[i] = getNeighborBest(i) ; + } + + iteration_++; + //System.out.println("Swarm( " + iteration_+ "): " + swarm_) ; + //swarm_.printObjectives(); + double bestCurrentFitness = swarm_->best(comparator_)->getObjective(0) ; + //cout << "Best: " << bestCurrentFitness << endl; + + if (bestCurrentFitness == bestFoundFitness) + { + //cout << "Recomputing" << endl; + neighborhood_->recompute(); + } + + if (bestCurrentFitness < bestFoundFitness) + { + bestFoundFitness = bestCurrentFitness ; + } } - if (bestCurrentFitness < bestFoundFitness) { - bestFoundFitness = bestCurrentFitness ; + // Return a population with the best individual + SolutionSet * resultPopulation = new SolutionSet(1) ; + int * bestSolutionIdx = (int *) findBestSolution_->execute(swarm_); + resultPopulation->add(new Solution(swarm_->get(* bestSolutionIdx))) ; + delete bestSolutionIdx; + + // Free memory + for (int i = 0; i < swarmSize_; i++) + { + delete [] speed_[i]; } - } - - // Return a population with the best individual - SolutionSet * resultPopulation = new SolutionSet(1) ; - int * bestSolutionIdx = (int *) findBestSolution_->execute(swarm_); - resultPopulation->add(new Solution(swarm_->get(* bestSolutionIdx))) ; - delete bestSolutionIdx; - - // Free memory - for (int i = 0; i < swarmSize_; i++) { - delete [] speed_[i]; - } - for (int i = 0; i < swarm_->size(); i++) { - delete localBest_[i]; - } - delete neighborhood_; - deleteParams(); - - return resultPopulation ; + for (int i = 0; i < swarm_->size(); i++) + { + delete localBest_[i]; + } + delete neighborhood_; + deleteParams(); + + return resultPopulation ; } // execute diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.h b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.h index 20c27ed..5c41dd4 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.h +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.h @@ -37,47 +37,48 @@ /** * Class implementing a Standard PSO 2011 algorithm */ -class StandardPSO2011 : public Algorithm { +class StandardPSO2011 : public Algorithm +{ private: - SolutionSet * swarm_; - int swarmSize_; - int maxIterations_; - int iteration_; - int numberOfParticlesToInform_ ; // Referred a K in the SPSO document - Solution ** localBest_; - Solution ** neighborhoodBest_; - double ** speed_; - AdaptiveRandomNeighborhood * neighborhood_ ; + SolutionSet * swarm_; + int swarmSize_; + int maxIterations_; + int iteration_; + int numberOfParticlesToInform_ ; // Referred a K in the SPSO document + Solution ** localBest_; + Solution ** neighborhoodBest_; + double ** speed_; + AdaptiveRandomNeighborhood * neighborhood_ ; - int evaluations_ ; + int evaluations_ ; - /** - * Comparator object - */ - Comparator * comparator_ ; + /** + * Comparator object + */ + Comparator * comparator_ ; - Operator * findBestSolution_ ; + Operator * findBestSolution_ ; - double W_; - double C_; - double ChVel_; + double W_; + double C_; + double ChVel_; - void initParams(); - void deleteParams(); - Solution * getNeighborBest(int i); - void computeSpeed(); - void computeNewPositions(); + void initParams(); + void deleteParams(); + Solution * getNeighborBest(int i); + void computeSpeed(); + void computeNewPositions(); public: - double getW(); - double getC(); + double getW(); + double getC(); - StandardPSO2011(Problem * problem); - ~StandardPSO2011(); - SolutionSet * execute(); + StandardPSO2011(Problem * problem); + ~StandardPSO2011(); + SolutionSet * execute(); }; // StandardPSO2011 diff --git a/src/metaheuristics/smpso/SMPSO.cpp b/src/metaheuristics/smpso/SMPSO.cpp index 034780a..477ddb4 100644 --- a/src/metaheuristics/smpso/SMPSO.cpp +++ b/src/metaheuristics/smpso/SMPSO.cpp @@ -31,96 +31,100 @@ * Constructor * @param problem Problem to solve */ -SMPSO::SMPSO(Problem *problem) : Algorithm(problem) { - r1Max_ = 1.0; - r1Min_ = 0.0; - r2Max_ = 1.0; - r2Min_ = 0.0; - C1Max_ = 2.5; - C1Min_ = 1.5; - C2Max_ = 2.5; - C2Min_ = 1.5; - WMax_ = 0.1; - WMin_ = 0.1; - ChVel1_ = -1; - ChVel2_ = -1; +SMPSO::SMPSO(Problem *problem) : Algorithm(problem) +{ + r1Max_ = 1.0; + r1Min_ = 0.0; + r2Max_ = 1.0; + r2Min_ = 0.0; + C1Max_ = 2.5; + C1Min_ = 1.5; + C2Max_ = 2.5; + C2Min_ = 1.5; + WMax_ = 0.1; + WMin_ = 0.1; + ChVel1_ = -1; + ChVel2_ = -1; } // SMPSO /** * Initialize all parameter of the algorithm */ -void SMPSO::initParams() { - swarmSize_ = *(int *) getInputParameter("swarmSize"); - archiveSize_ = *(int *) getInputParameter("archiveSize"); - maxIterations_ = *(int *) getInputParameter("maxIterations"); - - setAlgParams(); - - // TODO: indicators_ = (QualityIndicator) getInputParameter("indicators"); - - polynomialMutation_ = operators_["mutation"] ; - - iteration_ = 0 ; - - success_ = false; - - particles_ = new SolutionSet(swarmSize_); - best_ = new Solution*[swarmSize_]; - leaders_ = new CrowdingArchive(archiveSize_, problem_->getNumberOfObjectives()); - - // Create comparators for dominance and crowding distance - dominance_ = new DominanceComparator(); - crowdingDistanceComparator_ = new CrowdingDistanceComparator(); - distance_ = new Distance(); - - // Create the speed_ vector - int numberOfVariables = problem_->getNumberOfVariables(); - //speed_ = new double[swarmSize_][numberOfVariables]; - speed_ = new double*[swarmSize_]; - // TODO: Liberar memoria al finalizar - - deltaMax_ = new double[problem_->getNumberOfVariables()]; - deltaMin_ = new double[problem_->getNumberOfVariables()]; - for (int i = 0; i < problem_->getNumberOfVariables(); i++) { - deltaMax_[i] = (problem_->getUpperLimit(i) - - problem_->getLowerLimit(i)) / 2.0; - deltaMin_[i] = -deltaMax_[i]; - } // for +void SMPSO::initParams() +{ + swarmSize_ = *(int *) getInputParameter("swarmSize"); + archiveSize_ = *(int *) getInputParameter("archiveSize"); + maxIterations_ = *(int *) getInputParameter("maxIterations"); + + setAlgParams(); + + // TODO: indicators_ = (QualityIndicator) getInputParameter("indicators"); + + polynomialMutation_ = operators_["mutation"] ; + + iteration_ = 0 ; + + success_ = false; + + particles_ = new SolutionSet(swarmSize_); + best_ = new Solution*[swarmSize_]; + leaders_ = new CrowdingArchive(archiveSize_, problem_->getNumberOfObjectives()); + + // Create comparators for dominance and crowding distance + dominance_ = new DominanceComparator(); + crowdingDistanceComparator_ = new CrowdingDistanceComparator(); + distance_ = new Distance(); + + // Create the speed_ vector + int numberOfVariables = problem_->getNumberOfVariables(); + //speed_ = new double[swarmSize_][numberOfVariables]; + speed_ = new double*[swarmSize_]; + // TODO: Liberar memoria al finalizar + + deltaMax_ = new double[problem_->getNumberOfVariables()]; + deltaMin_ = new double[problem_->getNumberOfVariables()]; + for (int i = 0; i < problem_->getNumberOfVariables(); i++) + { + deltaMax_[i] = (problem_->getUpperLimit(i) - + problem_->getLowerLimit(i)) / 2.0; + deltaMin_[i] = -deltaMax_[i]; + } // for } // initParams - + /** * Read all user input parameters * Possible params: r1Max, r1Min, r2Max, r2Min, C1Max, C1Min, C2Max, C2Min, * WMax, Wmin, ChVel1, ChVel2 */ -void SMPSO::setAlgParams() { - - void * r1MaxPtr = getInputParameter("r1Max"); - void * r1MinPtr = getInputParameter("r1Min"); - void * r2MaxPtr = getInputParameter("r2Max"); - void * r2MinPtr = getInputParameter("r2Min"); - void * C1MaxPtr = getInputParameter("C1Min"); - void * C1MinPtr = getInputParameter("C1Max"); - void * C2MaxPtr = getInputParameter("C2Max"); - void * C2MinPtr = getInputParameter("C2Min"); - void * WMaxPtr = getInputParameter("WMax"); - void * WMinPtr = getInputParameter("WMin"); - void * ChVel1Ptr = getInputParameter("ChVel1"); - void * ChVel2Ptr = getInputParameter("ChVel2"); - - if (r1MaxPtr != NULL) r1Max_ = * (double *) r1MaxPtr; - if (r1MinPtr != NULL) r1Min_ = * (double *) r1MinPtr; - if (r2MaxPtr != NULL) r2Max_ = * (double *) r2MaxPtr; - if (r2MinPtr != NULL) r2Min_ = * (double *) r2MinPtr; - if (C1MaxPtr != NULL) C1Max_ = * (double *) C1MaxPtr; - if (C1MinPtr != NULL) C1Min_ = * (double *) C1MinPtr; - if (C2MaxPtr != NULL) C2Max_ = * (double *) C2MaxPtr; - if (C2MinPtr != NULL) C2Min_ = * (double *) C2MinPtr; - if (WMaxPtr != NULL) WMax_ = * (double *) WMaxPtr; - if (WMinPtr != NULL) WMin_ = * (double *) WMinPtr; - if (ChVel1Ptr != NULL) ChVel1_ = * (double *) ChVel1Ptr; - if (ChVel2Ptr != NULL) ChVel2_ = * (double *) ChVel2Ptr; +void SMPSO::setAlgParams() +{ + + void * r1MaxPtr = getInputParameter("r1Max"); + void * r1MinPtr = getInputParameter("r1Min"); + void * r2MaxPtr = getInputParameter("r2Max"); + void * r2MinPtr = getInputParameter("r2Min"); + void * C1MaxPtr = getInputParameter("C1Min"); + void * C1MinPtr = getInputParameter("C1Max"); + void * C2MaxPtr = getInputParameter("C2Max"); + void * C2MinPtr = getInputParameter("C2Min"); + void * WMaxPtr = getInputParameter("WMax"); + void * WMinPtr = getInputParameter("WMin"); + void * ChVel1Ptr = getInputParameter("ChVel1"); + void * ChVel2Ptr = getInputParameter("ChVel2"); + + if (r1MaxPtr != NULL) r1Max_ = * (double *) r1MaxPtr; + if (r1MinPtr != NULL) r1Min_ = * (double *) r1MinPtr; + if (r2MaxPtr != NULL) r2Max_ = * (double *) r2MaxPtr; + if (r2MinPtr != NULL) r2Min_ = * (double *) r2MinPtr; + if (C1MaxPtr != NULL) C1Max_ = * (double *) C1MaxPtr; + if (C1MinPtr != NULL) C1Min_ = * (double *) C1MinPtr; + if (C2MaxPtr != NULL) C2Max_ = * (double *) C2MaxPtr; + if (C2MinPtr != NULL) C2Min_ = * (double *) C2MinPtr; + if (WMaxPtr != NULL) WMax_ = * (double *) WMaxPtr; + if (WMinPtr != NULL) WMin_ = * (double *) WMinPtr; + if (ChVel1Ptr != NULL) ChVel1_ = * (double *) ChVel1Ptr; + if (ChVel2Ptr != NULL) ChVel2_ = * (double *) ChVel2Ptr; } // setAlgParams @@ -128,123 +132,140 @@ void SMPSO::setAlgParams() { /** * Free all the memory reserved by the algorithm */ -void SMPSO::deleteParams() { - - for (int i = 0; i < swarmSize_; i++) { - delete [] speed_[i]; - } - delete [] speed_; - delete dominance_; - delete crowdingDistanceComparator_; - delete distance_; - delete [] deltaMax_; - delete [] deltaMin_; - delete particles_; - for (int i = 0; i < swarmSize_; i++) { - delete best_[i]; - } - delete [] best_; - delete leaders_; +void SMPSO::deleteParams() +{ + + for (int i = 0; i < swarmSize_; i++) + { + delete [] speed_[i]; + } + delete [] speed_; + delete dominance_; + delete crowdingDistanceComparator_; + delete distance_; + delete [] deltaMax_; + delete [] deltaMin_; + delete particles_; + for (int i = 0; i < swarmSize_; i++) + { + delete best_[i]; + } + delete [] best_; + delete leaders_; } // deleteParams // Adaptive inertia -double SMPSO::inertiaWeight(int iter, int miter, double wma, double wmin) { - return wma; // - (((wma-wmin)*(double)iter)/(double)miter); +double SMPSO::inertiaWeight(int iter, int miter, double wma, double wmin) +{ + return wma; // - (((wma-wmin)*(double)iter)/(double)miter); } // inertiaWeight // constriction coefficient (M. Clerc) -double SMPSO::constrictionCoefficient(double c1, double c2) { - double rho = c1 + c2; - //rho = 1.0 ; - if (rho <= 4) { - return 1.0; - } else { - return 2 / (2 - rho - sqrt(pow(rho, 2.0) - 4.0 * rho)); - } +double SMPSO::constrictionCoefficient(double c1, double c2) +{ + double rho = c1 + c2; + //rho = 1.0 ; + if (rho <= 4) + { + return 1.0; + } + else + { + return 2 / (2 - rho - sqrt(pow(rho, 2.0) - 4.0 * rho)); + } } // constrictionCoefficient // velocity bounds double SMPSO::velocityConstriction(double v, double * deltaMax, - double * deltaMin, int variableIndex, - int particleIndex) { + double * deltaMin, int variableIndex, + int particleIndex) +{ - double result; + double result; - double dmax = deltaMax[variableIndex]; - double dmin = deltaMin[variableIndex]; + double dmax = deltaMax[variableIndex]; + double dmin = deltaMin[variableIndex]; - result = v; + result = v; - if (v > dmax) { - result = dmax; - } + if (v > dmax) + { + result = dmax; + } - if (v < dmin) { - result = dmin; - } + if (v < dmin) + { + result = dmin; + } - return result; + return result; } // velocityConstriction /** * Update the speed of each particle */ -void SMPSO::computeSpeed(int iter, int miter) { - double r1, r2, W, C1, C2; - double wmax, wmin, deltaMax, deltaMin; - XReal * bestGlobal; - - for (int i = 0; i < swarmSize_; i++) { - XReal * particle = new XReal(particles_->get(i)) ; - XReal * bestParticle = new XReal(best_[i]) ; - - //Select a global best_ for calculate the speed of particle i, bestGlobal - Solution * one; - Solution * two; - int pos1 = PseudoRandom::randInt(0, leaders_->size() - 1); - int pos2 = PseudoRandom::randInt(0, leaders_->size() - 1); - one = leaders_->get(pos1); - two = leaders_->get(pos2); - - if (crowdingDistanceComparator_->compare(one, two) < 1) { - bestGlobal = new XReal(one); - } else { - bestGlobal = new XReal(two); - } - //Params for velocity equation - r1 = PseudoRandom::randDouble(r1Min_, r1Max_); - r2 = PseudoRandom::randDouble(r2Min_, r2Max_); - C1 = PseudoRandom::randDouble(C1Min_, C1Max_); - C2 = PseudoRandom::randDouble(C2Min_, C2Max_); - W = PseudoRandom::randDouble(WMin_, WMax_); - // - wmax = WMax_; - wmin = WMin_; - - for (int var = 0; var < particle->getNumberOfDecisionVariables(); var++) { - //Computing the velocity of this particle - speed_[i][var] = velocityConstriction(constrictionCoefficient(C1, C2) * - (inertiaWeight(iter, miter, wmax, wmin) * - speed_[i][var] + - C1 * r1 * (bestParticle->getValue(var) - - particle->getValue(var)) + - C2 * r2 * (bestGlobal->getValue(var) - - particle->getValue(var))), deltaMax_, //[var], - deltaMin_, //[var], - var, - i); - } // for - - delete bestGlobal; - delete particle; - delete bestParticle; +void SMPSO::computeSpeed(int iter, int miter) +{ + double r1, r2, W, C1, C2; + double wmax, wmin, deltaMax, deltaMin; + XReal * bestGlobal; + + for (int i = 0; i < swarmSize_; i++) + { + XReal * particle = new XReal(particles_->get(i)) ; + XReal * bestParticle = new XReal(best_[i]) ; + + //Select a global best_ for calculate the speed of particle i, bestGlobal + Solution * one; + Solution * two; + int pos1 = PseudoRandom::randInt(0, leaders_->size() - 1); + int pos2 = PseudoRandom::randInt(0, leaders_->size() - 1); + one = leaders_->get(pos1); + two = leaders_->get(pos2); + + if (crowdingDistanceComparator_->compare(one, two) < 1) + { + bestGlobal = new XReal(one); + } + else + { + bestGlobal = new XReal(two); + } + //Params for velocity equation + r1 = PseudoRandom::randDouble(r1Min_, r1Max_); + r2 = PseudoRandom::randDouble(r2Min_, r2Max_); + C1 = PseudoRandom::randDouble(C1Min_, C1Max_); + C2 = PseudoRandom::randDouble(C2Min_, C2Max_); + W = PseudoRandom::randDouble(WMin_, WMax_); + // + wmax = WMax_; + wmin = WMin_; + + for (int var = 0; var < particle->getNumberOfDecisionVariables(); var++) + { + //Computing the velocity of this particle + speed_[i][var] = velocityConstriction(constrictionCoefficient(C1, C2) * + (inertiaWeight(iter, miter, wmax, wmin) * + speed_[i][var] + + C1 * r1 * (bestParticle->getValue(var) - + particle->getValue(var)) + + C2 * r2 * (bestGlobal->getValue(var) - + particle->getValue(var))), deltaMax_, //[var], + deltaMin_, //[var], + var, + i); + } // for + + delete bestGlobal; + delete particle; + delete bestParticle; - }// for + }// for } // computeSpeed @@ -252,40 +273,47 @@ void SMPSO::computeSpeed(int iter, int miter) { /** * Update the position of each particle */ -void SMPSO::computeNewPositions() { - for (int i = 0; i < swarmSize_; i++) { - XReal * particle = new XReal(particles_->get(i)) ; - for (int var = 0; var < particle->getNumberOfDecisionVariables(); var++) { - particle->setValue(var, particle->getValue(var) + speed_[i][var]) ; - - if (particle->getValue(var) < problem_->getLowerLimit(var)) { - particle->setValue(var, problem_->getLowerLimit(var)); - speed_[i][var] = speed_[i][var] * ChVel1_; // - } - if (particle->getValue(var) > problem_->getUpperLimit(var)) { - particle->setValue(var, problem_->getUpperLimit(var)); - speed_[i][var] = speed_[i][var] * ChVel2_; // - } +void SMPSO::computeNewPositions() +{ + for (int i = 0; i < swarmSize_; i++) + { + XReal * particle = new XReal(particles_->get(i)) ; + for (int var = 0; var < particle->getNumberOfDecisionVariables(); var++) + { + particle->setValue(var, particle->getValue(var) + speed_[i][var]) ; + + if (particle->getValue(var) < problem_->getLowerLimit(var)) + { + particle->setValue(var, problem_->getLowerLimit(var)); + speed_[i][var] = speed_[i][var] * ChVel1_; // + } + if (particle->getValue(var) > problem_->getUpperLimit(var)) + { + particle->setValue(var, problem_->getUpperLimit(var)); + speed_[i][var] = speed_[i][var] * ChVel2_; // + } + }// for + delete particle; }// for - delete particle; - }// for } // computeNewPositions /** * Apply a mutation operator to some particles in the swarm */ -void SMPSO::mopsoMutation(int actualIteration, int totalIterations) { - for (int i = 0; i < particles_->size(); i++) { - if ( (i % 6) == 0) - polynomialMutation_->execute(particles_->get(i)); - //if (i % 3 == 0) { //particles_ mutated with a non-uniform mutation %3 - // nonUniformMutation_.execute(particles_.get(i)); - //} else if (i % 3 == 1) { //particles_ mutated with a uniform mutation operator - // uniformMutation_.execute(particles_.get(i)); - //} else //particles_ without mutation - //; - } +void SMPSO::mopsoMutation(int actualIteration, int totalIterations) +{ + for (int i = 0; i < particles_->size(); i++) + { + if ( (i % 6) == 0) + polynomialMutation_->execute(particles_->get(i)); + //if (i % 3 == 0) { //particles_ mutated with a non-uniform mutation %3 + // nonUniformMutation_.execute(particles_.get(i)); + //} else if (i % 3 == 1) { //particles_ mutated with a uniform mutation operator + // uniformMutation_.execute(particles_.get(i)); + //} else //particles_ without mutation + //; + } } // mopsoMutation @@ -294,101 +322,115 @@ void SMPSO::mopsoMutation(int actualIteration, int totalIterations) { * @return a SolutionSet that is a set of non dominated solutions * as a result of the algorithm execution */ -SolutionSet * SMPSO::execute() { - - initParams(); - - success_ = false; - //->Step 1 (and 3) Create the initial population and evaluate - for (int i = 0; i < swarmSize_; i++) { - Solution * particle = new Solution(problem_); - problem_->evaluate(particle); - problem_->evaluateConstraints(particle); - particles_->add(particle); - } - - //-> Step2. Initialize the speed_ of each particle to 0 - for (int i = 0; i < swarmSize_; i++) { - speed_[i] = new double[problem_->getNumberOfVariables()]; - for (int j = 0; j < problem_->getNumberOfVariables(); j++) { - speed_[i][j] = 0.0; +SolutionSet * SMPSO::execute() +{ + + initParams(); + + success_ = false; + //->Step 1 (and 3) Create the initial population and evaluate + for (int i = 0; i < swarmSize_; i++) + { + Solution * particle = new Solution(problem_); + problem_->evaluate(particle); + problem_->evaluateConstraints(particle); + particles_->add(particle); } - } - - // Step4 and 5 - for (int i = 0; i < particles_->size(); i++) { - Solution * particle = new Solution(particles_->get(i)); - bool isAdded = leaders_->add(particle); - if (isAdded == false) { - delete particle; + + //-> Step2. Initialize the speed_ of each particle to 0 + for (int i = 0; i < swarmSize_; i++) + { + speed_[i] = new double[problem_->getNumberOfVariables()]; + for (int j = 0; j < problem_->getNumberOfVariables(); j++) + { + speed_[i][j] = 0.0; + } } - } - //-> Step 6. Initialize the memory of each particle - for (int i = 0; i < particles_->size(); i++) { - Solution * particle = new Solution(particles_->get(i)); - best_[i] = particle; - } + // Step4 and 5 + for (int i = 0; i < particles_->size(); i++) + { + Solution * particle = new Solution(particles_->get(i)); + bool isAdded = leaders_->add(particle); + if (isAdded == false) + { + delete particle; + } + } + + //-> Step 6. Initialize the memory of each particle + for (int i = 0; i < particles_->size(); i++) + { + Solution * particle = new Solution(particles_->get(i)); + best_[i] = particle; + } - //Crowding the leaders_ - distance_->crowdingDistanceAssignment(leaders_, problem_->getNumberOfObjectives()); + //Crowding the leaders_ + distance_->crowdingDistanceAssignment(leaders_, problem_->getNumberOfObjectives()); - //-> Step 7. Iterations .. - while (iteration_ < maxIterations_) { + //-> Step 7. Iterations .. + while (iteration_ < maxIterations_) + { // try { // //Compute the speed_ // computeSpeed(iteration_, maxIterations_); // } catch (IOException ex) { // Logger.getLogger(SMPSO.class.getName()).log(Level.SEVERE, null, ex); // } - computeSpeed(iteration_, maxIterations_); - - //Compute the new positions for the particles_ - computeNewPositions(); - - //Mutate the particles_ - mopsoMutation(iteration_, maxIterations_); - - //Evaluate the new particles_ in new positions - for (int i = 0; i < particles_->size(); i++) { - Solution * particle = particles_->get(i); - problem_->evaluate(particle); - problem_->evaluateConstraints(particle); + computeSpeed(iteration_, maxIterations_); + + //Compute the new positions for the particles_ + computeNewPositions(); + + //Mutate the particles_ + mopsoMutation(iteration_, maxIterations_); + + //Evaluate the new particles_ in new positions + for (int i = 0; i < particles_->size(); i++) + { + Solution * particle = particles_->get(i); + problem_->evaluate(particle); + problem_->evaluateConstraints(particle); + } + + //Update the archive + for (int i = 0; i < particles_->size(); i++) + { + Solution * particle = new Solution(particles_->get(i)); + bool isAdded = leaders_->add(particle); + if (isAdded == false) + { + delete particle; + } + } + + //Update the memory of this particle + for (int i = 0; i < particles_->size(); i++) + { + int flag = dominance_->compare(particles_->get(i), best_[i]); + if (flag != 1) // the new particle is best_ than the older remembered + { + Solution * particle = new Solution(particles_->get(i)); + delete best_[i]; + best_[i] = particle; + } + } + + //Assign crowding distance to the leaders_ + distance_->crowdingDistanceAssignment(leaders_, + problem_->getNumberOfObjectives()); + iteration_++; } - //Update the archive - for (int i = 0; i < particles_->size(); i++) { - Solution * particle = new Solution(particles_->get(i)); - bool isAdded = leaders_->add(particle); - if (isAdded == false) { - delete particle; - } + // Build the solution set result + SolutionSet * result = new SolutionSet(leaders_->size()); + for (int i=0; isize(); i++) + { + result->add(new Solution(leaders_->get(i))); } - //Update the memory of this particle - for (int i = 0; i < particles_->size(); i++) { - int flag = dominance_->compare(particles_->get(i), best_[i]); - if (flag != 1) { // the new particle is best_ than the older remembered - Solution * particle = new Solution(particles_->get(i)); - delete best_[i]; - best_[i] = particle; - } - } - - //Assign crowding distance to the leaders_ - distance_->crowdingDistanceAssignment(leaders_, - problem_->getNumberOfObjectives()); - iteration_++; - } - - // Build the solution set result - SolutionSet * result = new SolutionSet(leaders_->size()); - for (int i=0;isize();i++) { - result->add(new Solution(leaders_->get(i))); - } - - // Free memory - deleteParams(); + // Free memory + deleteParams(); - return result; + return result; } // execute diff --git a/src/metaheuristics/smpso/SMPSO.h b/src/metaheuristics/smpso/SMPSO.h index 3fa67ec..4ec17d4 100644 --- a/src/metaheuristics/smpso/SMPSO.h +++ b/src/metaheuristics/smpso/SMPSO.h @@ -42,101 +42,102 @@ * (MCDM 2009), pp: 66-73. March 2009 */ -class SMPSO : public Algorithm { +class SMPSO : public Algorithm +{ private: - /** - * Stores the number of particles_ used - */ - int swarmSize_; - /** - * Stores the maximum size for the archive - */ - int archiveSize_; - /** - * Stores the maximum number of iteration_ - */ - int maxIterations_; - /** - * Stores the current number of iteration_ - */ - int iteration_; - /** - * Stores the particles - */ - SolutionSet * particles_; - /** - * Stores the best_ solutions founds so far for each particles - */ - Solution ** best_; - /** - * Stores the leaders_ - */ - CrowdingArchive * leaders_; - /** - * Stores the speed_ of each particle - */ - double ** speed_; - /** - * Stores a comparator for checking dominance - */ - Comparator * dominance_; - /** - * Stores a comparator for crowding checking - */ - Comparator * crowdingDistanceComparator_; - /** - * Stores a Distance object - */ - Distance * distance_; - /** - * Stores a operator for non uniform mutations - */ - Operator * polynomialMutation_; + /** + * Stores the number of particles_ used + */ + int swarmSize_; + /** + * Stores the maximum size for the archive + */ + int archiveSize_; + /** + * Stores the maximum number of iteration_ + */ + int maxIterations_; + /** + * Stores the current number of iteration_ + */ + int iteration_; + /** + * Stores the particles + */ + SolutionSet * particles_; + /** + * Stores the best_ solutions founds so far for each particles + */ + Solution ** best_; + /** + * Stores the leaders_ + */ + CrowdingArchive * leaders_; + /** + * Stores the speed_ of each particle + */ + double ** speed_; + /** + * Stores a comparator for checking dominance + */ + Comparator * dominance_; + /** + * Stores a comparator for crowding checking + */ + Comparator * crowdingDistanceComparator_; + /** + * Stores a Distance object + */ + Distance * distance_; + /** + * Stores a operator for non uniform mutations + */ + Operator * polynomialMutation_; - //QualityIndicator * indicators_; // QualityIndicator object + //QualityIndicator * indicators_; // QualityIndicator object - double r1Max_; - double r1Min_; - double r2Max_; - double r2Min_; - double C1Max_; - double C1Min_; - double C2Max_; - double C2Min_; - double WMax_; - double WMin_; - double ChVel1_; - double ChVel2_; + double r1Max_; + double r1Min_; + double r2Max_; + double r2Min_; + double C1Max_; + double C1Min_; + double C2Max_; + double C2Min_; + double WMax_; + double WMin_; + double ChVel1_; + double ChVel2_; - double trueHypervolume_; - //Hypervolume * hy_; - SolutionSet * trueFront_; - double * deltaMax_; - double * deltaMin_; - bool success_; + double trueHypervolume_; + //Hypervolume * hy_; + SolutionSet * trueFront_; + double * deltaMax_; + double * deltaMin_; + bool success_; - double inertiaWeight(int iter, int miter, double wma, - double wmin); - double constrictionCoefficient(double c1, double c2); - double velocityConstriction(double v, double * deltaMax, - double * deltaMin, - int variableIndex, - int particleIndex); - void computeSpeed(int iter, int miter); - void computeNewPositions(); - void mopsoMutation(int actualIteration, int totalIterations); - void initParams(); - void setAlgParams(); - void deleteParams(); + double inertiaWeight(int iter, int miter, double wma, + double wmin); + double constrictionCoefficient(double c1, double c2); + double velocityConstriction(double v, double * deltaMax, + double * deltaMin, + int variableIndex, + int particleIndex); + void computeSpeed(int iter, int miter); + void computeNewPositions(); + void mopsoMutation(int actualIteration, int totalIterations); + void initParams(); + void setAlgParams(); + void deleteParams(); public: - SMPSO(Problem * problem); - //TODO: SMPSO(Problem * problem, vector variables, string trueParetoFront); - //TODO: SMPSO(Problem * problem, string trueParetoFront); - SolutionSet * execute(); - //TODO: SolutionSet * getLeader(); + SMPSO(Problem * problem); + //TODO: SMPSO(Problem * problem, vector variables, string trueParetoFront); + //TODO: SMPSO(Problem * problem, string trueParetoFront); + SolutionSet * execute(); + //TODO: SolutionSet * getLeader(); }; diff --git a/src/metaheuristics/smpso/SMPSOhv.cpp b/src/metaheuristics/smpso/SMPSOhv.cpp index dcc9765..b9bd39b 100644 --- a/src/metaheuristics/smpso/SMPSOhv.cpp +++ b/src/metaheuristics/smpso/SMPSOhv.cpp @@ -31,78 +31,84 @@ * Constructor * @param problem Problem to solve */ -SMPSOhv::SMPSOhv(Problem *problem) : Algorithm(problem) { - r1Max = 1.0; - r1Min = 0.0; - r2Max = 1.0; - r2Min = 0.0; - C1Max = 2.5; - C1Min = 1.5; - C2Max = 2.5; - C2Min = 1.5; - WMax = 0.1; - WMin = 0.1; - ChVel1 = -1; - ChVel2 = -1; +SMPSOhv::SMPSOhv(Problem *problem) : Algorithm(problem) +{ + r1Max = 1.0; + r1Min = 0.0; + r2Max = 1.0; + r2Min = 0.0; + C1Max = 2.5; + C1Min = 1.5; + C2Max = 2.5; + C2Min = 1.5; + WMax = 0.1; + WMin = 0.1; + ChVel1 = -1; + ChVel2 = -1; } // SMPSOhv /** * Initialize all parameter of the algorithm */ -void SMPSOhv::initParams() { - swarmSize = *(int *) getInputParameter("swarmSize"); - archiveSize = *(int *) getInputParameter("archiveSize"); - maxIterations = *(int *) getInputParameter("maxIterations"); - - //indicators = *(QualityIndicator *) getInputParameter("indicators"); - - polynomialMutation = operators_["mutation"] ; - - iteration = 0; - - particles = new SolutionSet(swarmSize); - best = new Solution*[swarmSize]; - leaders = new FastHypervolumeArchive(archiveSize,problem_->getNumberOfObjectives()); - - // Create the dominator for equadless and dominance - dominance = new DominanceComparator(); - crowdingDistanceComparator = new CrowdingDistanceComparator(); - distance = new Distance(); - - // Create the speed_ vector - speed = new double*[swarmSize]; - - deltaMax = new double[problem_->getNumberOfVariables()]; - deltaMin = new double[problem_->getNumberOfVariables()]; - for (int i = 0; i < problem_->getNumberOfVariables(); i++) { - deltaMax[i] = (problem_->getUpperLimit(i) - - problem_->getLowerLimit(i)) / 2.0; - deltaMin[i] = -deltaMax[i]; - } // for +void SMPSOhv::initParams() +{ + swarmSize = *(int *) getInputParameter("swarmSize"); + archiveSize = *(int *) getInputParameter("archiveSize"); + maxIterations = *(int *) getInputParameter("maxIterations"); + + //indicators = *(QualityIndicator *) getInputParameter("indicators"); + + polynomialMutation = operators_["mutation"] ; + + iteration = 0; + + particles = new SolutionSet(swarmSize); + best = new Solution*[swarmSize]; + leaders = new FastHypervolumeArchive(archiveSize,problem_->getNumberOfObjectives()); + + // Create the dominator for equadless and dominance + dominance = new DominanceComparator(); + crowdingDistanceComparator = new CrowdingDistanceComparator(); + distance = new Distance(); + + // Create the speed_ vector + speed = new double*[swarmSize]; + + deltaMax = new double[problem_->getNumberOfVariables()]; + deltaMin = new double[problem_->getNumberOfVariables()]; + for (int i = 0; i < problem_->getNumberOfVariables(); i++) + { + deltaMax[i] = (problem_->getUpperLimit(i) - + problem_->getLowerLimit(i)) / 2.0; + deltaMin[i] = -deltaMax[i]; + } // for } // initParams /** * Free all the memory reserved by the algorithm */ -void SMPSOhv::deleteParams() { - - for (int i = 0; i < swarmSize; i++) { - delete [] speed[i]; - } - delete [] speed; - delete dominance; - delete crowdingDistanceComparator; - delete distance; - delete particles; - for (int i = 0; i < swarmSize; i++) { - delete best[i]; - } - delete [] best; - delete [] deltaMax; - delete [] deltaMin; - delete leaders; +void SMPSOhv::deleteParams() +{ + + for (int i = 0; i < swarmSize; i++) + { + delete [] speed[i]; + } + delete [] speed; + delete dominance; + delete crowdingDistanceComparator; + delete distance; + delete particles; + for (int i = 0; i < swarmSize; i++) + { + delete best[i]; + } + delete [] best; + delete [] deltaMax; + delete [] deltaMin; + delete leaders; } // deleteParams @@ -110,128 +116,147 @@ void SMPSOhv::deleteParams() { /** * Adaptive inertia */ -double SMPSOhv::inertiaWeight(int iter, int miter, double wma, double wmin) { - return wma; // - (((wma-wmin)*(double)iter)/(double)miter); +double SMPSOhv::inertiaWeight(int iter, int miter, double wma, double wmin) +{ + return wma; // - (((wma-wmin)*(double)iter)/(double)miter); } // inertiaWeight /** * constriction coefficient (M. Clerc) */ -double SMPSOhv::constrictionCoefficient(double c1, double c2) { - double rho = c1 + c2; - //rho = 1.0 ; - if (rho <= 4) { - return 1.0; - } else { - return 2 / (2 - rho - sqrt(pow(rho, 2.0) - 4.0 * rho)); - } +double SMPSOhv::constrictionCoefficient(double c1, double c2) +{ + double rho = c1 + c2; + //rho = 1.0 ; + if (rho <= 4) + { + return 1.0; + } + else + { + return 2 / (2 - rho - sqrt(pow(rho, 2.0) - 4.0 * rho)); + } } // constrictionCoefficient /** * velocity bounds */ double SMPSOhv::velocityConstriction(double v, double *deltaMax, - double *deltaMin, int variableIndex, - int particleIndex) { + double *deltaMin, int variableIndex, + int particleIndex) +{ - double result; + double result; - double dmax = deltaMax[variableIndex]; - double dmin = deltaMin[variableIndex]; + double dmax = deltaMax[variableIndex]; + double dmin = deltaMin[variableIndex]; - result = v; + result = v; - if (v > dmax) { - result = dmax; - } + if (v > dmax) + { + result = dmax; + } - if (v < dmin) { - result = dmin; - } + if (v < dmin) + { + result = dmin; + } - return result; + return result; } // velocityConstriction /** * Update the speed of each particle */ -void SMPSOhv::computeSpeed(int iter, int miter) { - double r1, r2, W, C1, C2; - double wmax, wmin; - XReal *bestGlobal; - - for (int i = 0; i < swarmSize; i++) { - XReal *particle = new XReal(particles->get(i)); - XReal *bestParticle = new XReal(best[i]); - - //Select a global best for calculate the speed of particle i, bestGlobal - Solution *one, *two; - int pos1 = PseudoRandom::randInt(0,leaders->size()-1); - - //int pos1 = PseudoRandom::randInt(0,leaders->size()-1); - int pos2 = PseudoRandom::randInt(0,leaders->size()-1); - one = leaders->get(pos1); - two = leaders->get(pos2); - - if (crowdingDistanceComparator->compare(one,two) < 1) { - bestGlobal = new XReal(one); - } else { - bestGlobal = new XReal(two); - } - - //Params for velocity equation - r1 = PseudoRandom::randDouble(r1Min, r1Max); - r2 = PseudoRandom::randDouble(r2Min, r2Max); - C1 = PseudoRandom::randDouble(C1Min, C1Max); - C2 = PseudoRandom::randDouble(C2Min, C2Max); - W = PseudoRandom::randDouble(WMin, WMax); - - wmax = WMax; - wmin = WMin; - - for (int var = 0; var < particle->getNumberOfDecisionVariables(); var++) { - //Computing the velocity of this particle - speed[i][var] = velocityConstriction(constrictionCoefficient(C1, C2) * - (inertiaWeight(iter, miter, wmax, wmin) * - speed[i][var] + - C1 * r1 * (bestParticle->getValue(var) - - particle->getValue(var)) + - C2 * r2 * (bestGlobal->getValue(var) - - particle->getValue(var))), deltaMax, - deltaMin, - var, - i); +void SMPSOhv::computeSpeed(int iter, int miter) +{ + double r1, r2, W, C1, C2; + double wmax, wmin; + XReal *bestGlobal; + + for (int i = 0; i < swarmSize; i++) + { + XReal *particle = new XReal(particles->get(i)); + XReal *bestParticle = new XReal(best[i]); + + //Select a global best for calculate the speed of particle i, bestGlobal + Solution *one, *two; + int pos1 = PseudoRandom::randInt(0,leaders->size()-1); + + //int pos1 = PseudoRandom::randInt(0,leaders->size()-1); + int pos2 = PseudoRandom::randInt(0,leaders->size()-1); + one = leaders->get(pos1); + two = leaders->get(pos2); + + if (crowdingDistanceComparator->compare(one,two) < 1) + { + bestGlobal = new XReal(one); + } + else + { + bestGlobal = new XReal(two); + } + + //Params for velocity equation + r1 = PseudoRandom::randDouble(r1Min, r1Max); + r2 = PseudoRandom::randDouble(r2Min, r2Max); + C1 = PseudoRandom::randDouble(C1Min, C1Max); + C2 = PseudoRandom::randDouble(C2Min, C2Max); + W = PseudoRandom::randDouble(WMin, WMax); + + wmax = WMax; + wmin = WMin; + + for (int var = 0; var < particle->getNumberOfDecisionVariables(); var++) + { + //Computing the velocity of this particle + speed[i][var] = velocityConstriction(constrictionCoefficient(C1, C2) * + (inertiaWeight(iter, miter, wmax, wmin) * + speed[i][var] + + C1 * r1 * (bestParticle->getValue(var) - + particle->getValue(var)) + + C2 * r2 * (bestGlobal->getValue(var) - + particle->getValue(var))), deltaMax, + deltaMin, + var, + i); + } + delete bestGlobal; + delete particle; + delete bestParticle; } - delete bestGlobal; - delete particle; - delete bestParticle; - } } // computeSpeed /** * Update the position of each particle */ -void SMPSOhv::computeNewPositions() { - - for (int i = 0; i < swarmSize; i++) { - XReal * particle = new XReal(particles->get(i)); - for (int var = 0; var < particle->getNumberOfDecisionVariables(); var++) { - particle->setValue(var, particle->getValue(var) + speed[i][var]); - - if (particle->getValue(var) < problem_->getLowerLimit(var)) { - particle->setValue(var, problem_->getLowerLimit(var)); - speed[i][var] = speed[i][var] * ChVel1; - } - if (particle->getValue(var) > problem_->getUpperLimit(var)){ - particle->setValue(var, problem_->getUpperLimit(var)); - speed[i][var] = speed[i][var] * ChVel2; - } +void SMPSOhv::computeNewPositions() +{ + + for (int i = 0; i < swarmSize; i++) + { + XReal * particle = new XReal(particles->get(i)); + for (int var = 0; var < particle->getNumberOfDecisionVariables(); var++) + { + particle->setValue(var, particle->getValue(var) + speed[i][var]); + + if (particle->getValue(var) < problem_->getLowerLimit(var)) + { + particle->setValue(var, problem_->getLowerLimit(var)); + speed[i][var] = speed[i][var] * ChVel1; + } + if (particle->getValue(var) > problem_->getUpperLimit(var)) + { + particle->setValue(var, problem_->getUpperLimit(var)); + speed[i][var] = speed[i][var] * ChVel2; + } + } + delete particle; } - delete particle; - } } // computeNewPositions @@ -239,12 +264,15 @@ void SMPSOhv::computeNewPositions() { /** * Apply a mutation operator to some particles in the swarm */ -void SMPSOhv::mopsoMutation(int actualIteration, int totalIterations) { - for (int i = 0; i < particles->size(); i++) { - if ( (i % 6) == 0) { - polynomialMutation->execute(particles->get(i)); +void SMPSOhv::mopsoMutation(int actualIteration, int totalIterations) +{ + for (int i = 0; i < particles->size(); i++) + { + if ( (i % 6) == 0) + { + polynomialMutation->execute(particles->get(i)); + } } - } } // mopsoMutation @@ -253,92 +281,106 @@ void SMPSOhv::mopsoMutation(int actualIteration, int totalIterations) { * @return a SolutionSet that is a set of non dominated solutions * as a result of the algorithm execution */ -SolutionSet *SMPSOhv::execute() { - - initParams(); - - success = false; - //->Step 1 (and 3) Create the initial population and evaluate - for (int i = 0; i < swarmSize; i++){ - Solution *particle = new Solution(problem_); - problem_->evaluate(particle); - problem_->evaluateConstraints(particle); - particles->add(particle); - } - - //-> Step2. Initialize the speed of each particle to 0 - for (int i = 0; i < swarmSize; i++) { - speed[i] = new double[problem_->getNumberOfVariables()]; - for (int j = 0; j < problem_->getNumberOfVariables(); j++) { - speed[i][j] = 0.0; +SolutionSet *SMPSOhv::execute() +{ + + initParams(); + + success = false; + //->Step 1 (and 3) Create the initial population and evaluate + for (int i = 0; i < swarmSize; i++) + { + Solution *particle = new Solution(problem_); + problem_->evaluate(particle); + problem_->evaluateConstraints(particle); + particles->add(particle); } - } - // Step4 and 5 - for (int i = 0; i < particles->size(); i++){ - Solution *particle = new Solution(particles->get(i)); - if (leaders->add(particle) == false){ - delete particle; - } - } - - //-> Step 6. Initialize the memory of each particle - for (int i = 0; i < particles->size(); i++){ - Solution *particle = new Solution(particles->get(i)); - best[i] = particle; - } - - //Crowding the leaders_ - //distance->crowdingDistanceAssignment(leaders, problem_->getNumberOfObjectives()); - leaders->computeHVContribution(); - - //-> Step 7. Iterations .. - while (iteration < maxIterations) { - //Compute the speed_ - computeSpeed(iteration, maxIterations); - - //Compute the new positions for the particles_ - computeNewPositions(); - - //Mutate the particles_ - mopsoMutation(iteration,maxIterations); - - //Evaluate the new particles in new positions - for (int i = 0; i < particles->size(); i++){ - Solution *particle = particles->get(i); - problem_->evaluate(particle); - problem_->evaluateConstraints(particle); + //-> Step2. Initialize the speed of each particle to 0 + for (int i = 0; i < swarmSize; i++) + { + speed[i] = new double[problem_->getNumberOfVariables()]; + for (int j = 0; j < problem_->getNumberOfVariables(); j++) + { + speed[i][j] = 0.0; + } } - //Update the archive - for (int i = 0; i < particles->size(); i++) { - Solution *particle = new Solution(particles->get(i)); - if (leaders->add(particle) == false) { - delete particle; - } + // Step4 and 5 + for (int i = 0; i < particles->size(); i++) + { + Solution *particle = new Solution(particles->get(i)); + if (leaders->add(particle) == false) + { + delete particle; + } } - //Update the memory of this particle - for (int i = 0; i < particles->size(); i++) { - int flag = dominance->compare(particles->get(i), best[i]); - if (flag != 1) { // the new particle is best_ than the older remembered + //-> Step 6. Initialize the memory of each particle + for (int i = 0; i < particles->size(); i++) + { Solution *particle = new Solution(particles->get(i)); - delete best[i]; best[i] = particle; - } } - iteration++; - } + //Crowding the leaders_ + //distance->crowdingDistanceAssignment(leaders, problem_->getNumberOfObjectives()); + leaders->computeHVContribution(); + + //-> Step 7. Iterations .. + while (iteration < maxIterations) + { + //Compute the speed_ + computeSpeed(iteration, maxIterations); + + //Compute the new positions for the particles_ + computeNewPositions(); + + //Mutate the particles_ + mopsoMutation(iteration,maxIterations); + + //Evaluate the new particles in new positions + for (int i = 0; i < particles->size(); i++) + { + Solution *particle = particles->get(i); + problem_->evaluate(particle); + problem_->evaluateConstraints(particle); + } + + //Update the archive + for (int i = 0; i < particles->size(); i++) + { + Solution *particle = new Solution(particles->get(i)); + if (leaders->add(particle) == false) + { + delete particle; + } + } + + //Update the memory of this particle + for (int i = 0; i < particles->size(); i++) + { + int flag = dominance->compare(particles->get(i), best[i]); + if (flag != 1) // the new particle is best_ than the older remembered + { + Solution *particle = new Solution(particles->get(i)); + delete best[i]; + best[i] = particle; + } + } + + iteration++; + } - // Build the solution set result - SolutionSet * result = new SolutionSet(leaders->size()); - for (int i=0;isize();i++) { - result->add(new Solution(leaders->get(i))); - } + // Build the solution set result + SolutionSet * result = new SolutionSet(leaders->size()); + for (int i=0; isize(); i++) + { + result->add(new Solution(leaders->get(i))); + } - // Free memory - deleteParams(); + // Free memory + deleteParams(); - return result; + return result; } // execute diff --git a/src/metaheuristics/smpso/SMPSOhv.h b/src/metaheuristics/smpso/SMPSOhv.h index d863350..1233382 100644 --- a/src/metaheuristics/smpso/SMPSOhv.h +++ b/src/metaheuristics/smpso/SMPSOhv.h @@ -35,149 +35,150 @@ * A.J Nebro, J.J. Durillo, C.A. Coello Coello. Analysis of Leader Selection Strategies in a * Multi-Objective Particle Swarm Optimizer. 2013 IEEE Congress on Evolutionary Computation. June 2013 */ -class SMPSOhv : public Algorithm { +class SMPSOhv : public Algorithm +{ private: - /** - * Stores the number of particles used - */ - int swarmSize; - - /** - * Stores the maximum size for the archive - */ - int archiveSize; - - /** - * Stores the maximum number of iteration_ - */ - int maxIterations; - - /** - * Stores the current number of iteration_ - */ - int iteration; - - /** - * Stores the particles - */ - SolutionSet *particles; - - /** - * Stores the best solutions founds so far for each particles - */ - Solution **best; - - /** - * Stores the leaders - */ - FastHypervolumeArchive *leaders; - - /** - * Stores the speed of each particle - */ - double **speed; - - /** - * Stores a comparator for checking dominance - */ - Comparator *dominance; - - /** - * Stores a comparator for crowding checking - */ - Comparator *crowdingDistanceComparator; - - /** - * Stores a Distance object - */ - Distance *distance; - - /** - * Stores a operator for polynomial mutations - */ - Operator *polynomialMutation; - - //QualityIndicator *indicators; // QualityIndicator object - - double r1Max; - double r1Min; - double r2Max; - double r2Min; - double C1Max; - double C1Min; - double C2Max; - double C2Min; - double WMax; - double WMin; - double ChVel1; - double ChVel2; - - double trueHypervolume; - Hypervolume *hy; - SolutionSet *trueFront; - double *deltaMax; - double *deltaMin; - bool success; - - /** - * Initialize all parameter of the algorithm - */ - void initParams(); - - /** - * Free all the memory reserved by the algorithm - */ - void deleteParams(); - - /** - * Adaptive inertia - */ - double inertiaWeight(int iter, int miter, double wma, double wmin); - - /** - * constriction coefficient (M. Clerc) - */ - double constrictionCoefficient(double c1, double c2); - - /** - * velocity bounds - */ - double velocityConstriction(double v, double *deltaMax, - double *deltaMin, int variableIndex, - int particleIndex); - - /** - * Update the speed of each particle - */ - void computeSpeed(int iter, int miter); - - /** - * Update the position of each particle - */ - void computeNewPositions(); - - /** - * Apply a mutation operator to some particles in the swarm - */ - void mopsoMutation(int actualIteration, int totalIterations); + /** + * Stores the number of particles used + */ + int swarmSize; + + /** + * Stores the maximum size for the archive + */ + int archiveSize; + + /** + * Stores the maximum number of iteration_ + */ + int maxIterations; + + /** + * Stores the current number of iteration_ + */ + int iteration; + + /** + * Stores the particles + */ + SolutionSet *particles; + + /** + * Stores the best solutions founds so far for each particles + */ + Solution **best; + + /** + * Stores the leaders + */ + FastHypervolumeArchive *leaders; + + /** + * Stores the speed of each particle + */ + double **speed; + + /** + * Stores a comparator for checking dominance + */ + Comparator *dominance; + + /** + * Stores a comparator for crowding checking + */ + Comparator *crowdingDistanceComparator; + + /** + * Stores a Distance object + */ + Distance *distance; + + /** + * Stores a operator for polynomial mutations + */ + Operator *polynomialMutation; + + //QualityIndicator *indicators; // QualityIndicator object + + double r1Max; + double r1Min; + double r2Max; + double r2Min; + double C1Max; + double C1Min; + double C2Max; + double C2Min; + double WMax; + double WMin; + double ChVel1; + double ChVel2; + + double trueHypervolume; + Hypervolume *hy; + SolutionSet *trueFront; + double *deltaMax; + double *deltaMin; + bool success; + + /** + * Initialize all parameter of the algorithm + */ + void initParams(); + + /** + * Free all the memory reserved by the algorithm + */ + void deleteParams(); + + /** + * Adaptive inertia + */ + double inertiaWeight(int iter, int miter, double wma, double wmin); + + /** + * constriction coefficient (M. Clerc) + */ + double constrictionCoefficient(double c1, double c2); + + /** + * velocity bounds + */ + double velocityConstriction(double v, double *deltaMax, + double *deltaMin, int variableIndex, + int particleIndex); + + /** + * Update the speed of each particle + */ + void computeSpeed(int iter, int miter); + + /** + * Update the position of each particle + */ + void computeNewPositions(); + + /** + * Apply a mutation operator to some particles in the swarm + */ + void mopsoMutation(int actualIteration, int totalIterations); public: - /** - * Constructor. - * @param problem Problem to solve - */ - SMPSOhv(Problem *problem); - - /** - * Runs of the SMPSO algorithm. - * @return a SolutionSet that is a set of non dominated solutions - * as a result of the algorithm execution - * @throws JMException - */ - SolutionSet *execute(); + /** + * Constructor. + * @param problem Problem to solve + */ + SMPSOhv(Problem *problem); + + /** + * Runs of the SMPSO algorithm. + * @return a SolutionSet that is a set of non dominated solutions + * as a result of the algorithm execution + * @throws JMException + */ + SolutionSet *execute(); }; diff --git a/src/metaheuristics/smsemoa/FastSMSEMOA.cpp b/src/metaheuristics/smsemoa/FastSMSEMOA.cpp index fd302db..5c37a38 100644 --- a/src/metaheuristics/smsemoa/FastSMSEMOA.cpp +++ b/src/metaheuristics/smsemoa/FastSMSEMOA.cpp @@ -31,17 +31,19 @@ * Constructor * @param problem Problem to solve */ -FastSMSEMOA::FastSMSEMOA(Problem *problem) : Algorithm(problem) { - utils_ = new MetricsUtil(); - hv_ = new Hypervolume(); +FastSMSEMOA::FastSMSEMOA(Problem *problem) : Algorithm(problem) +{ + utils_ = new MetricsUtil(); + hv_ = new Hypervolume(); } // FastSMSEMOA /** * Destructor */ -FastSMSEMOA::~FastSMSEMOA() { - delete utils_; - delete hv_; +FastSMSEMOA::~FastSMSEMOA() +{ + delete utils_; + delete hv_; } // ~FastSMSEMOA /** @@ -49,164 +51,173 @@ FastSMSEMOA::~FastSMSEMOA() { * @return a SolutionSet that is a set of non dominated solutions * as a result of the algorithm execution */ -SolutionSet * FastSMSEMOA::execute() { - int populationSize; - int maxEvaluations; - int evaluations; - double offset; - - QualityIndicator * indicators; // QualityIndicator object - int requiredEvaluations; // Use in the example of use of the indicators object (see below) - - FastHypervolume * fastHypervolume; - - SolutionSet * population; - SolutionSet * offspringPopulation; - SolutionSet * unionSolution; - - Operator * mutationOperator; - Operator * crossoverOperator; - Operator * selectionOperator; - - //Read the parameters - populationSize = *(int *) getInputParameter("populationSize"); - maxEvaluations = *(int *) getInputParameter("maxEvaluations"); - indicators = (QualityIndicator *) getInputParameter("indicators"); - offset = *(double *) getInputParameter("offset"); - - //Initialize the variables - population = new SolutionSet(populationSize); - evaluations = 0; - - requiredEvaluations = 0; - - fastHypervolume = new FastHypervolume(offset); - - //Read the operator - mutationOperator = operators_["mutation"]; - crossoverOperator = operators_["crossover"]; - selectionOperator = operators_["selection"]; - - // Create the initial solutionSet - Solution * newSolution; - for (int i = 0; i < populationSize; i++) { - newSolution = new Solution(problem_); - problem_->evaluate(newSolution); - problem_->evaluateConstraints(newSolution); - evaluations++; - population->add(newSolution); - } //for - - // Generations ... - while (evaluations < maxEvaluations) { - - // select parents - offspringPopulation = new SolutionSet(1); - /* - LinkedList selectedParents = new LinkedList(); - Solution[] parents = new Solution[0]; - while (selectedParents->size() < 2) { - void * selected = selectionOperator->execute(population); - try { - Solution * parent = * (Solution*) selected; - selectedParents.add(parent); - } catch (ClassCastException e) { - Configuration.logger_.log(Level.WARNING, "Class cast exception", e); - parents = (Solution[]) selected; - Collections.addAll(selectedParents, parents); - } +SolutionSet * FastSMSEMOA::execute() +{ + int populationSize; + int maxEvaluations; + int evaluations; + double offset; + + QualityIndicator * indicators; // QualityIndicator object + int requiredEvaluations; // Use in the example of use of the indicators object (see below) + + FastHypervolume * fastHypervolume; + + SolutionSet * population; + SolutionSet * offspringPopulation; + SolutionSet * unionSolution; + + Operator * mutationOperator; + Operator * crossoverOperator; + Operator * selectionOperator; + + //Read the parameters + populationSize = *(int *) getInputParameter("populationSize"); + maxEvaluations = *(int *) getInputParameter("maxEvaluations"); + indicators = (QualityIndicator *) getInputParameter("indicators"); + offset = *(double *) getInputParameter("offset"); + + //Initialize the variables + population = new SolutionSet(populationSize); + evaluations = 0; + + requiredEvaluations = 0; + + fastHypervolume = new FastHypervolume(offset); + + //Read the operator + mutationOperator = operators_["mutation"]; + crossoverOperator = operators_["crossover"]; + selectionOperator = operators_["selection"]; + + // Create the initial solutionSet + Solution * newSolution; + for (int i = 0; i < populationSize; i++) + { + newSolution = new Solution(problem_); + problem_->evaluate(newSolution); + problem_->evaluateConstraints(newSolution); + evaluations++; + population->add(newSolution); + } //for + + // Generations ... + while (evaluations < maxEvaluations) + { + + // select parents + offspringPopulation = new SolutionSet(1); + /* + LinkedList selectedParents = new LinkedList(); + Solution[] parents = new Solution[0]; + while (selectedParents->size() < 2) { + void * selected = selectionOperator->execute(population); + try { + Solution * parent = * (Solution*) selected; + selectedParents.add(parent); + } catch (ClassCastException e) { + Configuration.logger_.log(Level.WARNING, "Class cast exception", e); + parents = (Solution[]) selected; + Collections.addAll(selectedParents, parents); + } + } + parents = selectedParents.toArray(parents); + */ + Solution ** parents = (Solution **) (selectionOperator->execute(population)); + + // crossover + Solution ** offSpring = (Solution **) (crossoverOperator->execute(parents)); + + // mutation + mutationOperator->execute(offSpring[0]); + + // evaluation + problem_->evaluate(offSpring[0]); + problem_->evaluateConstraints(offSpring[0]); + + // insert child into the offspring population + offspringPopulation->add(offSpring[0]); + + evaluations++; + + delete offSpring[1]; + delete[] offSpring; + delete[] parents; + + // Create the solutionSet union of solutionSet and offSpring + unionSolution = population->join(offspringPopulation); + delete offspringPopulation; + + // Ranking the union (non-dominated sorting) + Ranking * ranking = new Ranking(unionSolution); + + // ensure crowding distance values are up to date + // (may be important for parent selection) + for (int j = 0; j < population->size(); j++) + { + population->get(j)->setCrowdingDistance(0.0); + } + + SolutionSet * lastFront = ranking->getSubfront(ranking->getNumberOfSubfronts() - 1); + + //FastHypervolume fastHypervolume = new FastHypervolume() ; + fastHypervolume->computeHVContributions(lastFront); + CrowdingDistanceComparator * cd = new CrowdingDistanceComparator(); + lastFront->sort(cd); + delete cd; + + // all but the worst are carried over to the survivor population + SolutionSet * front = NULL; + for (int i=0; isize(); i++) + { + delete population->get(i); + } + population->clear(); + for (int i = 0; i < ranking->getNumberOfSubfronts() - 1; i++) + { + front = ranking->getSubfront(i); + for (int j = 0; j < front->size(); j++) + { + population->add(new Solution(front->get(j))); + } + } + for (int i = 0; i < lastFront->size() - 1; i++) + { + population->add(new Solution(lastFront->get(i))); + } + + delete unionSolution; + delete ranking; + + // This piece of code shows how to use the indicator object into the code + // of SMS-EMOA. In particular, it finds the number of evaluations required + // by the algorithm to obtain a Pareto front with a hypervolume higher + // than the hypervolume of the true Pareto front. + /* + if (indicators != null && requiredEvaluations == 0) { + double HV = indicators.getHypervolume(population); + if (HV >= (0.98 * indicators.getTrueParetoFrontHypervolume())) { + requiredEvaluations = evaluations; + } + } + */ } - parents = selectedParents.toArray(parents); - */ - Solution ** parents = (Solution **) (selectionOperator->execute(population)); - // crossover - Solution ** offSpring = (Solution **) (crossoverOperator->execute(parents)); + // Return as output parameter the required evaluations + //setOutputParameter("evaluations", requiredEvaluations); - // mutation - mutationOperator->execute(offSpring[0]); + // Return the first non-dominated front + Ranking * ranking = new Ranking(population); - // evaluation - problem_->evaluate(offSpring[0]); - problem_->evaluateConstraints(offSpring[0]); - - // insert child into the offspring population - offspringPopulation->add(offSpring[0]); - - evaluations++; - - delete offSpring[1]; - delete[] offSpring; - delete[] parents; - - // Create the solutionSet union of solutionSet and offSpring - unionSolution = population->join(offspringPopulation); - delete offspringPopulation; - - // Ranking the union (non-dominated sorting) - Ranking * ranking = new Ranking(unionSolution); - - // ensure crowding distance values are up to date - // (may be important for parent selection) - for (int j = 0; j < population->size(); j++) { - population->get(j)->setCrowdingDistance(0.0); - } - - SolutionSet * lastFront = ranking->getSubfront(ranking->getNumberOfSubfronts() - 1); - - //FastHypervolume fastHypervolume = new FastHypervolume() ; - fastHypervolume->computeHVContributions(lastFront); - CrowdingDistanceComparator * cd = new CrowdingDistanceComparator(); - lastFront->sort(cd); - delete cd; - - // all but the worst are carried over to the survivor population - SolutionSet * front = NULL; - for (int i=0;isize();i++) { - delete population->get(i); - } - population->clear(); - for (int i = 0; i < ranking->getNumberOfSubfronts() - 1; i++) { - front = ranking->getSubfront(i); - for (int j = 0; j < front->size(); j++) { - population->add(new Solution(front->get(j))); - } - } - for (int i = 0; i < lastFront->size() - 1; i++) { - population->add(new Solution(lastFront->get(i))); + SolutionSet * result = new SolutionSet(ranking->getSubfront(0)->size()); + for (int i=0; igetSubfront(0)->size(); i++) + { + result->add(new Solution(ranking->getSubfront(0)->get(i))); } - - delete unionSolution; delete ranking; + delete population; + delete fastHypervolume; - // This piece of code shows how to use the indicator object into the code - // of SMS-EMOA. In particular, it finds the number of evaluations required - // by the algorithm to obtain a Pareto front with a hypervolume higher - // than the hypervolume of the true Pareto front. - /* - if (indicators != null && requiredEvaluations == 0) { - double HV = indicators.getHypervolume(population); - if (HV >= (0.98 * indicators.getTrueParetoFrontHypervolume())) { - requiredEvaluations = evaluations; - } - } - */ - } - - // Return as output parameter the required evaluations - //setOutputParameter("evaluations", requiredEvaluations); - - // Return the first non-dominated front - Ranking * ranking = new Ranking(population); - - SolutionSet * result = new SolutionSet(ranking->getSubfront(0)->size()); - for (int i=0;igetSubfront(0)->size();i++) { - result->add(new Solution(ranking->getSubfront(0)->get(i))); - } - delete ranking; - delete population; - delete fastHypervolume; - - return result; + return result; } diff --git a/src/metaheuristics/smsemoa/FastSMSEMOA.h b/src/metaheuristics/smsemoa/FastSMSEMOA.h index b5f43a8..b07e9bf 100644 --- a/src/metaheuristics/smsemoa/FastSMSEMOA.h +++ b/src/metaheuristics/smsemoa/FastSMSEMOA.h @@ -31,20 +31,21 @@ #include #include -class FastSMSEMOA : public Algorithm { +class FastSMSEMOA : public Algorithm +{ private: - MetricsUtil * utils_; - Hypervolume * hv_; + MetricsUtil * utils_; + Hypervolume * hv_; - vector hvContributions(vector< vector > front); + vector hvContributions(vector< vector > front); public: - FastSMSEMOA(Problem * problem); - ~FastSMSEMOA(); - SolutionSet * execute(); + FastSMSEMOA(Problem * problem); + ~FastSMSEMOA(); + SolutionSet * execute(); }; diff --git a/src/metaheuristics/smsemoa/SMSEMOA.cpp b/src/metaheuristics/smsemoa/SMSEMOA.cpp index 9b16c09..7eb7c10 100644 --- a/src/metaheuristics/smsemoa/SMSEMOA.cpp +++ b/src/metaheuristics/smsemoa/SMSEMOA.cpp @@ -30,17 +30,19 @@ * Constructor * @param problem Problem to solve */ -SMSEMOA::SMSEMOA(Problem *problem) : Algorithm(problem) { - utils_ = new MetricsUtil(); - hv_ = new Hypervolume(); +SMSEMOA::SMSEMOA(Problem *problem) : Algorithm(problem) +{ + utils_ = new MetricsUtil(); + hv_ = new Hypervolume(); } // SMSEMOA /** * Destructor */ -SMSEMOA::~SMSEMOA() { - delete utils_; - delete hv_; +SMSEMOA::~SMSEMOA() +{ + delete utils_; + delete hv_; } // ~SMSEMOA @@ -49,240 +51,261 @@ SMSEMOA::~SMSEMOA() { * @return a SolutionSet that is a set of non dominated solutions * as a result of the algorithm execution */ -SolutionSet * SMSEMOA::execute() { - int populationSize; - int maxEvaluations; - int evaluations; - double offset = 100.0; - - QualityIndicator * indicators; // QualityIndicator object - int requiredEvaluations; // Use in the example of use of the indicators object (see below) - - SolutionSet * population; - SolutionSet * offspringPopulation; - SolutionSet * unionSolution; - - Operator * mutationOperator; - Operator * crossoverOperator; - Operator * selectionOperator; - - //Read the parameters - populationSize = *(int *) getInputParameter("populationSize"); - maxEvaluations = *(int *) getInputParameter("maxEvaluations"); - offset = *(double *) getInputParameter("offset"); - - //indicators = (QualityIndicator*) getInputParameter("indicators"); - - //Initialize the variables - population = new SolutionSet(populationSize); - evaluations = 0; - - requiredEvaluations = 0; - - //Read the operators - crossoverOperator = operators_["crossover"]; - mutationOperator = operators_["mutation"]; - selectionOperator = operators_["selection"]; - - // Create the initial solutionSet - Solution * newSolution; - for (int i = 0; i < populationSize; i++) { - newSolution = new Solution(problem_); - problem_->evaluate(newSolution); - problem_->evaluateConstraints(newSolution); - evaluations++; - population->add(newSolution); - } //for - - Solution ** parents; - Solution ** offSpring; - - // Generations ... - while (evaluations < maxEvaluations) { - - // Create the offSpring solutionSet - offspringPopulation = new SolutionSet(1); - - /*Selection Operator must return two individuals*/ - parents = (Solution **) (selectionOperator->execute(population)); - - offSpring = (Solution **) (crossoverOperator->execute(parents)); - - mutationOperator->execute(offSpring[0]); - - problem_->evaluate(offSpring[0]); - problem_->evaluateConstraints(offSpring[0]); - - // insert child into the offspring population - offspringPopulation->add(offSpring[0]); - - evaluations++; - - //cout << "Evaluations " << evaluations << endl; - - delete offSpring[1]; - delete[] offSpring; - delete[] parents; - - // Create the solutionSet union of solutionSet and offSpring - unionSolution = population->join(offspringPopulation); - delete offspringPopulation; - - // Ranking the union (non-dominated sorting) - Ranking * ranking = new Ranking(unionSolution); - - // ensure crowding distance values are up to date - // (may be important for parent selection) - for (int j = 0; j < population->size(); j++){ - population->get(j)->setCrowdingDistance(0.0); - } - - //cout << "front 0 size: " << ranking->getSubfront(0)->size() << endl ; - - SolutionSet *lastFront = ranking->getSubfront(ranking->getNumberOfSubfronts() - 1); - if (lastFront->size() > 1) { - - vector > frontValues = lastFront->writeObjectivesToMatrix(); - int numberOfObjectives = problem_->getNumberOfObjectives(); - - // STEP 1. Obtain the maximum and minimum values of the Pareto front - vector maximumValues = utils_->getMaximumValues(unionSolution->writeObjectivesToMatrix(), numberOfObjectives); - vector minimumValues = utils_->getMinimumValues(unionSolution->writeObjectivesToMatrix(), numberOfObjectives); - - // STEP 2. Get the normalized front - vector > normalizedFront = utils_->getNormalizedFront(frontValues, maximumValues, minimumValues); - - // compute offsets for reference point in normalized space - vector offsets; - for (int i = 0; i < maximumValues.size(); i++) { - offsets.push_back(offset / (maximumValues[i] - minimumValues[i])); - } - - // STEP 3. Inverse the pareto front. This is needed because the original - //metric by Zitzler is for maximization problems - vector > invertedFront = utils_->invertedFront(normalizedFront); - // shift away from origin, so that boundary points also get a contribution > 0 - for (int i = 0; i < invertedFront.size();i++) { - for (int j = 0; j < invertedFront[i].size(); j++) { - invertedFront[i][j] = invertedFront[i][j] + offsets[j]; +SolutionSet * SMSEMOA::execute() +{ + int populationSize; + int maxEvaluations; + int evaluations; + double offset = 100.0; + + QualityIndicator * indicators; // QualityIndicator object + int requiredEvaluations; // Use in the example of use of the indicators object (see below) + + SolutionSet * population; + SolutionSet * offspringPopulation; + SolutionSet * unionSolution; + + Operator * mutationOperator; + Operator * crossoverOperator; + Operator * selectionOperator; + + //Read the parameters + populationSize = *(int *) getInputParameter("populationSize"); + maxEvaluations = *(int *) getInputParameter("maxEvaluations"); + offset = *(double *) getInputParameter("offset"); + + //indicators = (QualityIndicator*) getInputParameter("indicators"); + + //Initialize the variables + population = new SolutionSet(populationSize); + evaluations = 0; + + requiredEvaluations = 0; + + //Read the operators + crossoverOperator = operators_["crossover"]; + mutationOperator = operators_["mutation"]; + selectionOperator = operators_["selection"]; + + // Create the initial solutionSet + Solution * newSolution; + for (int i = 0; i < populationSize; i++) + { + newSolution = new Solution(problem_); + problem_->evaluate(newSolution); + problem_->evaluateConstraints(newSolution); + evaluations++; + population->add(newSolution); + } //for + + Solution ** parents; + Solution ** offSpring; + + // Generations ... + while (evaluations < maxEvaluations) + { + + // Create the offSpring solutionSet + offspringPopulation = new SolutionSet(1); + + /*Selection Operator must return two individuals*/ + parents = (Solution **) (selectionOperator->execute(population)); + + offSpring = (Solution **) (crossoverOperator->execute(parents)); + + mutationOperator->execute(offSpring[0]); + + problem_->evaluate(offSpring[0]); + problem_->evaluateConstraints(offSpring[0]); + + // insert child into the offspring population + offspringPopulation->add(offSpring[0]); + + evaluations++; + + //cout << "Evaluations " << evaluations << endl; + + delete offSpring[1]; + delete[] offSpring; + delete[] parents; + + // Create the solutionSet union of solutionSet and offSpring + unionSolution = population->join(offspringPopulation); + delete offspringPopulation; + + // Ranking the union (non-dominated sorting) + Ranking * ranking = new Ranking(unionSolution); + + // ensure crowding distance values are up to date + // (may be important for parent selection) + for (int j = 0; j < population->size(); j++) + { + population->get(j)->setCrowdingDistance(0.0); } - } - - // calculate contributions and sort - vector contributions = hvContributions(invertedFront); - for (int i = 0; i < contributions.size(); i++) { - // contribution values are used analogously to crowding distance - lastFront->get(i)->setCrowdingDistance(contributions[i]); - } - - CrowdingDistanceComparator *cd = new CrowdingDistanceComparator(); - lastFront->sort(cd); - delete cd; - - } - - // all but the worst are carried over to the survivor population - SolutionSet *front = NULL; - for (int i=0;isize();i++) { - delete population->get(i); - } - population->clear(); - - for (int i = 0; i < ranking->getNumberOfSubfronts() - 1; i++) { - front = ranking->getSubfront(i); - for (int j = 0; j < front->size(); j++) - population->add(new Solution(front->get(j))); + + //cout << "front 0 size: " << ranking->getSubfront(0)->size() << endl ; + + SolutionSet *lastFront = ranking->getSubfront(ranking->getNumberOfSubfronts() - 1); + if (lastFront->size() > 1) + { + + vector > frontValues = lastFront->writeObjectivesToMatrix(); + int numberOfObjectives = problem_->getNumberOfObjectives(); + + // STEP 1. Obtain the maximum and minimum values of the Pareto front + vector maximumValues = utils_->getMaximumValues(unionSolution->writeObjectivesToMatrix(), numberOfObjectives); + vector minimumValues = utils_->getMinimumValues(unionSolution->writeObjectivesToMatrix(), numberOfObjectives); + + // STEP 2. Get the normalized front + vector > normalizedFront = utils_->getNormalizedFront(frontValues, maximumValues, minimumValues); + + // compute offsets for reference point in normalized space + vector offsets; + for (int i = 0; i < maximumValues.size(); i++) + { + offsets.push_back(offset / (maximumValues[i] - minimumValues[i])); + } + + // STEP 3. Inverse the pareto front. This is needed because the original + //metric by Zitzler is for maximization problems + vector > invertedFront = utils_->invertedFront(normalizedFront); + // shift away from origin, so that boundary points also get a contribution > 0 + for (int i = 0; i < invertedFront.size(); i++) + { + for (int j = 0; j < invertedFront[i].size(); j++) + { + invertedFront[i][j] = invertedFront[i][j] + offsets[j]; + } + } + + // calculate contributions and sort + vector contributions = hvContributions(invertedFront); + for (int i = 0; i < contributions.size(); i++) + { + // contribution values are used analogously to crowding distance + lastFront->get(i)->setCrowdingDistance(contributions[i]); + } + + CrowdingDistanceComparator *cd = new CrowdingDistanceComparator(); + lastFront->sort(cd); + delete cd; + + } + + // all but the worst are carried over to the survivor population + SolutionSet *front = NULL; + for (int i=0; isize(); i++) + { + delete population->get(i); + } + population->clear(); + + for (int i = 0; i < ranking->getNumberOfSubfronts() - 1; i++) + { + front = ranking->getSubfront(i); + for (int j = 0; j < front->size(); j++) + population->add(new Solution(front->get(j))); + } + for (int i = 0; i < lastFront->size() - 1; i++) + population->add(new Solution(lastFront->get(i))); + + delete ranking; + delete unionSolution; + + // This piece of code shows how to use the indicator object into the code + // of SMS-EMOA. In particular, it finds the number of evaluations required + // by the algorithm to obtain a Pareto front with a hypervolume higher + // than the hypervolume of the true Pareto front. + /*if (indicators != NULL && requiredEvaluations == 0) { + double HV = indicators->getHypervolume(population); + if (HV >= (0.98 * indicators->getTrueParetoFrontHypervolume())) { + requiredEvaluations = evaluations; + } // if + } // if */ + + } //WHILE + + // Return the first non-dominated front + Ranking *ranking = new Ranking(population); + SolutionSet * result = new SolutionSet(ranking->getSubfront(0)->size()); + for (int i=0; igetSubfront(0)->size(); i++) + { + result->add(new Solution(ranking->getSubfront(0)->get(i))); } - for (int i = 0; i < lastFront->size() - 1; i++) - population->add(new Solution(lastFront->get(i))); - delete ranking; - delete unionSolution; - - // This piece of code shows how to use the indicator object into the code - // of SMS-EMOA. In particular, it finds the number of evaluations required - // by the algorithm to obtain a Pareto front with a hypervolume higher - // than the hypervolume of the true Pareto front. - /*if (indicators != NULL && requiredEvaluations == 0) { - double HV = indicators->getHypervolume(population); - if (HV >= (0.98 * indicators->getTrueParetoFrontHypervolume())) { - requiredEvaluations = evaluations; - } // if - } // if */ - - } //WHILE - - // Return the first non-dominated front - Ranking *ranking = new Ranking(population); - SolutionSet * result = new SolutionSet(ranking->getSubfront(0)->size()); - for (int i=0;igetSubfront(0)->size();i++) { - result->add(new Solution(ranking->getSubfront(0)->get(i))); - } - delete ranking; - delete population; - - return result; + delete population; + + return result; } -vector SMSEMOA::hvContributions(vector< vector > front){ - int numberOfObjectives = problem_->getNumberOfObjectives(); - - vector contributions; - double hv; - - double** frontSubset; - - vector< vector > frontCopy; - - double** totalFront = new double*[front.size()]; - - for (int i = 0; i < front.size(); i++) { - frontCopy.push_back(vector()); - totalFront[i] = new double[front[i].size()]; - for (int j = 0; j < front[i].size(); j++) { - frontCopy[i].push_back(front[i][j]); - totalFront[i][j] = front[i][j]; - } - } - - double totalVolume = hv_->calculateHypervolume(totalFront, front.size(), numberOfObjectives); - - for (int i = 0; i < front.size(); i++) { - - vector evaluatedPoint; - for (int j = 0; j < frontCopy[i].size(); j++) { - evaluatedPoint.push_back(frontCopy[i][j]); +vector SMSEMOA::hvContributions(vector< vector > front) +{ + int numberOfObjectives = problem_->getNumberOfObjectives(); + + vector contributions; + double hv; + + double** frontSubset; + + vector< vector > frontCopy; + + double** totalFront = new double*[front.size()]; + + for (int i = 0; i < front.size(); i++) + { + frontCopy.push_back(vector()); + totalFront[i] = new double[front[i].size()]; + for (int j = 0; j < front[i].size(); j++) + { + frontCopy[i].push_back(front[i][j]); + totalFront[i][j] = front[i][j]; + } } - frontCopy.erase(frontCopy.begin() + i); - - /*Makes a copy in pointer of pointer format*/ - frontSubset = new double*[frontCopy.size()]; - for (int f = 0; f < frontCopy.size(); f++) { - frontSubset[f] = new double[frontCopy[f].size()]; - for (int c = 0; c < frontCopy[f].size(); c++) { - frontSubset[f][c]=frontCopy[f][c]; - } + + double totalVolume = hv_->calculateHypervolume(totalFront, front.size(), numberOfObjectives); + + for (int i = 0; i < front.size(); i++) + { + + vector evaluatedPoint; + for (int j = 0; j < frontCopy[i].size(); j++) + { + evaluatedPoint.push_back(frontCopy[i][j]); + } + frontCopy.erase(frontCopy.begin() + i); + + /*Makes a copy in pointer of pointer format*/ + frontSubset = new double*[frontCopy.size()]; + for (int f = 0; f < frontCopy.size(); f++) + { + frontSubset[f] = new double[frontCopy[f].size()]; + for (int c = 0; c < frontCopy[f].size(); c++) + { + frontSubset[f][c]=frontCopy[f][c]; + } + } + + // STEP4. The hypervolume + hv = hv_->calculateHypervolume(frontSubset, frontCopy.size(), numberOfObjectives); + contributions.push_back(totalVolume - hv); + + // put point back position i + frontCopy.insert(frontCopy.begin() + i, evaluatedPoint); + + for( int y = 0 ; y < frontCopy.size()-1 ; y++ ) + { + delete [] frontSubset[y] ; + } + delete [] frontSubset; + } - - // STEP4. The hypervolume - hv = hv_->calculateHypervolume(frontSubset, frontCopy.size(), numberOfObjectives); - contributions.push_back(totalVolume - hv); - - // put point back position i - frontCopy.insert(frontCopy.begin() + i , evaluatedPoint); - - for( int y = 0 ; y < frontCopy.size()-1 ; y++ ) { - delete [] frontSubset[y] ; + + for( int y = 0 ; y < front.size() ; y++ ) + { + delete [] totalFront[y] ; } - delete [] frontSubset; - - } - - for( int y = 0 ; y < front.size() ; y++ ) { - delete [] totalFront[y] ; - } - delete [] totalFront; - - return contributions; + delete [] totalFront; + + return contributions; } diff --git a/src/metaheuristics/smsemoa/SMSEMOA.h b/src/metaheuristics/smsemoa/SMSEMOA.h index 10ab5f8..778229a 100644 --- a/src/metaheuristics/smsemoa/SMSEMOA.h +++ b/src/metaheuristics/smsemoa/SMSEMOA.h @@ -32,20 +32,21 @@ #include #include -class SMSEMOA : public Algorithm { +class SMSEMOA : public Algorithm +{ private: - MetricsUtil * utils_; - Hypervolume * hv_; + MetricsUtil * utils_; + Hypervolume * hv_; - vector hvContributions(vector< vector > front); + vector hvContributions(vector< vector > front); public: - SMSEMOA(Problem * problem); - ~SMSEMOA(); - SolutionSet * execute(); + SMSEMOA(Problem * problem); + ~SMSEMOA(); + SolutionSet * execute(); }; diff --git a/src/operators/crossover/Crossover.cpp b/src/operators/crossover/Crossover.cpp index 4a9b94e..55d96c4 100644 --- a/src/operators/crossover/Crossover.cpp +++ b/src/operators/crossover/Crossover.cpp @@ -22,7 +22,7 @@ #include -Crossover::Crossover(map parameters) -: Operator(parameters) {} +Crossover::Crossover(map parameters) + : Operator(parameters) {} Crossover::~Crossover() { /* do nothing */ } diff --git a/src/operators/crossover/Crossover.h b/src/operators/crossover/Crossover.h index 7a840f9..4d611f4 100644 --- a/src/operators/crossover/Crossover.h +++ b/src/operators/crossover/Crossover.h @@ -29,11 +29,12 @@ * @class Crossover * @brief This class is aimed at representing a Crossover operator **/ -class Crossover : public Operator { +class Crossover : public Operator +{ public: - Crossover(map parameters); - virtual ~Crossover() = 0; + Crossover(map parameters); + virtual ~Crossover() = 0; }; diff --git a/src/operators/crossover/DifferentialEvolutionCrossover.cpp b/src/operators/crossover/DifferentialEvolutionCrossover.cpp index 797341d..cb0d785 100644 --- a/src/operators/crossover/DifferentialEvolutionCrossover.cpp +++ b/src/operators/crossover/DifferentialEvolutionCrossover.cpp @@ -65,25 +65,30 @@ const string DifferentialEvolutionCrossover::DEFAULT_DE_VARIANT = "rand/1/bin"; * Constructor */ DifferentialEvolutionCrossover::DifferentialEvolutionCrossover(map parameters) -: Crossover(parameters) { - - CR_ = DEFAULT_CR ; - F_ = DEFAULT_F ; - K_ = DEFAULT_K ; - DE_Variant_ = DEFAULT_DE_VARIANT ; - - if (parameters["CR"] != NULL) { - CR_ = *(double *) parameters["CR"]; - } - if (parameters["F"] != NULL) { - F_ = *(double *) parameters["F"]; - } - if (parameters["K"] != NULL) { - K_ = *(double *) parameters["K"]; - } - if (parameters["DE_VARIANT"] != NULL) { - DE_Variant_ = *(string *) parameters["DE_VARIANT"]; - } + : Crossover(parameters) +{ + + CR_ = DEFAULT_CR ; + F_ = DEFAULT_F ; + K_ = DEFAULT_K ; + DE_Variant_ = DEFAULT_DE_VARIANT ; + + if (parameters["CR"] != NULL) + { + CR_ = *(double *) parameters["CR"]; + } + if (parameters["F"] != NULL) + { + F_ = *(double *) parameters["F"]; + } + if (parameters["K"] != NULL) + { + K_ = *(double *) parameters["K"]; + } + if (parameters["DE_VARIANT"] != NULL) + { + DE_Variant_ = *(string *) parameters["DE_VARIANT"]; + } } // DifferentialEvolutionCrossover @@ -93,190 +98,227 @@ DifferentialEvolutionCrossover::DifferentialEvolutionCrossover(mapgetNumberOfDecisionVariables(); - jrand = PseudoRandom::randInt(0, numberOfVariables - 1); - - // STEP 4. Checking the DE variant - if ((DE_Variant_.compare("rand/1/bin") == 0) || - (DE_Variant_.compare("best/1/bin") == 0)) { - - for (int j=0; j < numberOfVariables; j++) { - if (PseudoRandom::randDouble(0, 1) < CR_ || j == jrand) { - double value; - value = xParent2->getValue(j) + F_ * (xParent0->getValue(j) - - xParent1->getValue(j)); - - if (value < xChild->getLowerBound(j)) { - value = xChild->getLowerBound(j); - } - if (value > xChild->getUpperBound(j)) { - value = xChild->getUpperBound(j); - } - /* - if (value < xChild.getLowerBound(j)) { - double rnd = PseudoRandom.randDouble(0, 1) ; - value = xChild.getLowerBound(j) + rnd *(xParent2.getValue(j) - xChild.getLowerBound(j)) ; - } - if (value > xChild.getUpperBound(j)) { - double rnd = PseudoRandom.randDouble(0, 1) ; - value = xChild.getUpperBound(j) - rnd*(xChild.getUpperBound(j)-xParent2.getValue(j)) ; - } - */ - xChild->setValue(j, value); - } - else { - double value ; - value = xCurrent->getValue(j); - xChild->setValue(j, value); - } // else - } // for - - } else if ((DE_Variant_.compare("rand/1/exp") == 0) || - (DE_Variant_.compare("best/1/exp") == 0)) { - - for (int j=0; j < numberOfVariables; j++) { - if (PseudoRandom::randDouble(0, 1) < CR_ || j == jrand) { - double value; - value = xParent2->getValue(j) + F_ * (xParent0->getValue(j) - - xParent1->getValue(j)); - - if (value < xChild->getLowerBound(j)) { - value = xChild->getLowerBound(j); - } - if (value > xChild->getUpperBound(j)) { - value = xChild->getUpperBound(j); - } - - xChild->setValue(j, value); - } else { - CR_ = 0.0; - double value; - value = xCurrent->getValue(j); - xChild->setValue(j, value); - } // if - } // for - - } else if ((DE_Variant_.compare("current-to-rand/1") == 0) || - (DE_Variant_.compare("current-to-best/1") == 0)) { - - for (int j=0; j < numberOfVariables; j++) { - double value; - value = xCurrent->getValue(j) + K_ * (xParent2->getValue(j) - - xCurrent->getValue(j)) + - F_ * (xParent0->getValue(j) - xParent1->getValue(j)); - - if (value < xChild->getLowerBound(j)) { - value = xChild->getLowerBound(j); - } - if (value > xChild->getUpperBound(j)) { - value = xChild->getUpperBound(j); - } - xChild->setValue(j, value) ; - } // for - - } else if ((DE_Variant_.compare("current-to-rand/1/bin") == 0) || - (DE_Variant_.compare("current-to-best/1/bin") == 0)) { - - for (int j=0; j < numberOfVariables; j++) { - if (PseudoRandom::randDouble(0, 1) < CR_ || j == jrand) { - double value ; - value = xCurrent->getValue(j) + K_ * (xParent2->getValue(j) - - xCurrent->getValue(j)) + - F_ * (xParent0->getValue(j) - xParent1->getValue(j)); - - if (value < xChild->getLowerBound(j)) { - value = xChild->getLowerBound(j); - } - if (value > xChild->getUpperBound(j)) { - value = xChild->getUpperBound(j); - } - - xChild->setValue(j, value); - } - else { - double value; - value = xCurrent->getValue(j); - xChild->setValue(j, value); - } // else - } // for - - } else if ((DE_Variant_.compare("current-to-rand/1/exp") == 0) || - (DE_Variant_.compare("current-to-best/1/exp") == 0)) { - - for (int j=0; j < numberOfVariables; j++) { - if (PseudoRandom::randDouble(0, 1) < CR_ || j == jrand) { - double value ; - value = xCurrent->getValue(j) + K_ * (xParent2->getValue(j) - - xCurrent->getValue(j)) + - F_ * (xParent0->getValue(j) - xParent1->getValue(j)); - - if (value < xChild->getLowerBound(j)) { - value = xChild->getLowerBound(j); - } - if (value > xChild->getUpperBound(j)) { - value = xChild->getUpperBound(j); - } - - xChild->setValue(j, value); - } else { - CR_ = 0.0; - double value; - value = xCurrent->getValue(j); - xChild->setValue(j, value); - } // else - } // for - - } else { - - cerr << "DifferentialEvolutionCrossover.execute: " << - " unknown DE variant (" << DE_Variant_ << ")" << endl; - cerr << "Exception in DifferentialEvolutionCrossover.execute()" << endl; - exit(-1); - - } // if - - delete xParent0; - delete xParent1; - delete xParent2; - delete xCurrent; - delete xChild; - - return child; +void * DifferentialEvolutionCrossover::execute(void *object) +{ + + void ** parameters = (void **) object; + Solution * current = (Solution *) parameters[0]; + Solution ** parent = (Solution **) parameters[1]; + // TODO: Comprobar la longitud de parents + + Solution * child; + + // TODO: Chequear el tipo de parents + // if (!(VALID_TYPES.contains(parent[0].getType().getClass()) && + // VALID_TYPES.contains(parent[1].getType().getClass()) && + // VALID_TYPES.contains(parent[2].getType().getClass())) ) { + // + // Configuration.logger_.severe("DifferentialEvolutionCrossover.execute: " + + // " the solutions " + + // "are not of the right type. The type should be 'Real' or 'ArrayReal', but " + + // parent[0].getType() + " and " + + // parent[1].getType() + " and " + + // parent[2].getType() + " are obtained"); + // + // Class cls = java.lang.String.class; + // String name = cls.getName(); + // throw new JMException("Exception in " + name + ".execute()") ; + // } + + int jrand; + + child = new Solution(current); + + XReal * xParent0 = new XReal(parent[0]); + XReal * xParent1 = new XReal(parent[1]); + XReal * xParent2 = new XReal(parent[2]); + XReal * xCurrent = new XReal(current); + XReal * xChild = new XReal(child); + + int numberOfVariables = xParent0->getNumberOfDecisionVariables(); + jrand = PseudoRandom::randInt(0, numberOfVariables - 1); + + // STEP 4. Checking the DE variant + if ((DE_Variant_.compare("rand/1/bin") == 0) || + (DE_Variant_.compare("best/1/bin") == 0)) + { + + for (int j=0; j < numberOfVariables; j++) + { + if (PseudoRandom::randDouble(0, 1) < CR_ || j == jrand) + { + double value; + value = xParent2->getValue(j) + F_ * (xParent0->getValue(j) - + xParent1->getValue(j)); + + if (value < xChild->getLowerBound(j)) + { + value = xChild->getLowerBound(j); + } + if (value > xChild->getUpperBound(j)) + { + value = xChild->getUpperBound(j); + } + /* + if (value < xChild.getLowerBound(j)) { + double rnd = PseudoRandom.randDouble(0, 1) ; + value = xChild.getLowerBound(j) + rnd *(xParent2.getValue(j) - xChild.getLowerBound(j)) ; + } + if (value > xChild.getUpperBound(j)) { + double rnd = PseudoRandom.randDouble(0, 1) ; + value = xChild.getUpperBound(j) - rnd*(xChild.getUpperBound(j)-xParent2.getValue(j)) ; + } + */ + xChild->setValue(j, value); + } + else + { + double value ; + value = xCurrent->getValue(j); + xChild->setValue(j, value); + } // else + } // for + + } + else if ((DE_Variant_.compare("rand/1/exp") == 0) || + (DE_Variant_.compare("best/1/exp") == 0)) + { + + for (int j=0; j < numberOfVariables; j++) + { + if (PseudoRandom::randDouble(0, 1) < CR_ || j == jrand) + { + double value; + value = xParent2->getValue(j) + F_ * (xParent0->getValue(j) - + xParent1->getValue(j)); + + if (value < xChild->getLowerBound(j)) + { + value = xChild->getLowerBound(j); + } + if (value > xChild->getUpperBound(j)) + { + value = xChild->getUpperBound(j); + } + + xChild->setValue(j, value); + } + else + { + CR_ = 0.0; + double value; + value = xCurrent->getValue(j); + xChild->setValue(j, value); + } // if + } // for + + } + else if ((DE_Variant_.compare("current-to-rand/1") == 0) || + (DE_Variant_.compare("current-to-best/1") == 0)) + { + + for (int j=0; j < numberOfVariables; j++) + { + double value; + value = xCurrent->getValue(j) + K_ * (xParent2->getValue(j) - + xCurrent->getValue(j)) + + F_ * (xParent0->getValue(j) - xParent1->getValue(j)); + + if (value < xChild->getLowerBound(j)) + { + value = xChild->getLowerBound(j); + } + if (value > xChild->getUpperBound(j)) + { + value = xChild->getUpperBound(j); + } + xChild->setValue(j, value) ; + } // for + + } + else if ((DE_Variant_.compare("current-to-rand/1/bin") == 0) || + (DE_Variant_.compare("current-to-best/1/bin") == 0)) + { + + for (int j=0; j < numberOfVariables; j++) + { + if (PseudoRandom::randDouble(0, 1) < CR_ || j == jrand) + { + double value ; + value = xCurrent->getValue(j) + K_ * (xParent2->getValue(j) - + xCurrent->getValue(j)) + + F_ * (xParent0->getValue(j) - xParent1->getValue(j)); + + if (value < xChild->getLowerBound(j)) + { + value = xChild->getLowerBound(j); + } + if (value > xChild->getUpperBound(j)) + { + value = xChild->getUpperBound(j); + } + + xChild->setValue(j, value); + } + else + { + double value; + value = xCurrent->getValue(j); + xChild->setValue(j, value); + } // else + } // for + + } + else if ((DE_Variant_.compare("current-to-rand/1/exp") == 0) || + (DE_Variant_.compare("current-to-best/1/exp") == 0)) + { + + for (int j=0; j < numberOfVariables; j++) + { + if (PseudoRandom::randDouble(0, 1) < CR_ || j == jrand) + { + double value ; + value = xCurrent->getValue(j) + K_ * (xParent2->getValue(j) - + xCurrent->getValue(j)) + + F_ * (xParent0->getValue(j) - xParent1->getValue(j)); + + if (value < xChild->getLowerBound(j)) + { + value = xChild->getLowerBound(j); + } + if (value > xChild->getUpperBound(j)) + { + value = xChild->getUpperBound(j); + } + + xChild->setValue(j, value); + } + else + { + CR_ = 0.0; + double value; + value = xCurrent->getValue(j); + xChild->setValue(j, value); + } // else + } // for + + } + else + { + + cerr << "DifferentialEvolutionCrossover.execute: " << + " unknown DE variant (" << DE_Variant_ << ")" << endl; + cerr << "Exception in DifferentialEvolutionCrossover.execute()" << endl; + exit(-1); + + } // if + + delete xParent0; + delete xParent1; + delete xParent2; + delete xCurrent; + delete xChild; + + return child; } // execute diff --git a/src/operators/crossover/DifferentialEvolutionCrossover.h b/src/operators/crossover/DifferentialEvolutionCrossover.h index 451d726..0aa708f 100644 --- a/src/operators/crossover/DifferentialEvolutionCrossover.h +++ b/src/operators/crossover/DifferentialEvolutionCrossover.h @@ -43,24 +43,25 @@ * - current-to-rand/1/bin (current-to-best/1/bin) * - current-to-rand/1/exp (current-to-best/1/exp) */ -class DifferentialEvolutionCrossover : public Crossover { +class DifferentialEvolutionCrossover : public Crossover +{ public: - DifferentialEvolutionCrossover(map parameters); - void *execute(void *); + DifferentialEvolutionCrossover(map parameters); + void *execute(void *); protected: - static const double DEFAULT_CR; - static const double DEFAULT_F; - static const double DEFAULT_K; - static const string DEFAULT_DE_VARIANT; + static const double DEFAULT_CR; + static const double DEFAULT_F; + static const double DEFAULT_K; + static const string DEFAULT_DE_VARIANT; private: - double CR_ ; - double F_ ; - double K_ ; - string DE_Variant_ ; // DE variant (rand/1/bin, rand/1/exp, etc.) - //TODO: A�adir VALID_TYPES; + double CR_ ; + double F_ ; + double K_ ; + string DE_Variant_ ; // DE variant (rand/1/bin, rand/1/exp, etc.) + //TODO: A�adir VALID_TYPES; }; diff --git a/src/operators/crossover/HUXCrossover.cpp b/src/operators/crossover/HUXCrossover.cpp index 52c2152..f6385de 100644 --- a/src/operators/crossover/HUXCrossover.cpp +++ b/src/operators/crossover/HUXCrossover.cpp @@ -28,11 +28,12 @@ * index given by DEFAULT_INDEX_CROSSOVER */ HUXCrossover::HUXCrossover(map parameters) -: Crossover(parameters) { - crossoverProbability_ = 0.0 ; - //TODO: crossoverProbability_ = NULL; - if (parameters["probability"] != NULL) - crossoverProbability_ = *(double *)parameters["probability"]; + : Crossover(parameters) +{ + crossoverProbability_ = 0.0 ; + //TODO: crossoverProbability_ = NULL; + if (parameters["probability"] != NULL) + crossoverProbability_ = *(double *)parameters["probability"]; } // SinglePointCrossover @@ -43,41 +44,48 @@ HUXCrossover::HUXCrossover(map parameters) * @param parent2 The second parent * @return An array containing the two offsprings **/ -Solution ** HUXCrossover::doCrossover(double probability, Solution *parent1, Solution *parent2) { - - Solution** offSpring = new Solution*[2]; - - if (offSpring == NULL) { - cout << "Error grave: Impossible reserve memory for allocating new solutions when performing SinglePointCrossover " << endl; - exit(-1); - } - - offSpring[0] = new Solution(parent1); - offSpring[1] = new Solution(parent2); - - if (PseudoRandom::randDouble() < probability) { - for (int var = 0; var < parent1->getNumberOfVariables(); var++) { - Binary *p1 = (Binary *)parent1->getDecisionVariables()[var]; - Binary *p2 = (Binary *)parent2->getDecisionVariables()[var]; - for (int bit = 0; bit < p1->getNumberOfBits(); bit++) { - if (PseudoRandom::randDouble() < 0.5) { - Binary *o1, *o2; - o1 = (Binary *) offSpring[0]->getDecisionVariables()[var]; - o2 = (Binary *) offSpring[1]->getDecisionVariables()[var]; - o1->setIth(bit,p2->getIth(bit)); - o2->setIth(bit,p1->getIth(bit)); - - } - } - } - for (int var = 0; var < parent1->getNumberOfVariables(); var++) { - ((Binary *)offSpring[0]->getDecisionVariables()[var])->decode(); - ((Binary *)offSpring[0]->getDecisionVariables()[var])->decode(); - } - } - return offSpring; - - return offSpring; +Solution ** HUXCrossover::doCrossover(double probability, Solution *parent1, Solution *parent2) +{ + + Solution** offSpring = new Solution*[2]; + + if (offSpring == NULL) + { + cout << "Error grave: Impossible reserve memory for allocating new solutions when performing SinglePointCrossover " << endl; + exit(-1); + } + + offSpring[0] = new Solution(parent1); + offSpring[1] = new Solution(parent2); + + if (PseudoRandom::randDouble() < probability) + { + for (int var = 0; var < parent1->getNumberOfVariables(); var++) + { + Binary *p1 = (Binary *)parent1->getDecisionVariables()[var]; + Binary *p2 = (Binary *)parent2->getDecisionVariables()[var]; + for (int bit = 0; bit < p1->getNumberOfBits(); bit++) + { + if (PseudoRandom::randDouble() < 0.5) + { + Binary *o1, *o2; + o1 = (Binary *) offSpring[0]->getDecisionVariables()[var]; + o2 = (Binary *) offSpring[1]->getDecisionVariables()[var]; + o1->setIth(bit,p2->getIth(bit)); + o2->setIth(bit,p1->getIth(bit)); + + } + } + } + for (int var = 0; var < parent1->getNumberOfVariables(); var++) + { + ((Binary *)offSpring[0]->getDecisionVariables()[var])->decode(); + ((Binary *)offSpring[0]->getDecisionVariables()[var])->decode(); + } + } + return offSpring; + + return offSpring; } // doCrossover @@ -86,12 +94,13 @@ Solution ** HUXCrossover::doCrossover(double probability, Solution *parent1, Sol * @param object An object containing an array of two parents * @return An object containing the offSprings */ -void * HUXCrossover::execute(void *object) { - Solution ** parents = (Solution **) object; - // TODO: Comprobar la longitud de parents - // TODO: Chequear el tipo de parents +void * HUXCrossover::execute(void *object) +{ + Solution ** parents = (Solution **) object; + // TODO: Comprobar la longitud de parents + // TODO: Chequear el tipo de parents - Solution ** offSpring = (Solution **)doCrossover(crossoverProbability_, parents[0], parents[1]); + Solution ** offSpring = (Solution **)doCrossover(crossoverProbability_, parents[0], parents[1]); - return offSpring; + return offSpring; } // execute diff --git a/src/operators/crossover/HUXCrossover.h b/src/operators/crossover/HUXCrossover.h index de8623f..0f2aff3 100644 --- a/src/operators/crossover/HUXCrossover.h +++ b/src/operators/crossover/HUXCrossover.h @@ -29,16 +29,17 @@ * This class allows to apply a SBX crossover operator using two parent * solutions. **/ -class HUXCrossover : public Crossover { +class HUXCrossover : public Crossover +{ public: - HUXCrossover(map parameters); - void *execute(void *); + HUXCrossover(map parameters); + void *execute(void *); private: - double crossoverProbability_; - Solution ** doCrossover(double probability, - Solution * parent1, Solution * parent2); + double crossoverProbability_; + Solution ** doCrossover(double probability, + Solution * parent1, Solution * parent2); }; diff --git a/src/operators/crossover/SBXCrossover.cpp b/src/operators/crossover/SBXCrossover.cpp index 0b21c03..93dd040 100644 --- a/src/operators/crossover/SBXCrossover.cpp +++ b/src/operators/crossover/SBXCrossover.cpp @@ -39,13 +39,14 @@ const double SBXCrossover::ETA_C_DEFAULT_ = 20.0; * index given by DEFAULT_INDEX_CROSSOVER */ SBXCrossover::SBXCrossover(map parameters) -: Crossover(parameters) { - //TODO: crossoverProbability_ = NULL; - distributionIndex_ = ETA_C_DEFAULT_; - if (parameters["probability"] != NULL) - crossoverProbability_ = *(double *)parameters["probability"]; - if (parameters["distributionIndex"] != NULL) - distributionIndex_ = *(double *)parameters["distributionIndex"]; + : Crossover(parameters) +{ + //TODO: crossoverProbability_ = NULL; + distributionIndex_ = ETA_C_DEFAULT_; + if (parameters["probability"] != NULL) + crossoverProbability_ = *(double *)parameters["probability"]; + if (parameters["distributionIndex"] != NULL) + distributionIndex_ = *(double *)parameters["distributionIndex"]; } // SBXCrossover @@ -56,146 +57,169 @@ SBXCrossover::~SBXCrossover() { } // ~SBXCrossover /** -* Perform the crossover operation. +* Perform the crossover operation. * @param probability Crossover probability * @param parent1 The first parent * @param parent2 The second parent * @return An array containing the two offsprings **/ -Solution ** SBXCrossover::doCrossover(double probability, Solution *parent1, Solution *parent2) { - - Solution** offSpring = new Solution*[2]; - - if (offSpring == NULL) { - cout << "Error grave: Impossible reserve memory for allocating new solutions when performing SBXCrossover " << endl; - exit(-1); - } +Solution ** SBXCrossover::doCrossover(double probability, Solution *parent1, Solution *parent2) +{ + + Solution** offSpring = new Solution*[2]; + + if (offSpring == NULL) + { + cout << "Error grave: Impossible reserve memory for allocating new solutions when performing SBXCrossover " << endl; + exit(-1); + } // cout << "SBXCrossover: AggregativeValue de parent1 = " << parent1->getAggregativeValue() << endl; // cout << "SBXCrossover: AggregativeValue de parent2 = " << parent2->getAggregativeValue() << endl; - offSpring[0] = new Solution(parent1); - offSpring[1] = new Solution(parent2); + offSpring[0] = new Solution(parent1); + offSpring[1] = new Solution(parent2); // cout << "SBXCrossover: AggregativeValue de offSpring[0] = " << offSpring[0]->getAggregativeValue() << endl; // cout << "SBXCrossover: AggregativeValue de offSpring[1] = " << offSpring[1]->getAggregativeValue() << endl; - - int i; - double rand; - double y1, y2, yL, yu; - double c1, c2; - double alpha, beta, betaq; - double valueX1,valueX2; - XReal * x1 = new XReal(parent1) ; - XReal * x2 = new XReal(parent2) ; - XReal * offs1 = new XReal(offSpring[0]) ; - XReal * offs2 = new XReal(offSpring[1]) ; - - int numberOfVariables = x1->getNumberOfDecisionVariables(); - - if (PseudoRandom::randDouble() <= probability){ - for (i=0; igetValue(i); - valueX2 = x2->getValue(i); - - if (PseudoRandom::randDouble()<=0.5 ){ - if (fabs(valueX1- valueX2) > EPS){ - - if (valueX1 < valueX2){ - y1 = valueX1; - y2 = valueX2; - } else { - y1 = valueX2; - y2 = valueX1; - } // if - - yL = x1->getLowerBound(i); - yu = x1->getUpperBound(i); - - //cout << yL << " " << yu << endl; - rand = PseudoRandom::randDouble(); - - beta = 1.0 + (2.0*(y1-yL)/(y2-y1)); - alpha = 2.0 - pow(beta,-(distributionIndex_+1.0)); - - if (rand <= (1.0/alpha)){ - betaq = pow ((rand*alpha),(1.0/(distributionIndex_+1.0))); - } else { - betaq = pow ((1.0/(2.0 - rand*alpha)),(1.0/(distributionIndex_+1.0))); - } // if - - c1 = 0.5*((y1+y2)-betaq*(y2-y1)); - beta = 1.0 + (2.0*(yu-y2)/(y2-y1)); - alpha = 2.0 - pow(beta,-(distributionIndex_+1.0)); - - if (rand <= (1.0/alpha)){ - betaq = pow ((rand*alpha),(1.0/(distributionIndex_+1.0))); - } else { - betaq = pow ((1.0/(2.0 - rand*alpha)),(1.0/(distributionIndex_+1.0))); - } // if - - c2 = 0.5*((y1+y2)+betaq*(y2-y1)); - - if (c1yu) - c1=yu; - - if (c2>yu) - c2=yu; - - if (PseudoRandom::randDouble()<=0.5) { - offs1->setValue(i,c2); - offs2->setValue(i,c1); - } else { - offs1->setValue(i,c1); - offs2->setValue(i,c2); - } // if - } else { - offs1->setValue(i,valueX1); - offs2->setValue(i,valueX2); + + int i; + double rand; + double y1, y2, yL, yu; + double c1, c2; + double alpha, beta, betaq; + double valueX1,valueX2; + XReal * x1 = new XReal(parent1) ; + XReal * x2 = new XReal(parent2) ; + XReal * offs1 = new XReal(offSpring[0]) ; + XReal * offs2 = new XReal(offSpring[1]) ; + + int numberOfVariables = x1->getNumberOfDecisionVariables(); + + if (PseudoRandom::randDouble() <= probability) + { + for (i=0; igetValue(i); + valueX2 = x2->getValue(i); + + if (PseudoRandom::randDouble()<=0.5 ) + { + if (fabs(valueX1- valueX2) > EPS) + { + + if (valueX1 < valueX2) + { + y1 = valueX1; + y2 = valueX2; + } + else + { + y1 = valueX2; + y2 = valueX1; + } // if + + yL = x1->getLowerBound(i); + yu = x1->getUpperBound(i); + + //cout << yL << " " << yu << endl; + rand = PseudoRandom::randDouble(); + + beta = 1.0 + (2.0*(y1-yL)/(y2-y1)); + alpha = 2.0 - pow(beta,-(distributionIndex_+1.0)); + + if (rand <= (1.0/alpha)) + { + betaq = pow ((rand*alpha),(1.0/(distributionIndex_+1.0))); + } + else + { + betaq = pow ((1.0/(2.0 - rand*alpha)),(1.0/(distributionIndex_+1.0))); + } // if + + c1 = 0.5*((y1+y2)-betaq*(y2-y1)); + beta = 1.0 + (2.0*(yu-y2)/(y2-y1)); + alpha = 2.0 - pow(beta,-(distributionIndex_+1.0)); + + if (rand <= (1.0/alpha)) + { + betaq = pow ((rand*alpha),(1.0/(distributionIndex_+1.0))); + } + else + { + betaq = pow ((1.0/(2.0 - rand*alpha)),(1.0/(distributionIndex_+1.0))); + } // if + + c2 = 0.5*((y1+y2)+betaq*(y2-y1)); + + if (c1yu) + c1=yu; + + if (c2>yu) + c2=yu; + + if (PseudoRandom::randDouble()<=0.5) + { + offs1->setValue(i,c2); + offs2->setValue(i,c1); + } + else + { + offs1->setValue(i,c1); + offs2->setValue(i,c2); + } // if + } + else + { + offs1->setValue(i,valueX1); + offs2->setValue(i,valueX2); + } // if + } + else + { + offs1->setValue(i,valueX2); + offs2->setValue(i,valueX1); + } // if } // if - } else { - offs1->setValue(i,valueX2); - offs2->setValue(i,valueX1); - } // if } // if - } // if - delete x1; - delete x2; - delete offs1; - delete offs2; - - return offSpring; + delete x1; + delete x2; + delete offs1; + delete offs2; + + return offSpring; } // doCrossover - - + + /** * Executes the operation * @param object An object containing an array of two parents * @return An object containing the offSprings */ -void * SBXCrossover::execute(void *object) { +void * SBXCrossover::execute(void *object) +{ // double probability = *(double *)getParameter("probability"); - - Solution ** parents = (Solution **) object; - // TODO: Comprobar la longitud de parents - // TODO: Chequear el tipo de parents - Solution ** offSpring = (Solution **)doCrossover(crossoverProbability_, parents[0], parents[1]); - + Solution ** parents = (Solution **) object; + // TODO: Comprobar la longitud de parents + // TODO: Chequear el tipo de parents + + Solution ** offSpring = (Solution **)doCrossover(crossoverProbability_, parents[0], parents[1]); + // for (int i = 0; i < 2; i++) // this operator will return only 2 offpsrings // { // offSpring[i]->setCrowdingDistance(0.0); // offSpring[i]->setRank(0); // } - return offSpring; -} // execute + return offSpring; +} // execute diff --git a/src/operators/crossover/SBXCrossover.h b/src/operators/crossover/SBXCrossover.h index 126fab3..ddb6ec1 100644 --- a/src/operators/crossover/SBXCrossover.h +++ b/src/operators/crossover/SBXCrossover.h @@ -32,23 +32,24 @@ * This class allows to apply a SBX crossover operator using two parent * solutions. **/ -class SBXCrossover : public Crossover { +class SBXCrossover : public Crossover +{ public: - SBXCrossover(map parameters); - ~SBXCrossover(); - void *execute(void *); + SBXCrossover(map parameters); + ~SBXCrossover(); + void *execute(void *); protected: - static const double ETA_C_DEFAULT_; - static const double EPS; + static const double ETA_C_DEFAULT_; + static const double EPS; private: - double crossoverProbability_; - double distributionIndex_; - //TODO: A�adir VALID_TYPES; - Solution ** doCrossover(double probability, - Solution * parent1, Solution * parent2); + double crossoverProbability_; + double distributionIndex_; + //TODO: A�adir VALID_TYPES; + Solution ** doCrossover(double probability, + Solution * parent1, Solution * parent2); }; #endif diff --git a/src/operators/crossover/SinglePointCrossover.cpp b/src/operators/crossover/SinglePointCrossover.cpp index 85dca51..a142cb7 100644 --- a/src/operators/crossover/SinglePointCrossover.cpp +++ b/src/operators/crossover/SinglePointCrossover.cpp @@ -34,11 +34,12 @@ * index given by DEFAULT_INDEX_CROSSOVER */ SinglePointCrossover::SinglePointCrossover(map parameters) -: Crossover(parameters) { - crossoverProbability_ = 0.0 ; - //TODO: crossoverProbability_ = NULL; - if (parameters["probability"] != NULL) - crossoverProbability_ = *(double *)parameters["probability"]; + : Crossover(parameters) +{ + crossoverProbability_ = 0.0 ; + //TODO: crossoverProbability_ = NULL; + if (parameters["probability"] != NULL) + crossoverProbability_ = *(double *)parameters["probability"]; } // SinglePointCrossover @@ -49,92 +50,99 @@ SinglePointCrossover::SinglePointCrossover(map parameters) * @param parent2 The second parent * @return An array containing the two offsprings **/ -Solution ** SinglePointCrossover::doCrossover(double probability, Solution *parent1, Solution *parent2) { +Solution ** SinglePointCrossover::doCrossover(double probability, Solution *parent1, Solution *parent2) +{ - Solution** offSpring = new Solution*[2]; + Solution** offSpring = new Solution*[2]; - if (offSpring == NULL) { - cout << "Error grave: Impossible reserve memory for allocating new solutions when performing SinglePointCrossover " << endl; - exit(-1); - } - - offSpring[0] = new Solution(parent1); - offSpring[1] = new Solution(parent2); - - if (PseudoRandom::randDouble() < probability) { - //1. Compute the total number of bits - int totalNumberOfBits = 0; - for (int i = 0; i < parent1->getProblem()->getNumberOfVariables(); i++) { - totalNumberOfBits += - ((Binary *)(parent1->getDecisionVariables()[0]))->getNumberOfBits() ; - } - - //2. Calculate the point to make the crossover - int crossoverPoint = PseudoRandom::randInt(0, totalNumberOfBits - 1); - - //3. Compute the variable containing the crossoverPoint bit - int variable = 0; - int acountBits = - ((Binary *)(parent1->getDecisionVariables()[variable]))->getNumberOfBits() ; - - while (acountBits < (crossoverPoint + 1)) { - variable++; - acountBits += - ((Binary *)(parent1->getDecisionVariables()[variable]))->getNumberOfBits() ; - } - - //4. Compute the bit into the variable selected - int diff = acountBits - crossoverPoint; - int intoVariableCrossoverPoint = - ((Binary *)(parent1->getDecisionVariables()[variable]))->getNumberOfBits() - diff; - - - //5. Make the crossover into the the gene; - Variable* offSpring1, * offSpring2; - Binary * of1, *of2 ; - offSpring1 = - ((parent1->getDecisionVariables()[variable]))->deepCopy(); - - offSpring2 = - ((parent2->getDecisionVariables()[variable]))->deepCopy(); - of1 = (Binary *)offSpring1 ; - of2 = (Binary *)offSpring2 ; - - for (int i = intoVariableCrossoverPoint; - i < of1->getNumberOfBits(); - i++) { - bool swap = of1->getIth(i) ; - of1->setIth(i, of2->getIth(i)) ; - of2->setIth(i, swap) ; + if (offSpring == NULL) + { + cout << "Error grave: Impossible reserve memory for allocating new solutions when performing SinglePointCrossover " << endl; + exit(-1); } - delete offSpring[0]->getDecisionVariables()[variable]; - delete offSpring[1]->getDecisionVariables()[variable]; - offSpring[0]->getDecisionVariables()[variable] = of1 ; - offSpring[1]->getDecisionVariables()[variable] = of2 ; - - //6. Apply the crossover to the other variables - for (int i = 0; i < variable; i++) { - - delete offSpring[0]->getDecisionVariables()[i]; - offSpring[0]->getDecisionVariables()[i] = - parent2->getDecisionVariables()[i]->deepCopy(); - - delete offSpring[1]->getDecisionVariables()[i]; - offSpring[1]->getDecisionVariables()[i] = - parent1->getDecisionVariables()[i]->deepCopy(); - - } - - //7. Decode the results - // for (int i = 0; i < offSpring[0].getDecisionVariables().length; i++) { - // ((Binary) offSpring[0].getDecisionVariables()[i]).decode(); - // ((Binary) offSpring[1].getDecisionVariables()[i]).decode(); - // } - - } // Binary or BinaryReal - - return offSpring; + offSpring[0] = new Solution(parent1); + offSpring[1] = new Solution(parent2); + + if (PseudoRandom::randDouble() < probability) + { + //1. Compute the total number of bits + int totalNumberOfBits = 0; + for (int i = 0; i < parent1->getProblem()->getNumberOfVariables(); i++) + { + totalNumberOfBits += + ((Binary *)(parent1->getDecisionVariables()[0]))->getNumberOfBits() ; + } + + //2. Calculate the point to make the crossover + int crossoverPoint = PseudoRandom::randInt(0, totalNumberOfBits - 1); + + //3. Compute the variable containing the crossoverPoint bit + int variable = 0; + int acountBits = + ((Binary *)(parent1->getDecisionVariables()[variable]))->getNumberOfBits() ; + + while (acountBits < (crossoverPoint + 1)) + { + variable++; + acountBits += + ((Binary *)(parent1->getDecisionVariables()[variable]))->getNumberOfBits() ; + } + + //4. Compute the bit into the variable selected + int diff = acountBits - crossoverPoint; + int intoVariableCrossoverPoint = + ((Binary *)(parent1->getDecisionVariables()[variable]))->getNumberOfBits() - diff; + + + //5. Make the crossover into the the gene; + Variable* offSpring1, * offSpring2; + Binary * of1, *of2 ; + offSpring1 = + ((parent1->getDecisionVariables()[variable]))->deepCopy(); + + offSpring2 = + ((parent2->getDecisionVariables()[variable]))->deepCopy(); + of1 = (Binary *)offSpring1 ; + of2 = (Binary *)offSpring2 ; + + for (int i = intoVariableCrossoverPoint; + i < of1->getNumberOfBits(); + i++) + { + bool swap = of1->getIth(i) ; + of1->setIth(i, of2->getIth(i)) ; + of2->setIth(i, swap) ; + } + + delete offSpring[0]->getDecisionVariables()[variable]; + delete offSpring[1]->getDecisionVariables()[variable]; + offSpring[0]->getDecisionVariables()[variable] = of1 ; + offSpring[1]->getDecisionVariables()[variable] = of2 ; + + //6. Apply the crossover to the other variables + for (int i = 0; i < variable; i++) + { + + delete offSpring[0]->getDecisionVariables()[i]; + offSpring[0]->getDecisionVariables()[i] = + parent2->getDecisionVariables()[i]->deepCopy(); + + delete offSpring[1]->getDecisionVariables()[i]; + offSpring[1]->getDecisionVariables()[i] = + parent1->getDecisionVariables()[i]->deepCopy(); + + } + + //7. Decode the results + // for (int i = 0; i < offSpring[0].getDecisionVariables().length; i++) { + // ((Binary) offSpring[0].getDecisionVariables()[i]).decode(); + // ((Binary) offSpring[1].getDecisionVariables()[i]).decode(); + // } + + } // Binary or BinaryReal + + return offSpring; } // doCrossover @@ -143,12 +151,13 @@ Solution ** SinglePointCrossover::doCrossover(double probability, Solution *pare * @param object An object containing an array of two parents * @return An object containing the offSprings */ -void * SinglePointCrossover::execute(void *object) { - Solution ** parents = (Solution **) object; - // TODO: Comprobar la longitud de parents - // TODO: Chequear el tipo de parents +void * SinglePointCrossover::execute(void *object) +{ + Solution ** parents = (Solution **) object; + // TODO: Comprobar la longitud de parents + // TODO: Chequear el tipo de parents - Solution ** offSpring = (Solution **)doCrossover(crossoverProbability_, parents[0], parents[1]); + Solution ** offSpring = (Solution **)doCrossover(crossoverProbability_, parents[0], parents[1]); - return offSpring; + return offSpring; } // execute diff --git a/src/operators/crossover/SinglePointCrossover.h b/src/operators/crossover/SinglePointCrossover.h index 97efbe6..a9a1b0a 100644 --- a/src/operators/crossover/SinglePointCrossover.h +++ b/src/operators/crossover/SinglePointCrossover.h @@ -30,16 +30,17 @@ * This class allows to apply a SBX crossover operator using two parent * solutions. **/ -class SinglePointCrossover : public Crossover { +class SinglePointCrossover : public Crossover +{ public: - SinglePointCrossover(map parameters); - void *execute(void *); + SinglePointCrossover(map parameters); + void *execute(void *); private: - double crossoverProbability_; - Solution ** doCrossover(double probability, - Solution * parent1, Solution * parent2); + double crossoverProbability_; + Solution ** doCrossover(double probability, + Solution * parent1, Solution * parent2); }; #endif diff --git a/src/operators/mutation/BitFlipMutation.cpp b/src/operators/mutation/BitFlipMutation.cpp index 51ff7ea..0741cc1 100644 --- a/src/operators/mutation/BitFlipMutation.cpp +++ b/src/operators/mutation/BitFlipMutation.cpp @@ -27,10 +27,11 @@ * Creates a new instance of the polynomial mutation operator */ BitFlipMutation::BitFlipMutation(map parameters) -: Mutation(parameters) { - mutationProbability_ = 0.0 ; - if (parameters["probability"] != NULL) - mutationProbability_ = *(double *) parameters["probability"]; + : Mutation(parameters) +{ + mutationProbability_ = 0.0 ; + if (parameters["probability"] != NULL) + mutationProbability_ = *(double *) parameters["probability"]; } // BitFlipMutation @@ -45,16 +46,18 @@ BitFlipMutation::~BitFlipMutation() { } // ~BitFlipMutation * @param probability Mutation probability * @param solution The solution to mutate */ -void * BitFlipMutation::doMutation(double probability, Solution *solution) { - int numberOfVariables = solution->getNumberOfVariables() ; +void * BitFlipMutation::doMutation(double probability, Solution *solution) +{ + int numberOfVariables = solution->getNumberOfVariables() ; - for (int i = 0 ; i < numberOfVariables ; i++) { - Binary * variable = (Binary *)(solution->getDecisionVariables()[i]) ; - for (int j = 0; j < variable->getNumberOfBits() ; j++) - if (PseudoRandom::randDouble() <= mutationProbability_) - variable->flip(j) ; - } - return nullptr; + for (int i = 0 ; i < numberOfVariables ; i++) + { + Binary * variable = (Binary *)(solution->getDecisionVariables()[i]) ; + for (int j = 0; j < variable->getNumberOfBits() ; j++) + if (PseudoRandom::randDouble() <= mutationProbability_) + variable->flip(j) ; + } + return nullptr; } // doMutation @@ -64,11 +67,12 @@ void * BitFlipMutation::doMutation(double probability, Solution *solution) { * @return An object containing the mutated solution * @throws JMException */ -void * BitFlipMutation::execute(void *object) { - Solution *solution = (Solution *)object; - // TODO: VALID_TYPES? +void * BitFlipMutation::execute(void *object) +{ + Solution *solution = (Solution *)object; + // TODO: VALID_TYPES? - doMutation(mutationProbability_, solution) ; + doMutation(mutationProbability_, solution) ; - return solution; + return solution; } // execute diff --git a/src/operators/mutation/BitFlipMutation.h b/src/operators/mutation/BitFlipMutation.h index c90148d..9e681d9 100644 --- a/src/operators/mutation/BitFlipMutation.h +++ b/src/operators/mutation/BitFlipMutation.h @@ -32,17 +32,18 @@ * @class Mutation * @brief This class implements a polynomial mutation operator. **/ -class BitFlipMutation : public Mutation { +class BitFlipMutation : public Mutation +{ public: - BitFlipMutation(map parameters); - ~BitFlipMutation(); - void * execute(void *); + BitFlipMutation(map parameters); + ~BitFlipMutation(); + void * execute(void *); private: - double mutationProbability_; - // TODO: VALID_TYPES; - void * doMutation(double probability, Solution * solution); + double mutationProbability_; + // TODO: VALID_TYPES; + void * doMutation(double probability, Solution * solution); }; // BitFlipMutation diff --git a/src/operators/mutation/Mutation.cpp b/src/operators/mutation/Mutation.cpp index 636cbd7..83c5a46 100644 --- a/src/operators/mutation/Mutation.cpp +++ b/src/operators/mutation/Mutation.cpp @@ -23,6 +23,6 @@ #include Mutation::Mutation(map parameters) -: Operator (parameters) {} + : Operator (parameters) {} Mutation::~Mutation() { /* do nothing */ } diff --git a/src/operators/mutation/Mutation.h b/src/operators/mutation/Mutation.h index 93938fa..c55f74a 100644 --- a/src/operators/mutation/Mutation.h +++ b/src/operators/mutation/Mutation.h @@ -29,11 +29,12 @@ * @class Mutation * @brief This class is aimed at representing a Mutation operator **/ -class Mutation : public Operator{ +class Mutation : public Operator +{ public: - Mutation(map parameters); - virtual ~Mutation() = 0; + Mutation(map parameters); + virtual ~Mutation() = 0; }; diff --git a/src/operators/mutation/NonUniformMutation.cpp b/src/operators/mutation/NonUniformMutation.cpp index 494b034..14fc612 100644 --- a/src/operators/mutation/NonUniformMutation.cpp +++ b/src/operators/mutation/NonUniformMutation.cpp @@ -34,16 +34,20 @@ const string NonUniformMutation::VALID_TYPES[] = {"Real", "ArrayReal"}; * Creates a new instance of the non uniform mutation */ NonUniformMutation::NonUniformMutation(map parameters) -: Mutation(parameters) { - if (parameters["probability"] != NULL) { - mutationProbability_ = *(double *) parameters["probability"]; - } - if (parameters["perturbation"] != NULL) { - perturbation_ = *(double *) parameters["perturbation"]; - } - if (parameters["maxIterations"] != NULL) { - maxIterations_ = *(int *) parameters["maxIterations"]; - } + : Mutation(parameters) +{ + if (parameters["probability"] != NULL) + { + mutationProbability_ = *(double *) parameters["probability"]; + } + if (parameters["perturbation"] != NULL) + { + perturbation_ = *(double *) parameters["perturbation"]; + } + if (parameters["maxIterations"] != NULL) + { + maxIterations_ = *(int *) parameters["maxIterations"]; + } } // NonUniformMutation /** @@ -51,50 +55,60 @@ NonUniformMutation::NonUniformMutation(map parameters) * @param probability Mutation probability * @param solution The solution to mutate */ -void NonUniformMutation::doMutation(double probability, Solution *solution) { +void NonUniformMutation::doMutation(double probability, Solution *solution) +{ - XReal * x = new XReal(solution); + XReal * x = new XReal(solution); - for (int var=0; var < solution->getNumberOfVariables(); var++) { - if (PseudoRandom::randDouble() < probability) { - double rand = PseudoRandom::randDouble(); - double tmp; + for (int var=0; var < solution->getNumberOfVariables(); var++) + { + if (PseudoRandom::randDouble() < probability) + { + double rand = PseudoRandom::randDouble(); + double tmp; - if (rand <= 0.5) { - tmp = delta(x->getUpperBound(var) - x->getValue(var), - perturbation_); - tmp += x->getValue(var); - } else { - tmp = delta(x->getLowerBound(var) - x->getValue(var), - perturbation_); - tmp += x->getValue(var); - } + if (rand <= 0.5) + { + tmp = delta(x->getUpperBound(var) - x->getValue(var), + perturbation_); + tmp += x->getValue(var); + } + else + { + tmp = delta(x->getLowerBound(var) - x->getValue(var), + perturbation_); + tmp += x->getValue(var); + } - if (tmp < x->getLowerBound(var)) { - tmp = x->getLowerBound(var); - } else if (tmp > x->getUpperBound(var)) { - tmp = x->getUpperBound(var); - } + if (tmp < x->getLowerBound(var)) + { + tmp = x->getLowerBound(var); + } + else if (tmp > x->getUpperBound(var)) + { + tmp = x->getUpperBound(var); + } - x->setValue(var, tmp) ; - } // if - } // for + x->setValue(var, tmp) ; + } // if + } // for - delete x; + delete x; } // doMutation /** * Calculates the delta value used in NonUniform mutation operator */ -double NonUniformMutation::delta(double y, double bMutationParameter) { - double rand = PseudoRandom::randDouble(); - int it, maxIt; - it = currentIteration_; - maxIt = maxIterations_; +double NonUniformMutation::delta(double y, double bMutationParameter) +{ + double rand = PseudoRandom::randDouble(); + int it, maxIt; + it = currentIteration_; + maxIt = maxIterations_; - return (y * (1.0 - - pow(rand, pow((1.0 - it /(double) maxIt),bMutationParameter) ))); + return (y * (1.0 - + pow(rand, pow((1.0 - it /(double) maxIt),bMutationParameter) ))); } // delta /** @@ -102,12 +116,14 @@ double NonUniformMutation::delta(double y, double bMutationParameter) { * @param object An object containing a solution * @return An object containing the mutated solution */ -void *NonUniformMutation::execute(void *object) { - Solution *solution = (Solution *)object; - // TODO: VALID_TYPES? - if (getParameter("currentIteration") != NULL) { +void *NonUniformMutation::execute(void *object) +{ + Solution *solution = (Solution *)object; + // TODO: VALID_TYPES? + if (getParameter("currentIteration") != NULL) + { currentIteration_ = *(int *) getParameter("currentIteration") ; - } - doMutation(mutationProbability_,solution); - return solution; + } + doMutation(mutationProbability_,solution); + return solution; } // execute diff --git a/src/operators/mutation/NonUniformMutation.h b/src/operators/mutation/NonUniformMutation.h index c73acd5..b08f409 100644 --- a/src/operators/mutation/NonUniformMutation.h +++ b/src/operators/mutation/NonUniformMutation.h @@ -29,60 +29,61 @@ /** * This class implements a non-uniform mutation operator. */ -class NonUniformMutation : public Mutation { +class NonUniformMutation : public Mutation +{ private: - /** - * Valid solution types to apply this operator. - */ - static const string VALID_TYPES[]; - - /** - * perturbation_ stores the perturbation value used in the Non Uniform - * mutation operator - */ - double perturbation_; - - /** - * maxIterations_ stores the maximun number of iterations. - */ - int maxIterations_; - - /** - * currentIteration_ stores the iteration in which the operator is going to be - * applied - */ - int currentIteration_; - - double mutationProbability_; - - /** - * Performs the operation. - * @param probability Mutation probability - * @param solution The solution to mutate - * @throws JMException - */ - void doMutation(double probability, Solution *solution); - - /** - * Calculates the delta value used in NonUniform mutation operator - */ - double delta(double y, double bMutationParameter); + /** + * Valid solution types to apply this operator. + */ + static const string VALID_TYPES[]; + + /** + * perturbation_ stores the perturbation value used in the Non Uniform + * mutation operator + */ + double perturbation_; + + /** + * maxIterations_ stores the maximun number of iterations. + */ + int maxIterations_; + + /** + * currentIteration_ stores the iteration in which the operator is going to be + * applied + */ + int currentIteration_; + + double mutationProbability_; + + /** + * Performs the operation. + * @param probability Mutation probability + * @param solution The solution to mutate + * @throws JMException + */ + void doMutation(double probability, Solution *solution); + + /** + * Calculates the delta value used in NonUniform mutation operator + */ + double delta(double y, double bMutationParameter); public: - /** - * Constructor. - * Creates a new instance of the non uniform mutation - */ - NonUniformMutation(map parameters); - - /** - * Executes the operation - * @param object An object containing the solution to mutate - */ - void *execute(void *); + /** + * Constructor. + * Creates a new instance of the non uniform mutation + */ + NonUniformMutation(map parameters); + + /** + * Executes the operation + * @param object An object containing the solution to mutate + */ + void *execute(void *); }; // NonUniformMutation diff --git a/src/operators/mutation/PolynomialMutation.cpp b/src/operators/mutation/PolynomialMutation.cpp index 58bd89b..89fdf15 100644 --- a/src/operators/mutation/PolynomialMutation.cpp +++ b/src/operators/mutation/PolynomialMutation.cpp @@ -33,13 +33,14 @@ const double PolynomialMutation::eta_m_ = ETA_M_DEFAULT_; * Creates a new instance of the polynomial mutation operator */ PolynomialMutation::PolynomialMutation(map parameters) -: Mutation(parameters) { - // TODO: mutationProbability_ = NULL; - distributionIndex_ = eta_m_; - if (parameters["probability"] != NULL) - mutationProbability_ = *(double *) parameters["probability"]; - if (parameters["distributionIndex"] != NULL) - distributionIndex_ = *(double *) parameters["distributionIndex"]; + : Mutation(parameters) +{ + // TODO: mutationProbability_ = NULL; + distributionIndex_ = eta_m_; + if (parameters["probability"] != NULL) + mutationProbability_ = *(double *) parameters["probability"]; + if (parameters["distributionIndex"] != NULL) + distributionIndex_ = *(double *) parameters["distributionIndex"]; } // PolynomialMutation @@ -54,39 +55,45 @@ PolynomialMutation::~PolynomialMutation() { } // ~PolynomialMutation * @param probability Mutation probability * @param solution The solution to mutate */ -void * PolynomialMutation::doMutation(double probability, Solution *solution) { - double rnd, delta1, delta2, mut_pow, deltaq; - double y, yl, yu, val, xy; - XReal * x = new XReal(solution); - - for (int var=0; var < solution->getNumberOfVariables(); var++) { - if (PseudoRandom::randDouble() <= probability) { - y = x->getValue(var); - yl = x->getLowerBound(var); - yu = x->getUpperBound(var); - delta1 = (y-yl)/(yu-yl); - delta2 = (yu-y)/(yu-yl); - rnd = PseudoRandom::randDouble(); - mut_pow = 1.0/(distributionIndex_+1.0); - if (rnd <= 0.5) { - xy = 1.0-delta1; - val = 2.0*rnd+(1.0-2.0*rnd)*(pow(xy,(eta_m_+1.0))); - deltaq = pow(val,mut_pow) - 1.0; - } else { - xy = 1.0-delta2; - val = 2.0*(1.0-rnd)+2.0*(rnd-0.5)*(pow(xy,(eta_m_+1.0))); - deltaq = 1.0 - (pow(val,mut_pow)); - } - y = y + deltaq*(yu-yl); - if (yyu) - y = yu; - x->setValue(var, y); - } - } // for +void * PolynomialMutation::doMutation(double probability, Solution *solution) +{ + double rnd, delta1, delta2, mut_pow, deltaq; + double y, yl, yu, val, xy; + XReal * x = new XReal(solution); - delete x; + for (int var=0; var < solution->getNumberOfVariables(); var++) + { + if (PseudoRandom::randDouble() <= probability) + { + y = x->getValue(var); + yl = x->getLowerBound(var); + yu = x->getUpperBound(var); + delta1 = (y-yl)/(yu-yl); + delta2 = (yu-y)/(yu-yl); + rnd = PseudoRandom::randDouble(); + mut_pow = 1.0/(distributionIndex_+1.0); + if (rnd <= 0.5) + { + xy = 1.0-delta1; + val = 2.0*rnd+(1.0-2.0*rnd)*(pow(xy,(eta_m_+1.0))); + deltaq = pow(val,mut_pow) - 1.0; + } + else + { + xy = 1.0-delta2; + val = 2.0*(1.0-rnd)+2.0*(rnd-0.5)*(pow(xy,(eta_m_+1.0))); + deltaq = 1.0 - (pow(val,mut_pow)); + } + y = y + deltaq*(yu-yl); + if (yyu) + y = yu; + x->setValue(var, y); + } + } // for + + delete x; } // doMutation @@ -95,12 +102,13 @@ void * PolynomialMutation::doMutation(double probability, Solution *solution) { * Executes the operation * @param object An object containing a solution * @return An object containing the mutated solution - * @throws JMException - */ -void * PolynomialMutation::execute(void *object) { - Solution *solution = (Solution *)object; - // TODO: VALID_TYPES? - //double probability = *(double *)getParameter("probability"); - doMutation(mutationProbability_,solution); - return solution; + * @throws JMException + */ +void * PolynomialMutation::execute(void *object) +{ + Solution *solution = (Solution *)object; + // TODO: VALID_TYPES? + //double probability = *(double *)getParameter("probability"); + doMutation(mutationProbability_,solution); + return solution; } // execute diff --git a/src/operators/mutation/PolynomialMutation.h b/src/operators/mutation/PolynomialMutation.h index af88bfe..c8dccdd 100644 --- a/src/operators/mutation/PolynomialMutation.h +++ b/src/operators/mutation/PolynomialMutation.h @@ -34,24 +34,25 @@ * @class Mutation * @brief This class implements a polynomial mutation operator. **/ -class PolynomialMutation : public Mutation { +class PolynomialMutation : public Mutation +{ public: - static const double ETA_M_DEFAULT_; - static const double eta_m_; + static const double ETA_M_DEFAULT_; + static const double eta_m_; - PolynomialMutation(map parameters); - ~PolynomialMutation(); + PolynomialMutation(map parameters); + ~PolynomialMutation(); - void * execute(void *); + void * execute(void *); private: - double mutationProbability_; - double distributionIndex_; + double mutationProbability_; + double distributionIndex_; - void * doMutation(double probability, Solution * solution); - // TODO: VALID_TYPES; + void * doMutation(double probability, Solution * solution); + // TODO: VALID_TYPES; }; // PolynomialMutation diff --git a/src/operators/mutation/UniformMutation.cpp b/src/operators/mutation/UniformMutation.cpp index bd19a26..e69da11 100644 --- a/src/operators/mutation/UniformMutation.cpp +++ b/src/operators/mutation/UniformMutation.cpp @@ -34,13 +34,16 @@ const string UniformMutation::VALID_TYPES[] = {"Real", "ArrayReal"}; * Creates a new uniform mutation operator instance */ UniformMutation::UniformMutation(map parameters) -: Mutation(parameters) { - if (parameters["probability"] != NULL) { - mutationProbability_ = *(double *) parameters["probability"]; - } - if (parameters["perturbation"] != NULL) { - perturbation_ = *(double *) parameters["perturbation"]; - } + : Mutation(parameters) +{ + if (parameters["probability"] != NULL) + { + mutationProbability_ = *(double *) parameters["probability"]; + } + if (parameters["perturbation"] != NULL) + { + perturbation_ = *(double *) parameters["perturbation"]; + } } // UniformMutation /** @@ -48,28 +51,34 @@ UniformMutation::UniformMutation(map parameters) * @param probability Mutation probability * @param solution The solution to mutate */ -void UniformMutation::doMutation(double probability, Solution *solution) { +void UniformMutation::doMutation(double probability, Solution *solution) +{ - XReal * x = new XReal(solution); + XReal * x = new XReal(solution); - for (int var=0; var < solution->getNumberOfVariables(); var++) { - if (PseudoRandom::randDouble() < probability) { - double rand = PseudoRandom::randDouble(); - double tmp = (rand - 0.5)*perturbation_; + for (int var=0; var < solution->getNumberOfVariables(); var++) + { + if (PseudoRandom::randDouble() < probability) + { + double rand = PseudoRandom::randDouble(); + double tmp = (rand - 0.5)*perturbation_; - tmp += x->getValue(var); + tmp += x->getValue(var); - if (tmp < x->getLowerBound(var)) { - tmp = x->getLowerBound(var); - } else if (tmp > x->getUpperBound(var)) { - tmp = x->getUpperBound(var); - } + if (tmp < x->getLowerBound(var)) + { + tmp = x->getLowerBound(var); + } + else if (tmp > x->getUpperBound(var)) + { + tmp = x->getUpperBound(var); + } - x->setValue(var, tmp) ; - } // if - } // for + x->setValue(var, tmp) ; + } // if + } // for - delete x; + delete x; } // doMutation @@ -78,9 +87,10 @@ void UniformMutation::doMutation(double probability, Solution *solution) { * @param object An object containing a solution * @return An object containing the mutated solution */ -void *UniformMutation::execute(void *object) { - Solution *solution = (Solution *)object; - // TODO: VALID_TYPES? - doMutation(mutationProbability_,solution); - return solution; +void *UniformMutation::execute(void *object) +{ + Solution *solution = (Solution *)object; + // TODO: VALID_TYPES? + doMutation(mutationProbability_,solution); + return solution; } // execute diff --git a/src/operators/mutation/UniformMutation.h b/src/operators/mutation/UniformMutation.h index 0a38399..88db048 100644 --- a/src/operators/mutation/UniformMutation.h +++ b/src/operators/mutation/UniformMutation.h @@ -29,43 +29,44 @@ /** * This class implements a uniform mutation operator. */ -class UniformMutation : public Mutation { +class UniformMutation : public Mutation +{ private: - /** - * Valid solution types to apply this operator. - */ - static const string VALID_TYPES[]; + /** + * Valid solution types to apply this operator. + */ + static const string VALID_TYPES[]; - /** - * Stores the value used in a uniform mutation operator. - */ - double perturbation_; + /** + * Stores the value used in a uniform mutation operator. + */ + double perturbation_; - double mutationProbability_; + double mutationProbability_; - /** - * Performs the operation. - * @param probability Mutation probability - * @param solution The solution to mutate - * @throws JMException - */ - void doMutation(double probability, Solution *solution); + /** + * Performs the operation. + * @param probability Mutation probability + * @param solution The solution to mutate + * @throws JMException + */ + void doMutation(double probability, Solution *solution); public: - /** - * Constructor. - * Creates a new uniform mutation operator instance. - */ - UniformMutation(map parameters); + /** + * Constructor. + * Creates a new uniform mutation operator instance. + */ + UniformMutation(map parameters); - /** - * Executes the operation - * @param object An object containing the solution to mutate - */ - void *execute(void *); + /** + * Executes the operation + * @param object An object containing the solution to mutate + */ + void *execute(void *); }; // UniformMutation diff --git a/src/operators/selection/BestSolutionSelection.cpp b/src/operators/selection/BestSolutionSelection.cpp index 657b155..7076627 100644 --- a/src/operators/selection/BestSolutionSelection.cpp +++ b/src/operators/selection/BestSolutionSelection.cpp @@ -32,11 +32,13 @@ * Constructor */ BestSolutionSelection::BestSolutionSelection(map parameters) -: Selection(parameters) { - comparator_ = NULL; - if (parameters["comparator"] != NULL) { - comparator_ = (Comparator *) parameters["comparator"]; - } + : Selection(parameters) +{ + comparator_ = NULL; + if (parameters["comparator"] != NULL) + { + comparator_ = (Comparator *) parameters["comparator"]; + } } @@ -45,23 +47,27 @@ BestSolutionSelection::BestSolutionSelection(map parameters) * @param object Object representing a SolutionSet * @return the best solution found */ -void * BestSolutionSelection::execute(void * object) { +void * BestSolutionSelection::execute(void * object) +{ - SolutionSet * solutionSet = (SolutionSet *)object; + SolutionSet * solutionSet = (SolutionSet *)object; - if (solutionSet->size() == 0) { - return NULL; - } + if (solutionSet->size() == 0) + { + return NULL; + } - int bestSolution = 0; + int bestSolution = 0; - for (int i = 1; i < solutionSet->size(); i++) { - if (comparator_->compare(solutionSet->get(i), solutionSet->get(bestSolution)) < 0) { - bestSolution = i; - } - } // for + for (int i = 1; i < solutionSet->size(); i++) + { + if (comparator_->compare(solutionSet->get(i), solutionSet->get(bestSolution)) < 0) + { + bestSolution = i; + } + } // for - int * intPtr = new int(bestSolution); - return intPtr; + int * intPtr = new int(bestSolution); + return intPtr; } // execute diff --git a/src/operators/selection/BestSolutionSelection.h b/src/operators/selection/BestSolutionSelection.h index c3a2322..7f93dde 100644 --- a/src/operators/selection/BestSolutionSelection.h +++ b/src/operators/selection/BestSolutionSelection.h @@ -29,14 +29,15 @@ * This class implements a selection operator used for selecting the best * solution in a SolutionSet according to a given comparator */ -class BestSolutionSelection : public Selection { +class BestSolutionSelection : public Selection +{ private: - Comparator * comparator_; + Comparator * comparator_; public: - BestSolutionSelection(map parameters); - void *execute(void *); + BestSolutionSelection(map parameters); + void *execute(void *); }; diff --git a/src/operators/selection/BinaryTournament.cpp b/src/operators/selection/BinaryTournament.cpp index ecc346d..e0e24c8 100644 --- a/src/operators/selection/BinaryTournament.cpp +++ b/src/operators/selection/BinaryTournament.cpp @@ -33,19 +33,21 @@ * Creates a new Binary tournament operator using a BinaryTournamentComparator */ BinaryTournament::BinaryTournament(map parameters) -: Selection(parameters) { - if (parameters["comparator"] != NULL) - comparator_ = (Comparator *) parameters["comparator"]; - else - comparator_ = new DominanceComparator(); + : Selection(parameters) +{ + if (parameters["comparator"] != NULL) + comparator_ = (Comparator *) parameters["comparator"]; + else + comparator_ = new DominanceComparator(); } // BinaryTournament /** * Destructor */ -BinaryTournament::~BinaryTournament() { - delete comparator_; +BinaryTournament::~BinaryTournament() +{ + delete comparator_; } // ~BinaryTournament @@ -54,30 +56,32 @@ BinaryTournament::~BinaryTournament() { * @param object Object representing a SolutionSet * @return the selected solution */ -void * BinaryTournament::execute(void * object) { +void * BinaryTournament::execute(void * object) +{ - SolutionSet * solutionSet = (SolutionSet *) object; - int index1 = PseudoRandom::randInt(0,solutionSet->size()-1); - int index2 = PseudoRandom::randInt(0,solutionSet->size()-1); + SolutionSet * solutionSet = (SolutionSet *) object; + int index1 = PseudoRandom::randInt(0,solutionSet->size()-1); + int index2 = PseudoRandom::randInt(0,solutionSet->size()-1); - if (solutionSet->size() >= 2) { - while (index1 == index2) { - index2 = PseudoRandom::randInt(0,solutionSet->size()-1); + if (solutionSet->size() >= 2) + { + while (index1 == index2) + { + index2 = PseudoRandom::randInt(0,solutionSet->size()-1); + } } - } - Solution * solution1 = solutionSet->get(index1); - Solution * solution2 = solutionSet->get(index2); + Solution * solution1 = solutionSet->get(index1); + Solution * solution2 = solutionSet->get(index2); - int flag = comparator_->compare(solution1,solution2); - if (flag == -1) - return solution1; - else if (flag == 1) - return solution2; - else - if (PseudoRandom::randDouble()<0.5) - return solution1; + int flag = comparator_->compare(solution1,solution2); + if (flag == -1) + return solution1; + else if (flag == 1) + return solution2; + else if (PseudoRandom::randDouble()<0.5) + return solution1; else - return solution2; + return solution2; } // execute diff --git a/src/operators/selection/BinaryTournament.h b/src/operators/selection/BinaryTournament.h index 9dc94dd..ae5c360 100644 --- a/src/operators/selection/BinaryTournament.h +++ b/src/operators/selection/BinaryTournament.h @@ -30,15 +30,16 @@ /** * This class implements an binary tournament selection operator */ -class BinaryTournament : public Selection { +class BinaryTournament : public Selection +{ private: - Comparator * comparator_; + Comparator * comparator_; public: - BinaryTournament(map parameters); - ~BinaryTournament(); - void *execute(void *); + BinaryTournament(map parameters); + ~BinaryTournament(); + void *execute(void *); }; diff --git a/src/operators/selection/BinaryTournament2.cpp b/src/operators/selection/BinaryTournament2.cpp index 4333794..14a0eac 100644 --- a/src/operators/selection/BinaryTournament2.cpp +++ b/src/operators/selection/BinaryTournament2.cpp @@ -36,64 +36,67 @@ * NSGA-II implementation version) */ BinaryTournament2::BinaryTournament2(map parameters) -: Selection(parameters) { - index_ = 0; - a_ = new int[1]; // Initialized as dummy - dominance_ = new DominanceComparator(); - if (dominance_ == NULL) { - cout << "BinaryTournament::BinaryTournament: error creating comparator" ; - cout << endl ; - exit(-1) ; - } + : Selection(parameters) +{ + index_ = 0; + a_ = new int[1]; // Initialized as dummy + dominance_ = new DominanceComparator(); + if (dominance_ == NULL) + { + cout << "BinaryTournament::BinaryTournament: error creating comparator" ; + cout << endl ; + exit(-1) ; + } } /** * Destructor */ -BinaryTournament2::~BinaryTournament2() { - delete dominance_; - delete [] a_; +BinaryTournament2::~BinaryTournament2() +{ + delete dominance_; + delete [] a_; } // ~BinaryTournament2 - + /** * Performs the operation * @param object Object representing a SolutionSet * @return the selected solution */ -void * BinaryTournament2::execute(void * object) { +void * BinaryTournament2::execute(void * object) +{ - SolutionSet * population = (SolutionSet *)object; + SolutionSet * population = (SolutionSet *)object; - if (index_ == 0) //Create the permutation - { - PermutationUtility * permutationUtility = new PermutationUtility(); - delete [] a_; - a_= permutationUtility->intPermutation(population->size()); - delete permutationUtility; - } - - Solution * solution1; - Solution * solution2; - solution1 = population->get(a_[index_]); - solution2 = population->get(a_[index_+1]); - - index_ = (index_ + 2) % population->size(); - - int flag = dominance_->compare(solution1,solution2); - if (flag == -1) - return solution1; - else if (flag == 1) - return solution2; - else if (solution1->getCrowdingDistance() > solution2->getCrowdingDistance()) - return solution1; - else if (solution2->getCrowdingDistance() > solution1->getCrowdingDistance()) - return solution2; - else - if (PseudoRandom::randDouble()<0.5) - return solution1; + if (index_ == 0) //Create the permutation + { + PermutationUtility * permutationUtility = new PermutationUtility(); + delete [] a_; + a_= permutationUtility->intPermutation(population->size()); + delete permutationUtility; + } + + Solution * solution1; + Solution * solution2; + solution1 = population->get(a_[index_]); + solution2 = population->get(a_[index_+1]); + + index_ = (index_ + 2) % population->size(); + + int flag = dominance_->compare(solution1,solution2); + if (flag == -1) + return solution1; + else if (flag == 1) + return solution2; + else if (solution1->getCrowdingDistance() > solution2->getCrowdingDistance()) + return solution1; + else if (solution2->getCrowdingDistance() > solution1->getCrowdingDistance()) + return solution2; + else if (PseudoRandom::randDouble()<0.5) + return solution1; else - return solution2; + return solution2; -} // execute +} // execute diff --git a/src/operators/selection/BinaryTournament2.h b/src/operators/selection/BinaryTournament2.h index 310a61b..a5acfb1 100644 --- a/src/operators/selection/BinaryTournament2.h +++ b/src/operators/selection/BinaryTournament2.h @@ -33,17 +33,18 @@ * This class implements an operator for binary selections using the same code * in Deb's NSGA-II implementation */ -class BinaryTournament2 : public Selection { +class BinaryTournament2 : public Selection +{ private: - Comparator * dominance_; - int * a_; - int index_; + Comparator * dominance_; + int * a_; + int index_; public: - BinaryTournament2(map parameters); - ~BinaryTournament2(); - void *execute(void *); + BinaryTournament2(map parameters); + ~BinaryTournament2(); + void *execute(void *); }; diff --git a/src/operators/selection/DifferentialEvolutionSelection.cpp b/src/operators/selection/DifferentialEvolutionSelection.cpp index e25fd77..9550da8 100644 --- a/src/operators/selection/DifferentialEvolutionSelection.cpp +++ b/src/operators/selection/DifferentialEvolutionSelection.cpp @@ -33,7 +33,7 @@ * Constructor */ DifferentialEvolutionSelection::DifferentialEvolutionSelection(map parameters) -: Selection(parameters) {} + : Selection(parameters) {} /** @@ -42,34 +42,42 @@ DifferentialEvolutionSelection::DifferentialEvolutionSelection(mapsize() < 4) { - cerr << "DifferentialEvolutionSelection: the population has less than four solutions" << endl; - exit(-1); - } + if (population->size() < 4) + { + cerr << "DifferentialEvolutionSelection: the population has less than four solutions" << endl; + exit(-1); + } - do { - r1 = PseudoRandom::randInt(0,population->size()-1); - } while ( r1==index ); - do { - r2 = PseudoRandom::randInt(0,population->size()-1); - } while ( r2==index || r2==r1 ); - do { - r3 = PseudoRandom::randInt(0,population->size()-1); - } while( r3==index || r3==r1 || r3==r2 ); + do + { + r1 = PseudoRandom::randInt(0,population->size()-1); + } + while ( r1==index ); + do + { + r2 = PseudoRandom::randInt(0,population->size()-1); + } + while ( r2==index || r2==r1 ); + do + { + r3 = PseudoRandom::randInt(0,population->size()-1); + } + while( r3==index || r3==r1 || r3==r2 ); - parents[0] = population->get(r1); - parents[1] = population->get(r2); - parents[2] = population->get(r3); + parents[0] = population->get(r1); + parents[1] = population->get(r2); + parents[2] = population->get(r3); - return parents ; + return parents ; } // execute diff --git a/src/operators/selection/DifferentialEvolutionSelection.h b/src/operators/selection/DifferentialEvolutionSelection.h index 98db269..23e8d67 100644 --- a/src/operators/selection/DifferentialEvolutionSelection.h +++ b/src/operators/selection/DifferentialEvolutionSelection.h @@ -30,11 +30,12 @@ * Class implementing the selection operator used in DE: three different solutions * are returned from a population. */ -class DifferentialEvolutionSelection : public Selection { +class DifferentialEvolutionSelection : public Selection +{ public: - DifferentialEvolutionSelection(map parameters); - void *execute(void *); + DifferentialEvolutionSelection(map parameters); + void *execute(void *); }; diff --git a/src/operators/selection/RandomSelection.cpp b/src/operators/selection/RandomSelection.cpp index 5f86633..5390098 100755 --- a/src/operators/selection/RandomSelection.cpp +++ b/src/operators/selection/RandomSelection.cpp @@ -32,7 +32,8 @@ * Constructor * Creates a new RandomSelection operator using a BinaryTournamentComparator */ -RandomSelection::RandomSelection(map parameters): Selection(parameters) { +RandomSelection::RandomSelection(map parameters): Selection(parameters) +{ } // RandomSelection @@ -47,20 +48,22 @@ RandomSelection::~RandomSelection() { } // ~RandomSelection * @param object Object representing a SolutionSet. * @return an object representing an array with the selected parents */ -void * RandomSelection::execute(void * object) { +void * RandomSelection::execute(void * object) +{ - SolutionSet * population = (SolutionSet *) object; - int pos1 = PseudoRandom::randInt(0,population->size()-1); - int pos2 = PseudoRandom::randInt(0,population->size()-1); + SolutionSet * population = (SolutionSet *) object; + int pos1 = PseudoRandom::randInt(0,population->size()-1); + int pos2 = PseudoRandom::randInt(0,population->size()-1); - while ((pos1 == pos2) && (population->size()>1) ) { - pos2 = PseudoRandom::randInt(0,population->size()-1); - } + while ((pos1 == pos2) && (population->size()>1) ) + { + pos2 = PseudoRandom::randInt(0,population->size()-1); + } - Solution ** parents = new Solution*[2]; - parents[0] = population->get(pos1); - parents[1] = population->get(pos2); - return parents; + Solution ** parents = new Solution*[2]; + parents[0] = population->get(pos1); + parents[1] = population->get(pos2); + return parents; } // execute diff --git a/src/operators/selection/RandomSelection.h b/src/operators/selection/RandomSelection.h index 547fe38..704e787 100755 --- a/src/operators/selection/RandomSelection.h +++ b/src/operators/selection/RandomSelection.h @@ -30,15 +30,16 @@ /** * This class implements an binary tournament selection operator */ -class RandomSelection : public Selection { +class RandomSelection : public Selection +{ private: - Comparator * comparator_; + Comparator * comparator_; public: - RandomSelection(map parameters); - ~RandomSelection(); - void *execute(void *); + RandomSelection(map parameters); + ~RandomSelection(); + void *execute(void *); }; diff --git a/src/operators/selection/Selection.cpp b/src/operators/selection/Selection.cpp index cf847a3..0d9de76 100644 --- a/src/operators/selection/Selection.cpp +++ b/src/operators/selection/Selection.cpp @@ -23,6 +23,6 @@ #include Selection::Selection(map parameters) -: Operator(parameters) {} + : Operator(parameters) {} Selection::~Selection() { /* do nothing */ } diff --git a/src/operators/selection/Selection.h b/src/operators/selection/Selection.h index 7de1178..b4bf53b 100644 --- a/src/operators/selection/Selection.h +++ b/src/operators/selection/Selection.h @@ -29,11 +29,12 @@ * @class Selection * @brief This class is aimed at representing a Selection operator **/ -class Selection : public Operator { +class Selection : public Operator +{ public: - Selection (map parameters); - virtual ~Selection() = 0; + Selection (map parameters); + virtual ~Selection() = 0; }; #endif diff --git a/src/operators/selection/WorstSolutionSelection.cpp b/src/operators/selection/WorstSolutionSelection.cpp index 9d17d8d..4c89ef5 100644 --- a/src/operators/selection/WorstSolutionSelection.cpp +++ b/src/operators/selection/WorstSolutionSelection.cpp @@ -32,11 +32,13 @@ * Constructor */ WorstSolutionSelection::WorstSolutionSelection(map parameters) -: Selection(parameters) { - comparator_ = NULL; - if (parameters["comparator"] != NULL) { - comparator_ = (Comparator *) parameters["comparator"]; - } + : Selection(parameters) +{ + comparator_ = NULL; + if (parameters["comparator"] != NULL) + { + comparator_ = (Comparator *) parameters["comparator"]; + } } @@ -45,23 +47,27 @@ WorstSolutionSelection::WorstSolutionSelection(map parameters) * @param object Object representing a SolutionSet * @return the worst solution found */ -void * WorstSolutionSelection::execute(void * object) { +void * WorstSolutionSelection::execute(void * object) +{ - SolutionSet * solutionSet = (SolutionSet *)object; + SolutionSet * solutionSet = (SolutionSet *)object; - if (solutionSet->size() == 0) { - return NULL; - } + if (solutionSet->size() == 0) + { + return NULL; + } - int worstSolution = 0; + int worstSolution = 0; - for (int i = 1; i < solutionSet->size(); i++) { - if (comparator_->compare(solutionSet->get(i), solutionSet->get(worstSolution)) > 0) { - worstSolution = i; - } - } // for + for (int i = 1; i < solutionSet->size(); i++) + { + if (comparator_->compare(solutionSet->get(i), solutionSet->get(worstSolution)) > 0) + { + worstSolution = i; + } + } // for - int * intPtr = new int(worstSolution); - return intPtr; + int * intPtr = new int(worstSolution); + return intPtr; } // execute diff --git a/src/operators/selection/WorstSolutionSelection.h b/src/operators/selection/WorstSolutionSelection.h index acb3c15..2ba8ae8 100644 --- a/src/operators/selection/WorstSolutionSelection.h +++ b/src/operators/selection/WorstSolutionSelection.h @@ -29,14 +29,15 @@ * This class implements a selection operator used for selecting the worst * solution in a SolutionSet according to a given comparator */ -class WorstSolutionSelection : public Selection { +class WorstSolutionSelection : public Selection +{ private: - Comparator * comparator_; + Comparator * comparator_; public: - WorstSolutionSelection(map parameters); - void *execute(void *); + WorstSolutionSelection(map parameters); + void *execute(void *); }; diff --git a/src/problems/DTLZ/DTLZ1.cpp b/src/problems/DTLZ/DTLZ1.cpp index c9087a2..5c75951 100644 --- a/src/problems/DTLZ/DTLZ1.cpp +++ b/src/problems/DTLZ/DTLZ1.cpp @@ -22,86 +22,96 @@ const double DTLZ1::PI = 3.141592653589793; -DTLZ1::DTLZ1(string solutionType, int numberOfVariables, int numberOfObjectives) { - numberOfVariables_ = numberOfVariables; - numberOfObjectives_ = numberOfObjectives; - numberOfConstraints_ = 0; - problemName_ = "DTLZ1"; - - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } - - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } - - for (int i = 0; i < numberOfVariables_; i++) { - lowerLimit_[i] = 0.0; - upperLimit_[i] = 1.0; - } - - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; - //cout << "Tipo seleccionado Real" << endl; - } - else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; - else { - cout << "Error: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } - - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; +DTLZ1::DTLZ1(string solutionType, int numberOfVariables, int numberOfObjectives) +{ + numberOfVariables_ = numberOfVariables; + numberOfObjectives_ = numberOfObjectives; + numberOfConstraints_ = 0; + problemName_ = "DTLZ1"; + + lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (lowerLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (upperLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + for (int i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = 0.0; + upperLimit_[i] = 1.0; + } + + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + { + solutionType_ = new RealSolutionType(this) ; + //cout << "Tipo seleccionado Real" << endl; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = new ArrayRealSolutionType(this) ; + else + { + cout << "Error: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } + + fx_ = new double[numberOfObjectives_] ; + x_ = new double[numberOfVariables_]; } -DTLZ1::~DTLZ1() { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; - delete [] fx_ ; - delete [] x_ ; +DTLZ1::~DTLZ1() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; + delete [] fx_ ; + delete [] x_ ; } /** * Evaluates a solution * @param solution The solution to evaluate */ -void DTLZ1::evaluate(Solution *solution) { - XReal * vars = new XReal(solution); +void DTLZ1::evaluate(Solution *solution) +{ + XReal * vars = new XReal(solution); - int k = numberOfVariables_ - numberOfObjectives_ + 1; + int k = numberOfVariables_ - numberOfObjectives_ + 1; - for (int i = 0; i < numberOfVariables_; i++) - x_[i] = vars->getValue(i); + for (int i = 0; i < numberOfVariables_; i++) + x_[i] = vars->getValue(i); - double g = 0.0 ; + double g = 0.0 ; - for (int i = numberOfVariables_ - k; i < numberOfVariables_; i++) - g += (x_[i] - 0.5)*(x_[i] - 0.5) - cos(20.0 * PI * (x_[i] - 0.5)); + for (int i = numberOfVariables_ - k; i < numberOfVariables_; i++) + g += (x_[i] - 0.5)*(x_[i] - 0.5) - cos(20.0 * PI * (x_[i] - 0.5)); - g = 100 * (k + g); - for (int i = 0; i < numberOfObjectives_; i++) - fx_[i] = (1.0 + g) * 0.5; + g = 100 * (k + g); + for (int i = 0; i < numberOfObjectives_; i++) + fx_[i] = (1.0 + g) * 0.5; - for (int i = 0; i < numberOfObjectives_; i++){ - for (int j = 0; j < numberOfObjectives_ - (i + 1); j++) - fx_[i] *= x_[j]; - if (i != 0){ - int aux = numberOfObjectives_ - (i + 1); - fx_[i] *= 1 - x_[aux]; - } //if - }//for + for (int i = 0; i < numberOfObjectives_; i++) + { + for (int j = 0; j < numberOfObjectives_ - (i + 1); j++) + fx_[i] *= x_[j]; + if (i != 0) + { + int aux = numberOfObjectives_ - (i + 1); + fx_[i] *= 1 - x_[aux]; + } //if + }//for - for (int i = 0; i < numberOfObjectives_; i++) - solution->setObjective(i, fx_[i]); + for (int i = 0; i < numberOfObjectives_; i++) + solution->setObjective(i, fx_[i]); - delete vars ; + delete vars ; } // evaluate diff --git a/src/problems/DTLZ/DTLZ1.h b/src/problems/DTLZ/DTLZ1.h index 8a675b2..4f47822 100644 --- a/src/problems/DTLZ/DTLZ1.h +++ b/src/problems/DTLZ/DTLZ1.h @@ -29,16 +29,17 @@ #include #include -class DTLZ1 : public Problem { +class DTLZ1 : public Problem +{ public: - DTLZ1(string solutionType, int numberOfVariables = 7, int numberOfObjectives = 3); - void evaluate(Solution *solution); + DTLZ1(string solutionType, int numberOfVariables = 7, int numberOfObjectives = 3); + void evaluate(Solution *solution); - virtual ~DTLZ1(); + virtual ~DTLZ1(); private: - double * fx_ ; - double * x_ ; - static const double PI; + double * fx_ ; + double * x_ ; + static const double PI; }; #endif /* __DTLZ1_H__ */ diff --git a/src/problems/DTLZ/DTLZ2.cpp b/src/problems/DTLZ/DTLZ2.cpp index 5d37339..d4b3baa 100644 --- a/src/problems/DTLZ/DTLZ2.cpp +++ b/src/problems/DTLZ/DTLZ2.cpp @@ -22,83 +22,93 @@ const double DTLZ2::PI = 3.141592653589793; -DTLZ2::DTLZ2(string solutionType, int numberOfVariables, int numberOfObjectives) { - numberOfVariables_ = numberOfVariables; - numberOfObjectives_ = numberOfObjectives; - numberOfConstraints_ = 0; - problemName_ = "DTLZ2"; - - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } - - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } - - for (int i = 0; i < numberOfVariables_; i++) { - lowerLimit_[i] = 0.0; - upperLimit_[i] = 1.0; - } - - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; - //cout << "Tipo seleccionado Real" << endl; - } - else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; - else { - cout << "Error: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } - - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; +DTLZ2::DTLZ2(string solutionType, int numberOfVariables, int numberOfObjectives) +{ + numberOfVariables_ = numberOfVariables; + numberOfObjectives_ = numberOfObjectives; + numberOfConstraints_ = 0; + problemName_ = "DTLZ2"; + + lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (lowerLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (upperLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + for (int i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = 0.0; + upperLimit_[i] = 1.0; + } + + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + { + solutionType_ = new RealSolutionType(this) ; + //cout << "Tipo seleccionado Real" << endl; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = new ArrayRealSolutionType(this) ; + else + { + cout << "Error: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } + + fx_ = new double[numberOfObjectives_] ; + x_ = new double[numberOfVariables_]; } -DTLZ2::~DTLZ2() { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; - delete [] fx_ ; - delete [] x_ ; +DTLZ2::~DTLZ2() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; + delete [] fx_ ; + delete [] x_ ; } /** * Evaluates a solution * @param solution The solution to evaluate */ -void DTLZ2::evaluate(Solution *solution) { - XReal * vars = new XReal(solution); - - int k = numberOfVariables_ - numberOfObjectives_ + 1; - - for (int i = 0; i < numberOfVariables_; i++) - x_[i] = vars->getValue(i); - - double g = 0.0; - for (int i = numberOfVariables_ - k; i < numberOfVariables_; i++) - g += (x_[i] - 0.5)*(x_[i] - 0.5); - - for (int i = 0; i < numberOfObjectives_; i++) - fx_[i] = 1.0 + g; - - for (int i = 0; i < numberOfObjectives_; i++){ - for (int j = 0; j < numberOfObjectives_ - (i + 1); j++) - fx_[i] *= cos(x_[j]*0.5*PI); - if (i != 0){ - int aux = numberOfObjectives_ - (i + 1); - fx_[i] *= sin(x_[aux]*0.5*PI); - } //if - } // for - for (int i = 0; i < numberOfObjectives_; i++) - solution->setObjective(i, fx_[i]); - - delete vars ; +void DTLZ2::evaluate(Solution *solution) +{ + XReal * vars = new XReal(solution); + + int k = numberOfVariables_ - numberOfObjectives_ + 1; + + for (int i = 0; i < numberOfVariables_; i++) + x_[i] = vars->getValue(i); + + double g = 0.0; + for (int i = numberOfVariables_ - k; i < numberOfVariables_; i++) + g += (x_[i] - 0.5)*(x_[i] - 0.5); + + for (int i = 0; i < numberOfObjectives_; i++) + fx_[i] = 1.0 + g; + + for (int i = 0; i < numberOfObjectives_; i++) + { + for (int j = 0; j < numberOfObjectives_ - (i + 1); j++) + fx_[i] *= cos(x_[j]*0.5*PI); + if (i != 0) + { + int aux = numberOfObjectives_ - (i + 1); + fx_[i] *= sin(x_[aux]*0.5*PI); + } //if + } // for + for (int i = 0; i < numberOfObjectives_; i++) + solution->setObjective(i, fx_[i]); + + delete vars ; } // evaluate diff --git a/src/problems/DTLZ/DTLZ2.h b/src/problems/DTLZ/DTLZ2.h index 959af8c..7c1d4e3 100644 --- a/src/problems/DTLZ/DTLZ2.h +++ b/src/problems/DTLZ/DTLZ2.h @@ -29,16 +29,17 @@ #include #include -class DTLZ2 : public Problem { +class DTLZ2 : public Problem +{ public: - DTLZ2(string solutionType, int numberOfVariables = 12, int numberOfObjectives = 3); - void evaluate(Solution *solution); + DTLZ2(string solutionType, int numberOfVariables = 12, int numberOfObjectives = 3); + void evaluate(Solution *solution); - virtual ~DTLZ2(); + virtual ~DTLZ2(); private: - double * fx_ ; - double * x_ ; - static const double PI; + double * fx_ ; + double * x_ ; + static const double PI; }; #endif /* __DTLZ2_H__ */ diff --git a/src/problems/DTLZ/DTLZ3.cpp b/src/problems/DTLZ/DTLZ3.cpp index d5e8a46..f8a3ec9 100644 --- a/src/problems/DTLZ/DTLZ3.cpp +++ b/src/problems/DTLZ/DTLZ3.cpp @@ -22,79 +22,89 @@ const double DTLZ3::PI = 3.141592653589793; -DTLZ3::DTLZ3(string solutionType, int numberOfVariables, int numberOfObjectives) { - numberOfVariables_ = numberOfVariables; - numberOfObjectives_ = numberOfObjectives; - numberOfConstraints_ = 0; - problemName_ = "DTLZ3"; +DTLZ3::DTLZ3(string solutionType, int numberOfVariables, int numberOfObjectives) +{ + numberOfVariables_ = numberOfVariables; + numberOfObjectives_ = numberOfObjectives; + numberOfConstraints_ = 0; + problemName_ = "DTLZ3"; - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } + lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (lowerLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } + upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (upperLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } - for (int i = 0; i < numberOfVariables_; i++) { - lowerLimit_[i] = 0.0; - upperLimit_[i] = 1.0; - } + for (int i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = 0.0; + upperLimit_[i] = 1.0; + } - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; - // cout << "Tipo seleccionado Real" << endl; - } - else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; - else { - cout << "Error: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + { + solutionType_ = new RealSolutionType(this) ; + // cout << "Tipo seleccionado Real" << endl; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = new ArrayRealSolutionType(this) ; + else + { + cout << "Error: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } + fx_ = new double[numberOfObjectives_] ; + x_ = new double[numberOfVariables_]; } -DTLZ3::~DTLZ3() { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; +DTLZ3::~DTLZ3() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; } /** * Evaluates a solution * @param solution The solution to evaluate */ -void DTLZ3::evaluate(Solution *solution) { - XReal * vars = new XReal(solution); +void DTLZ3::evaluate(Solution *solution) +{ + XReal * vars = new XReal(solution); - int k = numberOfVariables_ - numberOfObjectives_ + 1; + int k = numberOfVariables_ - numberOfObjectives_ + 1; - for (int i = 0; i < numberOfVariables_; i++) - x_[i] = vars->getValue(i); + for (int i = 0; i < numberOfVariables_; i++) + x_[i] = vars->getValue(i); - double g = 0.0; - for (int i = numberOfVariables_ - k; i < numberOfVariables_; i++) - g += (x_[i] - 0.5)*(x_[i] - 0.5) - cos(20.0 * PI * (x_[i] - 0.5)); + double g = 0.0; + for (int i = numberOfVariables_ - k; i < numberOfVariables_; i++) + g += (x_[i] - 0.5)*(x_[i] - 0.5) - cos(20.0 * PI * (x_[i] - 0.5)); - g = 100.0 * (k + g); - for (int i = 0; i < numberOfObjectives_; i++) - fx_[i] = 1.0 + g; + g = 100.0 * (k + g); + for (int i = 0; i < numberOfObjectives_; i++) + fx_[i] = 1.0 + g; - for (int i = 0; i < numberOfObjectives_; i++){ - for (int j = 0; j < numberOfObjectives_ - (i + 1); j++) - fx_[i] *= cos(x_[j]*0.5*PI); - if (i != 0){ - int aux = numberOfObjectives_ - (i + 1); - fx_[i] *= sin(x_[aux]*0.5*PI); - } // if - } //for + for (int i = 0; i < numberOfObjectives_; i++) + { + for (int j = 0; j < numberOfObjectives_ - (i + 1); j++) + fx_[i] *= cos(x_[j]*0.5*PI); + if (i != 0) + { + int aux = numberOfObjectives_ - (i + 1); + fx_[i] *= sin(x_[aux]*0.5*PI); + } // if + } //for - delete vars ; + delete vars ; } // evaluate diff --git a/src/problems/DTLZ/DTLZ3.h b/src/problems/DTLZ/DTLZ3.h index dbfec09..bc884ab 100644 --- a/src/problems/DTLZ/DTLZ3.h +++ b/src/problems/DTLZ/DTLZ3.h @@ -29,16 +29,17 @@ #include #include -class DTLZ3 : public Problem { +class DTLZ3 : public Problem +{ public: - DTLZ3(string solutionType, int numberOfVariables = 12, int numberOfObjectives = 3); - void evaluate(Solution *solution); + DTLZ3(string solutionType, int numberOfVariables = 12, int numberOfObjectives = 3); + void evaluate(Solution *solution); - virtual ~DTLZ3(); + virtual ~DTLZ3(); private: - double * fx_ ; - double * x_ ; - static const double PI ; + double * fx_ ; + double * x_ ; + static const double PI ; }; #endif /* __DTLZ3_H__ */ diff --git a/src/problems/DTLZ/DTLZ4.cpp b/src/problems/DTLZ/DTLZ4.cpp index 673a34c..1abb340 100644 --- a/src/problems/DTLZ/DTLZ4.cpp +++ b/src/problems/DTLZ/DTLZ4.cpp @@ -22,83 +22,93 @@ const double DTLZ4::PI = 3.141592653589793; -DTLZ4::DTLZ4(string solutionType, int numberOfVariables, int numberOfObjectives) { - numberOfVariables_ = numberOfVariables; - numberOfObjectives_ = numberOfObjectives; - numberOfConstraints_ = 0; - problemName_ = "DTLZ4"; - - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } - - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } - - for (int i = 0; i < numberOfVariables_; i++) { - lowerLimit_[i] = 0.0; - upperLimit_[i] = 1.0; - } - - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; - // cout << "Tipo seleccionado Real" << endl; - } - else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; - else { - cout << "Error: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } - - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; +DTLZ4::DTLZ4(string solutionType, int numberOfVariables, int numberOfObjectives) +{ + numberOfVariables_ = numberOfVariables; + numberOfObjectives_ = numberOfObjectives; + numberOfConstraints_ = 0; + problemName_ = "DTLZ4"; + + lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (lowerLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (upperLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + for (int i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = 0.0; + upperLimit_[i] = 1.0; + } + + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + { + solutionType_ = new RealSolutionType(this) ; + // cout << "Tipo seleccionado Real" << endl; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = new ArrayRealSolutionType(this) ; + else + { + cout << "Error: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } + + fx_ = new double[numberOfObjectives_] ; + x_ = new double[numberOfVariables_]; } -DTLZ4::~DTLZ4() { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; +DTLZ4::~DTLZ4() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; } /** * Evaluates a solution * @param solution The solution to evaluate */ -void DTLZ4::evaluate(Solution *solution) { - XReal * vars = new XReal(solution); - - int k = numberOfVariables_ - numberOfObjectives_ + 1; - double alpha = 100.0; - - for (int i = 0; i < numberOfVariables_; i++) - x_[i] = vars->getValue(i); - - double g = 0.0; - for (int i = numberOfVariables_ - k; i < numberOfVariables_; i++) - g += (x_[i] - 0.5)*(x_[i] - 0.5); - - for (int i = 0; i < numberOfObjectives_; i++) - fx_[i] = 1.0 + g; - - for (int i = 0; i < numberOfObjectives_; i++) { - for (int j = 0; j < numberOfObjectives_ - (i + 1); j++) - fx_[i] *= cos(pow(x_[j],alpha)*(PI/2.0)); - if (i != 0){ - int aux = numberOfObjectives_ - (i + 1); - fx_[i] *= sin(pow(x_[aux],alpha)*(PI/2.0)); - } //if - } // for - - for (int i = 0; i < numberOfObjectives_; i++) - solution->setObjective(i, fx_[i]); - - delete vars ; +void DTLZ4::evaluate(Solution *solution) +{ + XReal * vars = new XReal(solution); + + int k = numberOfVariables_ - numberOfObjectives_ + 1; + double alpha = 100.0; + + for (int i = 0; i < numberOfVariables_; i++) + x_[i] = vars->getValue(i); + + double g = 0.0; + for (int i = numberOfVariables_ - k; i < numberOfVariables_; i++) + g += (x_[i] - 0.5)*(x_[i] - 0.5); + + for (int i = 0; i < numberOfObjectives_; i++) + fx_[i] = 1.0 + g; + + for (int i = 0; i < numberOfObjectives_; i++) + { + for (int j = 0; j < numberOfObjectives_ - (i + 1); j++) + fx_[i] *= cos(pow(x_[j],alpha)*(PI/2.0)); + if (i != 0) + { + int aux = numberOfObjectives_ - (i + 1); + fx_[i] *= sin(pow(x_[aux],alpha)*(PI/2.0)); + } //if + } // for + + for (int i = 0; i < numberOfObjectives_; i++) + solution->setObjective(i, fx_[i]); + + delete vars ; } // evaluate diff --git a/src/problems/DTLZ/DTLZ4.h b/src/problems/DTLZ/DTLZ4.h index 0b90fe2..4ec73a5 100644 --- a/src/problems/DTLZ/DTLZ4.h +++ b/src/problems/DTLZ/DTLZ4.h @@ -29,16 +29,17 @@ #include #include -class DTLZ4 : public Problem { +class DTLZ4 : public Problem +{ public: - DTLZ4(string solutionType, int numberOfVariables = 12, int numberOfObjectives = 3); - void evaluate(Solution *solution); + DTLZ4(string solutionType, int numberOfVariables = 12, int numberOfObjectives = 3); + void evaluate(Solution *solution); - virtual ~DTLZ4(); + virtual ~DTLZ4(); private: - double * fx_ ; - double * x_ ; - static const double PI ; + double * fx_ ; + double * x_ ; + static const double PI ; }; #endif /* __DTLZ4_H__ */ diff --git a/src/problems/DTLZ/DTLZ5.cpp b/src/problems/DTLZ/DTLZ5.cpp index 2acf331..90ee86d 100644 --- a/src/problems/DTLZ/DTLZ5.cpp +++ b/src/problems/DTLZ/DTLZ5.cpp @@ -22,91 +22,101 @@ const double DTLZ5::PI = 3.141592653589793; -DTLZ5::DTLZ5(string solutionType, int numberOfVariables, int numberOfObjectives) { - numberOfVariables_ = numberOfVariables; - numberOfObjectives_ = numberOfObjectives; - numberOfConstraints_ = 0; - problemName_ = "DTLZ5"; - - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } - - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } - - for (int i = 0; i < numberOfVariables_; i++) { - lowerLimit_[i] = 0.0; - upperLimit_[i] = 1.0; - } - - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; - //cout << "Tipo seleccionado Real" << endl; - } - else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; - else { - cout << "Error: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } - - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; - theta_ = new double[numberOfObjectives_-1]; +DTLZ5::DTLZ5(string solutionType, int numberOfVariables, int numberOfObjectives) +{ + numberOfVariables_ = numberOfVariables; + numberOfObjectives_ = numberOfObjectives; + numberOfConstraints_ = 0; + problemName_ = "DTLZ5"; + + lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (lowerLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (upperLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + for (int i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = 0.0; + upperLimit_[i] = 1.0; + } + + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + { + solutionType_ = new RealSolutionType(this) ; + //cout << "Tipo seleccionado Real" << endl; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = new ArrayRealSolutionType(this) ; + else + { + cout << "Error: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } + + fx_ = new double[numberOfObjectives_] ; + x_ = new double[numberOfVariables_]; + theta_ = new double[numberOfObjectives_-1]; } -DTLZ5::~DTLZ5() { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; - delete [] theta_ ; +DTLZ5::~DTLZ5() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; + delete [] theta_ ; } /** * Evaluates a solution * @param solution The solution to evaluate */ -void DTLZ5::evaluate(Solution *solution) { - XReal * vars = new XReal(solution); - double g = 0.0; +void DTLZ5::evaluate(Solution *solution) +{ + XReal * vars = new XReal(solution); + double g = 0.0; - int k = numberOfVariables_ - numberOfObjectives_ + 1; - double alpha = 100.0; + int k = numberOfVariables_ - numberOfObjectives_ + 1; + double alpha = 100.0; - for (int i = 0; i < numberOfVariables_; i++) - x_[i] = vars->getValue(i); + for (int i = 0; i < numberOfVariables_; i++) + x_[i] = vars->getValue(i); - for (int i = numberOfVariables_ - k; i < numberOfVariables_; i++) - g += (x_[i] - 0.5)*(x_[i] - 0.5); + for (int i = numberOfVariables_ - k; i < numberOfVariables_; i++) + g += (x_[i] - 0.5)*(x_[i] - 0.5); - double t = PI / (4.0 * (1.0 + g)); + double t = PI / (4.0 * (1.0 + g)); - theta_[0] = x_[0] * PI / 2.0; - for (int i = 1; i < (numberOfObjectives_-1); i++) - theta_[i] = t * (1.0 + 2.0 * g * x_[i]); + theta_[0] = x_[0] * PI / 2.0; + for (int i = 1; i < (numberOfObjectives_-1); i++) + theta_[i] = t * (1.0 + 2.0 * g * x_[i]); - for (int i = 0; i < numberOfObjectives_; i++) - fx_[i] = 1.0 + g; + for (int i = 0; i < numberOfObjectives_; i++) + fx_[i] = 1.0 + g; - for (int i = 0; i < numberOfObjectives_; i++){ - for (int j = 0; j < numberOfObjectives_ - (i + 1); j++) - fx_[i] *= cos(theta_[j]); - if (i != 0){ - int aux = numberOfObjectives_ - (i + 1); - fx_[i] *= sin(theta_[aux]); - } // if - } //for + for (int i = 0; i < numberOfObjectives_; i++) + { + for (int j = 0; j < numberOfObjectives_ - (i + 1); j++) + fx_[i] *= cos(theta_[j]); + if (i != 0) + { + int aux = numberOfObjectives_ - (i + 1); + fx_[i] *= sin(theta_[aux]); + } // if + } //for - for (int i = 0; i < numberOfObjectives_; i++) - solution->setObjective(i, fx_[i]); + for (int i = 0; i < numberOfObjectives_; i++) + solution->setObjective(i, fx_[i]); - delete vars ; + delete vars ; } // evaluate diff --git a/src/problems/DTLZ/DTLZ5.h b/src/problems/DTLZ/DTLZ5.h index 3ecfad3..de0777d 100644 --- a/src/problems/DTLZ/DTLZ5.h +++ b/src/problems/DTLZ/DTLZ5.h @@ -29,18 +29,19 @@ #include #include -class DTLZ5 : public Problem { +class DTLZ5 : public Problem +{ public: - DTLZ5(string solutionType, int numberOfVariables = 12, int numberOfObjectives = 3); - void evaluate(Solution *solution); + DTLZ5(string solutionType, int numberOfVariables = 12, int numberOfObjectives = 3); + void evaluate(Solution *solution); - virtual ~DTLZ5(); + virtual ~DTLZ5(); private: - double * fx_ ; - double * x_ ; - double * theta_ ; - private: - static const double PI ; + double * fx_ ; + double * x_ ; + double * theta_ ; +private: + static const double PI ; }; #endif /* __DTLZ5_H__ */ diff --git a/src/problems/DTLZ/DTLZ6.cpp b/src/problems/DTLZ/DTLZ6.cpp index 760cbe0..f29ac75 100644 --- a/src/problems/DTLZ/DTLZ6.cpp +++ b/src/problems/DTLZ/DTLZ6.cpp @@ -22,91 +22,101 @@ const double DTLZ6::PI = 3.141592653589793; -DTLZ6::DTLZ6(string solutionType, int numberOfVariables, int numberOfObjectives) { - numberOfVariables_ = numberOfVariables; - numberOfObjectives_ = numberOfObjectives; - numberOfConstraints_ = 0; - problemName_ = "DTLZ6"; - - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } - - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } - - for (int i = 0; i < numberOfVariables_; i++) { - lowerLimit_[i] = 0.0; - upperLimit_[i] = 1.0; - } - - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; - //cout << "Tipo seleccionado Real" << endl; - } - else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; - else { - cout << "Error: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } - - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; - theta_ = new double[numberOfObjectives_-1]; +DTLZ6::DTLZ6(string solutionType, int numberOfVariables, int numberOfObjectives) +{ + numberOfVariables_ = numberOfVariables; + numberOfObjectives_ = numberOfObjectives; + numberOfConstraints_ = 0; + problemName_ = "DTLZ6"; + + lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (lowerLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (upperLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + for (int i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = 0.0; + upperLimit_[i] = 1.0; + } + + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + { + solutionType_ = new RealSolutionType(this) ; + //cout << "Tipo seleccionado Real" << endl; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = new ArrayRealSolutionType(this) ; + else + { + cout << "Error: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } + + fx_ = new double[numberOfObjectives_] ; + x_ = new double[numberOfVariables_]; + theta_ = new double[numberOfObjectives_-1]; } -DTLZ6::~DTLZ6() { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; - delete [] theta_ ; +DTLZ6::~DTLZ6() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; + delete [] theta_ ; } /** * Evaluates a solution * @param solution The solution to evaluate */ -void DTLZ6::evaluate(Solution *solution) { - XReal * vars = new XReal(solution); - double g = 0.0; +void DTLZ6::evaluate(Solution *solution) +{ + XReal * vars = new XReal(solution); + double g = 0.0; - int k = numberOfVariables_ - numberOfObjectives_ + 1; - double alpha = 100.0; + int k = numberOfVariables_ - numberOfObjectives_ + 1; + double alpha = 100.0; - for (int i = 0; i < numberOfVariables_; i++) - x_[i] = vars->getValue(i); + for (int i = 0; i < numberOfVariables_; i++) + x_[i] = vars->getValue(i); - for (int i = numberOfVariables_ - k; i < numberOfVariables_; i++) - g += pow(x_[i],0.1); + for (int i = numberOfVariables_ - k; i < numberOfVariables_; i++) + g += pow(x_[i],0.1); - double t = PI / (4.0 * (1.0 + g)); + double t = PI / (4.0 * (1.0 + g)); - theta_[0] = x_[0] * PI / 2.0; - for (int i = 1; i < (numberOfObjectives_-1); i++) - theta_[i] = t * (1.0 + 2.0 * g * x_[i]); + theta_[0] = x_[0] * PI / 2.0; + for (int i = 1; i < (numberOfObjectives_-1); i++) + theta_[i] = t * (1.0 + 2.0 * g * x_[i]); - for (int i = 0; i < numberOfObjectives_; i++) - fx_[i] = 1.0 + g; + for (int i = 0; i < numberOfObjectives_; i++) + fx_[i] = 1.0 + g; - for (int i = 0; i < numberOfObjectives_; i++){ - for (int j = 0; j < numberOfObjectives_ - (i + 1); j++) - fx_[i] *= cos(theta_[j]); - if (i != 0){ - int aux = numberOfObjectives_ - (i + 1); - fx_[i] *= sin(theta_[aux]); - } // if - } //for + for (int i = 0; i < numberOfObjectives_; i++) + { + for (int j = 0; j < numberOfObjectives_ - (i + 1); j++) + fx_[i] *= cos(theta_[j]); + if (i != 0) + { + int aux = numberOfObjectives_ - (i + 1); + fx_[i] *= sin(theta_[aux]); + } // if + } //for - for (int i = 0; i < numberOfObjectives_; i++) - solution->setObjective(i, fx_[i]); + for (int i = 0; i < numberOfObjectives_; i++) + solution->setObjective(i, fx_[i]); - delete vars ; + delete vars ; } // evaluate diff --git a/src/problems/DTLZ/DTLZ6.h b/src/problems/DTLZ/DTLZ6.h index 49153c3..d9cabcd 100644 --- a/src/problems/DTLZ/DTLZ6.h +++ b/src/problems/DTLZ/DTLZ6.h @@ -29,17 +29,18 @@ #include #include -class DTLZ6 : public Problem { +class DTLZ6 : public Problem +{ public: - DTLZ6(string solutionType, int numberOfVariables = 12, int numberOfObjectives = 2); - void evaluate(Solution *solution); + DTLZ6(string solutionType, int numberOfVariables = 12, int numberOfObjectives = 2); + void evaluate(Solution *solution); - virtual ~DTLZ6(); + virtual ~DTLZ6(); private: - double * fx_ ; - double * x_ ; - double * theta_ ; - static const double PI ; + double * fx_ ; + double * x_ ; + double * theta_ ; + static const double PI ; }; #endif /* __DTLZ6_H__ */ diff --git a/src/problems/DTLZ/DTLZ7.cpp b/src/problems/DTLZ/DTLZ7.cpp index 8fd4ed9..90c1cf7 100644 --- a/src/problems/DTLZ/DTLZ7.cpp +++ b/src/problems/DTLZ/DTLZ7.cpp @@ -22,86 +22,95 @@ const double DTLZ7::PI = 3.141592653589793; -DTLZ7::DTLZ7(string solutionType, int numberOfVariables, int numberOfObjectives) { - numberOfVariables_ = numberOfVariables; - numberOfObjectives_ = numberOfObjectives; - numberOfConstraints_ = 0; - problemName_ = "DTLZ7"; - - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } - - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } - - for (int i = 0; i < numberOfVariables_; i++) { - lowerLimit_[i] = 0.0; - upperLimit_[i] = 1.0; - } - - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; - //cout << "Tipo seleccionado Real" << endl; - } - else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; - else { - cout << "Error: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } - - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; +DTLZ7::DTLZ7(string solutionType, int numberOfVariables, int numberOfObjectives) +{ + numberOfVariables_ = numberOfVariables; + numberOfObjectives_ = numberOfObjectives; + numberOfConstraints_ = 0; + problemName_ = "DTLZ7"; + + lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (lowerLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (upperLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + for (int i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = 0.0; + upperLimit_[i] = 1.0; + } + + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + { + solutionType_ = new RealSolutionType(this) ; + //cout << "Tipo seleccionado Real" << endl; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = new ArrayRealSolutionType(this) ; + else + { + cout << "Error: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } + + fx_ = new double[numberOfObjectives_] ; + x_ = new double[numberOfVariables_]; } -DTLZ7::~DTLZ7() { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; +DTLZ7::~DTLZ7() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; } /** * Evaluates a solution * @param solution The solution to evaluate */ -void DTLZ7::evaluate(Solution *solution) { - XReal * vars = new XReal(solution); - double g = 0.0; +void DTLZ7::evaluate(Solution *solution) +{ + XReal * vars = new XReal(solution); + double g = 0.0; - int k = numberOfVariables_ - numberOfObjectives_ + 1; - double alpha = 100.0; + int k = numberOfVariables_ - numberOfObjectives_ + 1; + double alpha = 100.0; - for (int i = 0; i < numberOfVariables_; i++) - x_[i] = vars->getValue(i); + for (int i = 0; i < numberOfVariables_; i++) + x_[i] = vars->getValue(i); - for (int i = numberOfVariables_ - k; i < numberOfVariables_; i++) - g += x_[i] ; + for (int i = numberOfVariables_ - k; i < numberOfVariables_; i++) + g += x_[i] ; - g = 1 + (9.0 * g)/k ; + g = 1 + (9.0 * g)/k ; - for (int i = 0; i < numberOfObjectives_ - 1; i++) - fx_[i] = x_[i] ; + for (int i = 0; i < numberOfObjectives_ - 1; i++) + fx_[i] = x_[i] ; - double h = 0.0 ; - for (int i = 0; i < numberOfObjectives_ - 1; i++){ - h+=(fx_[i]/(1.0+g))*(1 + sin(3.0*PI*fx_[i])) ; - } //for + double h = 0.0 ; + for (int i = 0; i < numberOfObjectives_ - 1; i++) + { + h+=(fx_[i]/(1.0+g))*(1 + sin(3.0*PI*fx_[i])) ; + } //for - h = numberOfObjectives_ - h ; + h = numberOfObjectives_ - h ; - fx_[numberOfObjectives_ - 1] = (1+g)*h ; + fx_[numberOfObjectives_ - 1] = (1+g)*h ; - for (int i = 0; i < numberOfObjectives_; i++) - solution->setObjective(i, fx_[i]); + for (int i = 0; i < numberOfObjectives_; i++) + solution->setObjective(i, fx_[i]); - delete vars ; + delete vars ; } // evaluate diff --git a/src/problems/DTLZ/DTLZ7.h b/src/problems/DTLZ/DTLZ7.h index 01bd0d5..9d2ce0e 100644 --- a/src/problems/DTLZ/DTLZ7.h +++ b/src/problems/DTLZ/DTLZ7.h @@ -29,16 +29,17 @@ #include #include -class DTLZ7 : public Problem { +class DTLZ7 : public Problem +{ public: - DTLZ7(string solutionType, int numberOfVariables = 12, int numberOfObjectives = 3); - void evaluate(Solution *solution); + DTLZ7(string solutionType, int numberOfVariables = 12, int numberOfObjectives = 3); + void evaluate(Solution *solution); - virtual ~DTLZ7(); + virtual ~DTLZ7(); private: - double * fx_ ; - double * x_ ; - static const double PI ; + double * fx_ ; + double * x_ ; + static const double PI ; }; #endif /* __DTLZ7_H__ */ diff --git a/src/problems/Fonseca.cpp b/src/problems/Fonseca.cpp index 5183ad5..fa73bb8 100644 --- a/src/problems/Fonseca.cpp +++ b/src/problems/Fonseca.cpp @@ -3,7 +3,7 @@ // Authors: // Antonio J. Nebro // Juan J. Durillo -// +// // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // // This program is free software: you can redistribute it and/or modify @@ -15,103 +15,119 @@ // 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 program. If not, see . #include - + /** * Class constructor */ -Fonseca::Fonseca(string solutionType) { - numberOfVariables_ = 3; - numberOfObjectives_ = 2; - numberOfConstraints_ = 0; - problemName_ = "Fonseca"; - - lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) { - cout << "Fonseca::Fonseca. Error reserving memory for storing the array of lower limits" << endl; - } // if - - upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) { - cout << "Fonseca::Fonseca. Error reserving memory for storing the array of upper limits" << endl; - exit(-1) ; - } // if - - for (int i = 0; i < numberOfVariables_; i++) { - lowerLimit_[i] = -4.0; - upperLimit_[i] = 4.0; - } // for - - if (solutionType.compare("BinaryReal") == 0) { - //cout << "Selected solution type: BinaryReal" << endl; - solutionType_ = new BinaryRealSolutionType(this) ; - } else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; - //cout << "Selected solution type: Real" << endl; - } else if (solutionType.compare("ArrayReal") == 0) { - solutionType_ = new ArrayRealSolutionType(this) ; - } else { - cout << "Error: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } +Fonseca::Fonseca(string solutionType) +{ + numberOfVariables_ = 3; + numberOfObjectives_ = 2; + numberOfConstraints_ = 0; + problemName_ = "Fonseca"; + + lowerLimit_ = new double[numberOfVariables_]; + if (lowerLimit_ == NULL) + { + cout << "Fonseca::Fonseca. Error reserving memory for storing the array of lower limits" << endl; + } // if + + upperLimit_ = new double[numberOfVariables_]; + if (upperLimit_ == NULL) + { + cout << "Fonseca::Fonseca. Error reserving memory for storing the array of upper limits" << endl; + exit(-1) ; + } // if + + for (int i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = -4.0; + upperLimit_[i] = 4.0; + } // for + + if (solutionType.compare("BinaryReal") == 0) + { + //cout << "Selected solution type: BinaryReal" << endl; + solutionType_ = new BinaryRealSolutionType(this) ; + } + else if (solutionType.compare("Real") == 0) + { + solutionType_ = new RealSolutionType(this) ; + //cout << "Selected solution type: Real" << endl; + } + else if (solutionType.compare("ArrayReal") == 0) + { + solutionType_ = new ArrayRealSolutionType(this) ; + } + else + { + cout << "Error: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } } // Fonseca /** * Destructor */ -Fonseca::~Fonseca() { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; +Fonseca::~Fonseca() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; } // ~Fonseca /** * Evaluates a solution */ -void Fonseca::evaluate(Solution *solution) { - double *fx; - double *x ; - Variable **variables = solution->getDecisionVariables(); - - fx = new double[numberOfObjectives_]; - if (fx == NULL) { - cout << "Fonseca::evaluate: Error reserving memory for the function values array" << endl; - exit(-1); - } // if - - x = new double[numberOfVariables_]; - if (x == NULL) { - cout << "Fonseca::evaluate: Error reserving memory for the variable values array" << endl; - exit(-1); - } // if - - for (int i = 0; i < numberOfVariables_; i++) - x[i] = variables[i]->getValue() ; - - double sum1 = 0.0 ; - for (int i = 0; i < numberOfVariables_; i++) - sum1 += pow(x[i] - (1.0/sqrt((double)numberOfVariables_)),2.0); - - double exp1 = exp((-1.0)*sum1); - fx[0] = 1 - exp1; - - double sum2 = 0.0; - for (int i = 0; i < numberOfVariables_; i++){ - sum2 += pow(x[i] + (1.0/sqrt((double)numberOfVariables_)),2.0); - } - double exp2 = exp((-1.0)*sum2); - fx[1] = 1 - exp2; - - solution->setObjective(0,fx[0]); - solution->setObjective(1,fx[1]); - - delete[]fx ; - delete[]x ; +void Fonseca::evaluate(Solution *solution) +{ + double *fx; + double *x ; + Variable **variables = solution->getDecisionVariables(); + + fx = new double[numberOfObjectives_]; + if (fx == NULL) + { + cout << "Fonseca::evaluate: Error reserving memory for the function values array" << endl; + exit(-1); + } // if + + x = new double[numberOfVariables_]; + if (x == NULL) + { + cout << "Fonseca::evaluate: Error reserving memory for the variable values array" << endl; + exit(-1); + } // if + + for (int i = 0; i < numberOfVariables_; i++) + x[i] = variables[i]->getValue() ; + + double sum1 = 0.0 ; + for (int i = 0; i < numberOfVariables_; i++) + sum1 += pow(x[i] - (1.0/sqrt((double)numberOfVariables_)),2.0); + + double exp1 = exp((-1.0)*sum1); + fx[0] = 1 - exp1; + + double sum2 = 0.0; + for (int i = 0; i < numberOfVariables_; i++) + { + sum2 += pow(x[i] + (1.0/sqrt((double)numberOfVariables_)),2.0); + } + double exp2 = exp((-1.0)*sum2); + fx[1] = 1 - exp2; + + solution->setObjective(0,fx[0]); + solution->setObjective(1,fx[1]); + + delete[]fx ; + delete[]x ; } // evaluate diff --git a/src/problems/Fonseca.h b/src/problems/Fonseca.h index 811ebd9..0d467e8 100644 --- a/src/problems/Fonseca.h +++ b/src/problems/Fonseca.h @@ -3,7 +3,7 @@ // Authors: // Antonio J. Nebro // Juan J. Durillo -// +// // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // // This program is free software: you can redistribute it and/or modify @@ -15,7 +15,7 @@ // 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 program. If not, see . @@ -33,11 +33,12 @@ * @class Fonseca * @brief Class representing problem Fonseca **/ -class Fonseca : public Problem { +class Fonseca : public Problem +{ public: - Fonseca(string solutionType); - ~Fonseca(); - void evaluate(Solution *solution); + Fonseca(string solutionType); + ~Fonseca(); + void evaluate(Solution *solution); }; #endif diff --git a/src/problems/Kursawe.cpp b/src/problems/Kursawe.cpp index ca8be1e..e14d113 100644 --- a/src/problems/Kursawe.cpp +++ b/src/problems/Kursawe.cpp @@ -36,51 +36,58 @@ * @param numberOfVariables Number of variables of the problem * @param solutionType The solution type must "Real", "BinaryReal, and "ArrayReal". */ -Kursawe::Kursawe(string solutionType, int numberOfVariables) { - numberOfVariables_ = numberOfVariables; - numberOfObjectives_ = 2; - numberOfConstraints_ = 0; - problemName_ = "Kursawe"; - - lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } - - upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } - - for (int i = 0; i < numberOfVariables_; i++) { - lowerLimit_[i] = -5.0; - upperLimit_[i] = 5.0; - } - - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; - //cout << "Tipo seleccionado Real" << endl; - } - else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; - else { - cout << "Error: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } +Kursawe::Kursawe(string solutionType, int numberOfVariables) +{ + numberOfVariables_ = numberOfVariables; + numberOfObjectives_ = 2; + numberOfConstraints_ = 0; + problemName_ = "Kursawe"; + + lowerLimit_ = new double[numberOfVariables_]; + if (lowerLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + upperLimit_ = new double[numberOfVariables_]; + if (upperLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + for (int i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = -5.0; + upperLimit_[i] = 5.0; + } + + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + { + solutionType_ = new RealSolutionType(this) ; + //cout << "Tipo seleccionado Real" << endl; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = new ArrayRealSolutionType(this) ; + else + { + cout << "Error: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } } // Kursawe /** * Destructor */ -Kursawe::~Kursawe() { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; +Kursawe::~Kursawe() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; } // ~Kursawe @@ -88,43 +95,48 @@ Kursawe::~Kursawe() { * Evaluates a solution * @param solution The solution to evaluate */ -void Kursawe::evaluate(Solution *solution) { - - XReal * vars = new XReal(solution); - - double aux, xi, xj; // auxiliary variables - double * fx = new double[2]; // function values - if (fx == NULL) { - cout << "Error grave: Impossible to reserve memory while evaluating the problem" << endl; - exit(-1); - } - - double * x = new double[numberOfVariables_]; - for (int i = 0 ; i < numberOfVariables_; i++) { - x[i] = vars->getValue(i) ; - } - - fx[0] = 0.0 ; - for (int var = 0; var < numberOfVariables_ - 1; var++) { - xi = x[var] * x[var]; - xj = x[var+1] * x[var+1] ; - aux = (-0.2) * sqrt(xi + xj); - fx[0] += (-10.0) * exp(aux); - } // for - - fx[1] = 0.0; - - for (int var = 0; var < numberOfVariables_ ; var++) { - fx[1] += pow(fabs(x[var]), 0.8) + - 5.0 * sin(pow(x[var], 3.0)); - } // for - - solution->setObjective(0,fx[0]); - solution->setObjective(1,fx[1]); - - delete [] fx; - delete [] x; - delete vars; +void Kursawe::evaluate(Solution *solution) +{ + + XReal * vars = new XReal(solution); + + double aux, xi, xj; // auxiliary variables + double * fx = new double[2]; // function values + if (fx == NULL) + { + cout << "Error grave: Impossible to reserve memory while evaluating the problem" << endl; + exit(-1); + } + + double * x = new double[numberOfVariables_]; + for (int i = 0 ; i < numberOfVariables_; i++) + { + x[i] = vars->getValue(i) ; + } + + fx[0] = 0.0 ; + for (int var = 0; var < numberOfVariables_ - 1; var++) + { + xi = x[var] * x[var]; + xj = x[var+1] * x[var+1] ; + aux = (-0.2) * sqrt(xi + xj); + fx[0] += (-10.0) * exp(aux); + } // for + + fx[1] = 0.0; + + for (int var = 0; var < numberOfVariables_ ; var++) + { + fx[1] += pow(fabs(x[var]), 0.8) + + 5.0 * sin(pow(x[var], 3.0)); + } // for + + solution->setObjective(0,fx[0]); + solution->setObjective(1,fx[1]); + + delete [] fx; + delete [] x; + delete vars; } // evaluate diff --git a/src/problems/Kursawe.h b/src/problems/Kursawe.h index 840971c..f230fb3 100644 --- a/src/problems/Kursawe.h +++ b/src/problems/Kursawe.h @@ -36,12 +36,13 @@ /** * Class representing problem Kursawe */ -class Kursawe : public Problem { +class Kursawe : public Problem +{ public: - Kursawe(string solutionType, int numberOfVariables = 3); - ~Kursawe(); - void evaluate(Solution *solution); + Kursawe(string solutionType, int numberOfVariables = 3); + ~Kursawe(); + void evaluate(Solution *solution); }; #endif diff --git a/src/problems/LZ09/LZ09.cpp b/src/problems/LZ09/LZ09.cpp index a3c8e63..ae6b720 100644 --- a/src/problems/LZ09/LZ09.cpp +++ b/src/problems/LZ09/LZ09.cpp @@ -23,68 +23,81 @@ /** * Constructor */ -LZ09::LZ09(int nvar, int nobj, int ptype, int dtype, int ltype) { - nvar_ = nvar ; - nobj_ = nobj ; - ltype_ = ltype ; - dtype_ = dtype ; - ptype_ = ptype ; +LZ09::LZ09(int nvar, int nobj, int ptype, int dtype, int ltype) +{ + nvar_ = nvar ; + nobj_ = nobj ; + ltype_ = ltype ; + dtype_ = dtype ; + ptype_ = ptype ; } // LZ09::LZ09 /** * Alpha function */ -void LZ09::alphaFunction(double *alpha, vector * x, int dim, int type) { - if (dim == 2) { - if (type == 21) { - alpha[0] = x->at(0); - alpha[1] = 1 - sqrt(x->at(0)); - } - - if (type == 22) { - alpha[0] = x->at(0); - alpha[1] = 1 - x->at(0) * x->at(0); - } - - if (type == 23) { - alpha[0] = x->at(0); - alpha[1] = 1 - sqrt(alpha[0]) - alpha[0] - * sin(10 * alpha[0] * alpha[0] * 3.141596); - } - - if (type == 24) { - alpha[0] = x->at(0); - alpha[1] = 1 - x->at(0) - 0.05 * sin(4 * 3.141596 * x->at(0)); - } - } else { - if (type == 31) { - alpha[0] = cos(x->at(0) * 3.141596 / 2) * cos(x->at(1) * 3.141596 / 2); - alpha[1] = cos(x->at(0) * 3.141596 / 2) * sin(x->at(1) * 3.141596 / 2); - alpha[2] = sin(x->at(0) * 3.141596 / 2); - } - - if (type == 32) { - alpha[0] = 1 - cos(x->at(0) * 3.141596 / 2) - * cos(x->at(1) * 3.141596 / 2); - alpha[1] = 1 - cos(x->at(0) * 3.141596 / 2) - * sin(x->at(1) * 3.141596 / 2); - alpha[2] = 1 - sin(x->at(0) * 3.141596 / 2); - } - - if (type == 33) { - alpha[0] = x->at(0); - alpha[1] = x->at(1); - alpha[2] = 3 - - (sin(3 * 3.141596 * x->at(0)) + sin(3 * 3.141596 * x->at(1))) - 2 - * (x->at(0) + x->at(1)); - } - - if (type == 34) { - alpha[0] = x->at(0) * x->at(1); - alpha[1] = x->at(0) * (1 - x->at(1)); - alpha[2] = (1 - x->at(0)); - } - } +void LZ09::alphaFunction(double *alpha, vector * x, int dim, int type) +{ + if (dim == 2) + { + if (type == 21) + { + alpha[0] = x->at(0); + alpha[1] = 1 - sqrt(x->at(0)); + } + + if (type == 22) + { + alpha[0] = x->at(0); + alpha[1] = 1 - x->at(0) * x->at(0); + } + + if (type == 23) + { + alpha[0] = x->at(0); + alpha[1] = 1 - sqrt(alpha[0]) - alpha[0] + * sin(10 * alpha[0] * alpha[0] * 3.141596); + } + + if (type == 24) + { + alpha[0] = x->at(0); + alpha[1] = 1 - x->at(0) - 0.05 * sin(4 * 3.141596 * x->at(0)); + } + } + else + { + if (type == 31) + { + alpha[0] = cos(x->at(0) * 3.141596 / 2) * cos(x->at(1) * 3.141596 / 2); + alpha[1] = cos(x->at(0) * 3.141596 / 2) * sin(x->at(1) * 3.141596 / 2); + alpha[2] = sin(x->at(0) * 3.141596 / 2); + } + + if (type == 32) + { + alpha[0] = 1 - cos(x->at(0) * 3.141596 / 2) + * cos(x->at(1) * 3.141596 / 2); + alpha[1] = 1 - cos(x->at(0) * 3.141596 / 2) + * sin(x->at(1) * 3.141596 / 2); + alpha[2] = 1 - sin(x->at(0) * 3.141596 / 2); + } + + if (type == 33) + { + alpha[0] = x->at(0); + alpha[1] = x->at(1); + alpha[2] = 3 + - (sin(3 * 3.141596 * x->at(0)) + sin(3 * 3.141596 * x->at(1))) - 2 + * (x->at(0) + x->at(1)); + } + + if (type == 34) + { + alpha[0] = x->at(0) * x->at(1); + alpha[1] = x->at(0) * (1 - x->at(1)); + alpha[2] = (1 - x->at(0)); + } + } } /** @@ -92,245 +105,272 @@ void LZ09::alphaFunction(double *alpha, vector * x, int dim, int type) { */ -double LZ09::betaFunction(vector * x, int type) { - - double beta; - beta = 0; - - int dim = x->size() ; - - if (dim == 0) - beta = 0; - - if (type == 1) { - beta = 0; - for (int i = 0; i < dim; i++) { - beta += x->at(i) * x->at(i); - } - beta = 2.0 * beta / dim; - } - - if (type == 2) { - beta = 0; - for (int i = 0; i < dim; i++) { - beta += sqrt(i + 1) * x->at(i) * x->at(i); - } - beta = 2.0 * beta / dim; - } - - if (type == 3) { - double sum = 0, xx; - for (int i = 0; i < dim; i++) { - xx = 2 * x->at(i); - sum += (xx * xx - cos(4 * 3.141596 * xx) + 1); - } - beta = 2.0 * sum / dim; - } - - if (type == 4) { - double sum = 0, prod = 1, xx; - for (int i = 0; i < dim; i++) { - xx = 2 * x->at(i); - sum += xx * xx; - prod *= cos(10 * 3.141596 * xx / sqrt(i + 1)); - } - beta = 2.0 * (sum - 2 * prod + 2) / dim; - } - return beta; +double LZ09::betaFunction(vector * x, int type) +{ + + double beta; + beta = 0; + + int dim = x->size() ; + + if (dim == 0) + beta = 0; + + if (type == 1) + { + beta = 0; + for (int i = 0; i < dim; i++) + { + beta += x->at(i) * x->at(i); + } + beta = 2.0 * beta / dim; + } + + if (type == 2) + { + beta = 0; + for (int i = 0; i < dim; i++) + { + beta += sqrt(i + 1) * x->at(i) * x->at(i); + } + beta = 2.0 * beta / dim; + } + + if (type == 3) + { + double sum = 0, xx; + for (int i = 0; i < dim; i++) + { + xx = 2 * x->at(i); + sum += (xx * xx - cos(4 * 3.141596 * xx) + 1); + } + beta = 2.0 * sum / dim; + } + + if (type == 4) + { + double sum = 0, prod = 1, xx; + for (int i = 0; i < dim; i++) + { + xx = 2 * x->at(i); + sum += xx * xx; + prod *= cos(10 * 3.141596 * xx / sqrt(i + 1)); + } + beta = 2.0 * (sum - 2 * prod + 2) / dim; + } + return beta; } -double LZ09::psfunc2(double x, double t1, int dim, int type, int css) { - double beta; - beta = 0.0; - - dim++; - - if(type==21){ - double xy = 2*(x - 0.5); - beta = xy - pow(t1, 0.5*(nvar_ + 3*dim - 8)/(nvar_ - 2)); - } - - if(type==22){ - double theta = 6*3.141596*t1 + dim*3.141596/nvar_; - double xy = 2*(x - 0.5); - beta = xy - sin(theta); - } - - if(type==23){ - double theta = 6*3.141596*t1 + dim*3.141596/nvar_; - double ra = 0.8*t1; - double xy = 2*(x - 0.5); - if(css==1) - beta = xy - ra*cos(theta); - else{ - beta = xy - ra*sin(theta); - } - } - - if(type==24){ - double theta = 6*3.141596*t1 + dim*3.141596/nvar_; - double xy = 2*(x - 0.5); - double ra = 0.8*t1; - if(css==1) - beta = xy - ra*cos(theta/3); - else{ - beta = xy - ra*sin(theta); - } - } - - if(type==25){ - double rho = 0.8; - double phi = 3.141596*t1; - double theta = 6*3.141596*t1 + dim*3.141596/nvar_; - double xy = 2*(x - 0.5); - if(css==1) - beta = xy - rho*sin(phi)*sin(theta); - else if(css==2) - beta = xy - rho*sin(phi)*cos(theta); - else - beta = xy - rho*cos(phi); - } - - if(type==26){ - double theta = 6*3.141596*t1 + dim*3.141596/nvar_; - double ra = 0.3*t1*(t1*cos(4*theta) + 2); - double xy = 2*(x - 0.5); - if(css==1) - beta = xy - ra*cos(theta); - else{ - beta = xy - ra*sin(theta); - } - } - - return beta; +double LZ09::psfunc2(double x, double t1, int dim, int type, int css) +{ + double beta; + beta = 0.0; + + dim++; + + if(type==21) + { + double xy = 2*(x - 0.5); + beta = xy - pow(t1, 0.5*(nvar_ + 3*dim - 8)/(nvar_ - 2)); + } + + if(type==22) + { + double theta = 6*3.141596*t1 + dim*3.141596/nvar_; + double xy = 2*(x - 0.5); + beta = xy - sin(theta); + } + + if(type==23) + { + double theta = 6*3.141596*t1 + dim*3.141596/nvar_; + double ra = 0.8*t1; + double xy = 2*(x - 0.5); + if(css==1) + beta = xy - ra*cos(theta); + else + { + beta = xy - ra*sin(theta); + } + } + + if(type==24) + { + double theta = 6*3.141596*t1 + dim*3.141596/nvar_; + double xy = 2*(x - 0.5); + double ra = 0.8*t1; + if(css==1) + beta = xy - ra*cos(theta/3); + else + { + beta = xy - ra*sin(theta); + } + } + + if(type==25) + { + double rho = 0.8; + double phi = 3.141596*t1; + double theta = 6*3.141596*t1 + dim*3.141596/nvar_; + double xy = 2*(x - 0.5); + if(css==1) + beta = xy - rho*sin(phi)*sin(theta); + else if(css==2) + beta = xy - rho*sin(phi)*cos(theta); + else + beta = xy - rho*cos(phi); + } + + if(type==26) + { + double theta = 6*3.141596*t1 + dim*3.141596/nvar_; + double ra = 0.3*t1*(t1*cos(4*theta) + 2); + double xy = 2*(x - 0.5); + if(css==1) + beta = xy - ra*cos(theta); + else + { + beta = xy - ra*sin(theta); + } + } + + return beta; } -double LZ09::psfunc3(double x, double t1, double t2, int dim, int type){ - // type: the type of curve - // css: the class of index - double beta; - beta = 0.0 ; - - dim++; - - if(type==31){ - double xy = 4*(x - 0.5); - double rate = 1.0*dim/nvar_; - beta = xy - 4*(t1*t1*rate + t2*(1.0-rate)) + 2; - } - - if(type==32){ - double theta = 2*3.141596*t1 + dim*3.141596/nvar_; - double xy = 4*(x - 0.5); - beta = xy - 2*t2*sin(theta); - } - - return beta; +double LZ09::psfunc3(double x, double t1, double t2, int dim, int type) +{ + // type: the type of curve + // css: the class of index + double beta; + beta = 0.0 ; + + dim++; + + if(type==31) + { + double xy = 4*(x - 0.5); + double rate = 1.0*dim/nvar_; + beta = xy - 4*(t1*t1*rate + t2*(1.0-rate)) + 2; + } + + if(type==32) + { + double theta = 2*3.141596*t1 + dim*3.141596/nvar_; + double xy = 4*(x - 0.5); + beta = xy - 2*t2*sin(theta); + } + + return beta; } -void LZ09::objective(vector *x_var, vector *y_obj) { - // 2-objective case - if(nobj_==2) - { - if(ltype_==21||ltype_==22||ltype_==23||ltype_==24||ltype_==26) - { - double g = 0, h = 0, a, b; - vector aa ; // *aa = new vector(); - vector bb ; // *bb = new vector(); - for(int n=1;nat(n),x_var->at(0),n,ltype_,1); // linkage - aa.push_back(a); - } - else - { - b = psfunc2(x_var->at(n),x_var->at(0),n,ltype_,2); - bb.push_back(b); - } - - } - - g = betaFunction(&aa, dtype_); - h = betaFunction(&bb, dtype_); - - double alpha[2] ; - alphaFunction(alpha,x_var,2,ptype_); // shape function - y_obj->at(0) = alpha[0] + h; - y_obj->at(1) = alpha[1] + g; - aa.clear(); - bb.clear(); - } - - if(ltype_==25) - { - double g = 0, h = 0, a, b; - double e = 0, c; - vector aa ; //= new Vector() ; - vector bb ; //= new Vector() ; - for(int n=1;nat(n),x_var->at(0),n,ltype_,1); - aa.push_back(a); - } - else if(n%3==1) - { - b = psfunc2(x_var->at(n),x_var->at(0),n,ltype_,2); - bb.push_back(b); - } - else{ - c = psfunc2(x_var->at(n),x_var->at(0),n,ltype_,3); - if(n%2==0) aa.push_back(c); - else bb.push_back(c); - } - } - g = betaFunction(&aa,dtype_); // distance function - h = betaFunction(&bb,dtype_); - - //double * alpha = new double[2]; - double alpha[2] ; - alphaFunction(alpha,x_var,2,ptype_); // shape function - y_obj->at(0) = alpha[0] + h; - y_obj->at(1) = alpha[1] + g; - aa.clear(); - bb.clear(); - } - } - - - // 3-objective case - if(nobj_==3) - { - if(ltype_==31||ltype_==32) - { - double g = 0, h = 0, e = 0, a; - vector aa ; - vector bb ; - vector cc ; - for(int n=2;nat(n),x_var->at(0),x_var->at(1),n,ltype_); - if(n%3==0) aa.push_back(a); - else if(n%3==1) bb.push_back(a); - else cc.push_back(a); - } - - g = betaFunction(&aa,dtype_); - h = betaFunction(&bb,dtype_); - e = betaFunction(&cc,dtype_); - - //double * alpha = new double[3]; - double alpha[3] ; - alphaFunction(alpha,x_var,3,ptype_); // shape function - y_obj->at(0) = alpha[0] + h; - y_obj->at(1) = alpha[1] + g; - y_obj->at(2) = alpha[2] + e; - aa.clear(); - bb.clear(); - cc.clear(); - } - } +void LZ09::objective(vector *x_var, vector *y_obj) +{ + // 2-objective case + if(nobj_==2) + { + if(ltype_==21||ltype_==22||ltype_==23||ltype_==24||ltype_==26) + { + double g = 0, h = 0, a, b; + vector aa ; // *aa = new vector(); + vector bb ; // *bb = new vector(); + for(int n=1; nat(n),x_var->at(0),n,ltype_,1); // linkage + aa.push_back(a); + } + else + { + b = psfunc2(x_var->at(n),x_var->at(0),n,ltype_,2); + bb.push_back(b); + } + + } + + g = betaFunction(&aa, dtype_); + h = betaFunction(&bb, dtype_); + + double alpha[2] ; + alphaFunction(alpha,x_var,2,ptype_); // shape function + y_obj->at(0) = alpha[0] + h; + y_obj->at(1) = alpha[1] + g; + aa.clear(); + bb.clear(); + } + + if(ltype_==25) + { + double g = 0, h = 0, a, b; + double e = 0, c; + vector aa ; //= new Vector() ; + vector bb ; //= new Vector() ; + for(int n=1; nat(n),x_var->at(0),n,ltype_,1); + aa.push_back(a); + } + else if(n%3==1) + { + b = psfunc2(x_var->at(n),x_var->at(0),n,ltype_,2); + bb.push_back(b); + } + else + { + c = psfunc2(x_var->at(n),x_var->at(0),n,ltype_,3); + if(n%2==0) aa.push_back(c); + else bb.push_back(c); + } + } + g = betaFunction(&aa,dtype_); // distance function + h = betaFunction(&bb,dtype_); + + //double * alpha = new double[2]; + double alpha[2] ; + alphaFunction(alpha,x_var,2,ptype_); // shape function + y_obj->at(0) = alpha[0] + h; + y_obj->at(1) = alpha[1] + g; + aa.clear(); + bb.clear(); + } + } + + + // 3-objective case + if(nobj_==3) + { + if(ltype_==31||ltype_==32) + { + double g = 0, h = 0, e = 0, a; + vector aa ; + vector bb ; + vector cc ; + for(int n=2; nat(n),x_var->at(0),x_var->at(1),n,ltype_); + if(n%3==0) aa.push_back(a); + else if(n%3==1) bb.push_back(a); + else cc.push_back(a); + } + + g = betaFunction(&aa,dtype_); + h = betaFunction(&bb,dtype_); + e = betaFunction(&cc,dtype_); + + //double * alpha = new double[3]; + double alpha[3] ; + alphaFunction(alpha,x_var,3,ptype_); // shape function + y_obj->at(0) = alpha[0] + h; + y_obj->at(1) = alpha[1] + g; + y_obj->at(2) = alpha[2] + e; + aa.clear(); + bb.clear(); + cc.clear(); + } + } } diff --git a/src/problems/LZ09/LZ09.h b/src/problems/LZ09/LZ09.h index a30ae2c..bbc98ac 100644 --- a/src/problems/LZ09/LZ09.h +++ b/src/problems/LZ09/LZ09.h @@ -27,21 +27,22 @@ using namespace std; -class LZ09 { +class LZ09 +{ private: - int nvar_ ; - int nobj_ ; - int ltype_ ; - int dtype_ ; - int ptype_ ; + int nvar_ ; + int nobj_ ; + int ltype_ ; + int dtype_ ; + int ptype_ ; public: - LZ09 (int nvar, int nobj, int ptype, int dtype, int ltype) ; - void alphaFunction(double *alpha, vector *x, int dim, int type) ; - double betaFunction(vector * x, int type) ; - double psfunc2(double x, double t1, int dim, int type, int css) ; - double psfunc3(double x, double t1, double t2, int dim, int type) ; - void objective(vector * x_var, vector * y_obj) ; + LZ09 (int nvar, int nobj, int ptype, int dtype, int ltype) ; + void alphaFunction(double *alpha, vector *x, int dim, int type) ; + double betaFunction(vector * x, int type) ; + double psfunc2(double x, double t1, int dim, int type, int css) ; + double psfunc3(double x, double t1, double t2, int dim, int type) ; + void objective(vector * x_var, vector * y_obj) ; }; diff --git a/src/problems/LZ09/LZ09_F1.cpp b/src/problems/LZ09/LZ09_F1.cpp index e8feec5..8254f83 100644 --- a/src/problems/LZ09/LZ09_F1.cpp +++ b/src/problems/LZ09/LZ09_F1.cpp @@ -23,82 +23,92 @@ /** * Constructor */ -LZ09_F1::LZ09_F1(string solutionType, int ptype, int dtype, int ltype) { - numberOfVariables_ = 10; - numberOfObjectives_ = 2; - numberOfConstraints_= 0; - problemName_ = "LZ09_F1"; - - LZ09_ = new LZ09(numberOfVariables_, - numberOfObjectives_, - ptype, - dtype, - ltype) ; +LZ09_F1::LZ09_F1(string solutionType, int ptype, int dtype, int ltype) +{ + numberOfVariables_ = 10; + numberOfObjectives_ = 2; + numberOfConstraints_= 0; + problemName_ = "LZ09_F1"; - lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) { - cout << "LZ09_F1::LZ09_F1: Error reserving memory for storing the " - << "variable lower limits" << endl; - exit(-1); - } + LZ09_ = new LZ09(numberOfVariables_, + numberOfObjectives_, + ptype, + dtype, + ltype) ; - upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) { - cout << "LZ09_F1::LZ09_F1: Error reserving memory for storing the " - << "variable lower limits" << endl; - exit(-1); - } + lowerLimit_ = new double[numberOfVariables_]; + if (lowerLimit_ == NULL) + { + cout << "LZ09_F1::LZ09_F1: Error reserving memory for storing the " + << "variable lower limits" << endl; + exit(-1); + } - for (int i = 0; i < numberOfVariables_; i++) { - lowerLimit_[i] = 0.0; - upperLimit_[i] = 1.0; - } - - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; - } - else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; - else { - cout << "LZ09_F1::LZ09_F1: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } - - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; + upperLimit_ = new double[numberOfVariables_]; + if (upperLimit_ == NULL) + { + cout << "LZ09_F1::LZ09_F1: Error reserving memory for storing the " + << "variable lower limits" << endl; + exit(-1); + } + + for (int i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = 0.0; + upperLimit_[i] = 1.0; + } + + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + { + solutionType_ = new RealSolutionType(this) ; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = new ArrayRealSolutionType(this) ; + else + { + cout << "LZ09_F1::LZ09_F1: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } + + fx_ = new double[numberOfObjectives_] ; + x_ = new double[numberOfVariables_]; } // LZ09_F1::LZ09_F1 /** * Destructor */ -LZ09_F1::~LZ09_F1 () { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; - delete LZ09_ ; +LZ09_F1::~LZ09_F1 () +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; + delete LZ09_ ; } -void LZ09_F1::evaluate(Solution * solution) { - XReal * vars = new XReal(solution); - - vector * x = new vector(numberOfVariables_) ; - vector * y = new vector(numberOfObjectives_); +void LZ09_F1::evaluate(Solution * solution) +{ + XReal * vars = new XReal(solution); + + vector * x = new vector(numberOfVariables_) ; + vector * y = new vector(numberOfObjectives_); + + for (int i = 0; i < numberOfVariables_; i++) + { + x->at(i) = vars->getValue(i); + } // for + for (int i = 0; i < numberOfObjectives_; i++) + { + y->at(i) = 0.0 ; + } // for - for (int i = 0; i < numberOfVariables_; i++) { - x->at(i) = vars->getValue(i); - } // for - for (int i = 0; i < numberOfObjectives_; i++) { - y->at(i) = 0.0 ; - } // for + LZ09_->objective(x, y) ; - LZ09_->objective(x, y) ; + for (int i = 0; i < numberOfObjectives_; i++) + solution->setObjective(i, y->at(i)); - for (int i = 0; i < numberOfObjectives_; i++) - solution->setObjective(i, y->at(i)); - - delete x; - delete y; - delete vars; + delete x; + delete y; + delete vars; } diff --git a/src/problems/LZ09/LZ09_F1.h b/src/problems/LZ09/LZ09_F1.h index 77eb236..df8cc59 100644 --- a/src/problems/LZ09/LZ09_F1.h +++ b/src/problems/LZ09/LZ09_F1.h @@ -31,16 +31,17 @@ #include #include -class LZ09_F1 : public Problem { +class LZ09_F1 : public Problem +{ public: - LZ09_F1(string solutionType, int ptype=21, int dtype=1, int ltype=21); - void evaluate(Solution *solution); + LZ09_F1(string solutionType, int ptype=21, int dtype=1, int ltype=21); + void evaluate(Solution *solution); - virtual ~LZ09_F1(); + virtual ~LZ09_F1(); private: - LZ09 * LZ09_ ; - double * fx_ ; - double * x_ ; + LZ09 * LZ09_ ; + double * fx_ ; + double * x_ ; }; #endif /* __LZ09_F1_H__ */ diff --git a/src/problems/LZ09/LZ09_F2.cpp b/src/problems/LZ09/LZ09_F2.cpp index a1577ea..39eef56 100644 --- a/src/problems/LZ09/LZ09_F2.cpp +++ b/src/problems/LZ09/LZ09_F2.cpp @@ -23,84 +23,94 @@ /** * Constructor */ -LZ09_F2::LZ09_F2(string solutionType, int ptype, int dtype, int ltype) { - numberOfVariables_ = 30; - numberOfObjectives_ = 2; - numberOfConstraints_= 0; - problemName_ = "LZ09_F2"; +LZ09_F2::LZ09_F2(string solutionType, int ptype, int dtype, int ltype) +{ + numberOfVariables_ = 30; + numberOfObjectives_ = 2; + numberOfConstraints_= 0; + problemName_ = "LZ09_F2"; - LZ09_ = new LZ09(numberOfVariables_, - numberOfObjectives_, - ptype, - dtype, - ltype) ; + LZ09_ = new LZ09(numberOfVariables_, + numberOfObjectives_, + ptype, + dtype, + ltype) ; - lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) { - cout << "LZ09_F2::LZ09_F2: Error reserving memory for storing the " - << "variable lower limits" << endl; - exit(-1); - } + lowerLimit_ = new double[numberOfVariables_]; + if (lowerLimit_ == NULL) + { + cout << "LZ09_F2::LZ09_F2: Error reserving memory for storing the " + << "variable lower limits" << endl; + exit(-1); + } - upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) { - cout << "LZ09_F2::LZ09_F2: Error reserving memory for storing the " - << "variable lower limits" << endl; - exit(-1); - } + upperLimit_ = new double[numberOfVariables_]; + if (upperLimit_ == NULL) + { + cout << "LZ09_F2::LZ09_F2: Error reserving memory for storing the " + << "variable lower limits" << endl; + exit(-1); + } - lowerLimit_[0] = 0.0; - upperLimit_[0] = 1.0; - for (int i = 1; i < numberOfVariables_; i++) { - lowerLimit_[i] = -1.0; - upperLimit_[i] = 1.0; - } + lowerLimit_[0] = 0.0; + upperLimit_[0] = 1.0; + for (int i = 1; i < numberOfVariables_; i++) + { + lowerLimit_[i] = -1.0; + upperLimit_[i] = 1.0; + } - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; - } - else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; - else { - cout << "LZ09_F2::LZ09_F2: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + { + solutionType_ = new RealSolutionType(this) ; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = new ArrayRealSolutionType(this) ; + else + { + cout << "LZ09_F2::LZ09_F2: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; + fx_ = new double[numberOfObjectives_] ; + x_ = new double[numberOfVariables_]; } // LZ09_F2::LZ09_F2 /** * Destructor */ -LZ09_F2::~LZ09_F2 () { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; - delete LZ09_ ; +LZ09_F2::~LZ09_F2 () +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; + delete LZ09_ ; } -void LZ09_F2::evaluate(Solution * solution) { - XReal * vars = new XReal(solution); +void LZ09_F2::evaluate(Solution * solution) +{ + XReal * vars = new XReal(solution); - vector * x = new vector(numberOfVariables_) ; - vector * y = new vector(numberOfObjectives_); + vector * x = new vector(numberOfVariables_) ; + vector * y = new vector(numberOfObjectives_); - for (int i = 0; i < numberOfVariables_; i++) { - x->at(i) = vars->getValue(i); - } // for - for (int i = 0; i < numberOfObjectives_; i++) { - y->at(i) = 0.0 ; - } // for + for (int i = 0; i < numberOfVariables_; i++) + { + x->at(i) = vars->getValue(i); + } // for + for (int i = 0; i < numberOfObjectives_; i++) + { + y->at(i) = 0.0 ; + } // for - LZ09_->objective(x, y) ; + LZ09_->objective(x, y) ; - for (int i = 0; i < numberOfObjectives_; i++) - solution->setObjective(i, y->at(i)); - - delete x; - delete y; - delete vars; + for (int i = 0; i < numberOfObjectives_; i++) + solution->setObjective(i, y->at(i)); + + delete x; + delete y; + delete vars; } diff --git a/src/problems/LZ09/LZ09_F2.h b/src/problems/LZ09/LZ09_F2.h index 2628624..eeb95cd 100644 --- a/src/problems/LZ09/LZ09_F2.h +++ b/src/problems/LZ09/LZ09_F2.h @@ -31,16 +31,17 @@ #include #include -class LZ09_F2 : public Problem { +class LZ09_F2 : public Problem +{ public: - LZ09_F2(string solutionType, int ptype=21, int dtype=1, int ltype=22); - void evaluate(Solution *solution); + LZ09_F2(string solutionType, int ptype=21, int dtype=1, int ltype=22); + void evaluate(Solution *solution); - virtual ~LZ09_F2(); + virtual ~LZ09_F2(); private: - LZ09 * LZ09_ ; - double * fx_ ; - double * x_ ; + LZ09 * LZ09_ ; + double * fx_ ; + double * x_ ; }; #endif /* __LZ09_F2_H__ */ diff --git a/src/problems/LZ09/LZ09_F3.cpp b/src/problems/LZ09/LZ09_F3.cpp index d595ca4..5ae88c7 100644 --- a/src/problems/LZ09/LZ09_F3.cpp +++ b/src/problems/LZ09/LZ09_F3.cpp @@ -23,84 +23,94 @@ /** * Constructor */ -LZ09_F3::LZ09_F3(string solutionType, int ptype, int dtype, int ltype) { - numberOfVariables_ = 30; - numberOfObjectives_ = 2; - numberOfConstraints_= 0; - problemName_ = "LZ09_F3"; +LZ09_F3::LZ09_F3(string solutionType, int ptype, int dtype, int ltype) +{ + numberOfVariables_ = 30; + numberOfObjectives_ = 2; + numberOfConstraints_= 0; + problemName_ = "LZ09_F3"; - LZ09_ = new LZ09(numberOfVariables_, - numberOfObjectives_, - ptype, - dtype, - ltype) ; + LZ09_ = new LZ09(numberOfVariables_, + numberOfObjectives_, + ptype, + dtype, + ltype) ; - lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) { - cout << "LZ09_F3::LZ09_F3: Error reserving memory for storing the " - << "variable lower limits" << endl; - exit(-1); - } + lowerLimit_ = new double[numberOfVariables_]; + if (lowerLimit_ == NULL) + { + cout << "LZ09_F3::LZ09_F3: Error reserving memory for storing the " + << "variable lower limits" << endl; + exit(-1); + } - upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) { - cout << "LZ09_F3::LZ09_F3: Error reserving memory for storing the " - << "variable lower limits" << endl; - exit(-1); - } + upperLimit_ = new double[numberOfVariables_]; + if (upperLimit_ == NULL) + { + cout << "LZ09_F3::LZ09_F3: Error reserving memory for storing the " + << "variable lower limits" << endl; + exit(-1); + } - lowerLimit_[0] = 0.0; - upperLimit_[0] = 1.0; - for (int i = 1; i < numberOfVariables_; i++) { - lowerLimit_[i] = -1.0; - upperLimit_[i] = 1.0; - } + lowerLimit_[0] = 0.0; + upperLimit_[0] = 1.0; + for (int i = 1; i < numberOfVariables_; i++) + { + lowerLimit_[i] = -1.0; + upperLimit_[i] = 1.0; + } - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; - } - else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; - else { - cout << "LZ09_F3::LZ09_F3: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + { + solutionType_ = new RealSolutionType(this) ; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = new ArrayRealSolutionType(this) ; + else + { + cout << "LZ09_F3::LZ09_F3: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; + fx_ = new double[numberOfObjectives_] ; + x_ = new double[numberOfVariables_]; } // LZ09_F3::LZ09_F3 /** * Destructor */ -LZ09_F3::~LZ09_F3 () { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; - delete LZ09_ ; +LZ09_F3::~LZ09_F3 () +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; + delete LZ09_ ; } -void LZ09_F3::evaluate(Solution * solution) { - XReal * vars = new XReal(solution); +void LZ09_F3::evaluate(Solution * solution) +{ + XReal * vars = new XReal(solution); - vector * x = new vector(numberOfVariables_) ; - vector * y = new vector(numberOfObjectives_); + vector * x = new vector(numberOfVariables_) ; + vector * y = new vector(numberOfObjectives_); - for (int i = 0; i < numberOfVariables_; i++) { - x->at(i) = vars->getValue(i); - } // for - for (int i = 0; i < numberOfObjectives_; i++) { - y->at(i) = 0.0 ; - } // for + for (int i = 0; i < numberOfVariables_; i++) + { + x->at(i) = vars->getValue(i); + } // for + for (int i = 0; i < numberOfObjectives_; i++) + { + y->at(i) = 0.0 ; + } // for - LZ09_->objective(x, y) ; + LZ09_->objective(x, y) ; - for (int i = 0; i < numberOfObjectives_; i++) - solution->setObjective(i, y->at(i)); - - delete x; - delete y; - delete vars; + for (int i = 0; i < numberOfObjectives_; i++) + solution->setObjective(i, y->at(i)); + + delete x; + delete y; + delete vars; } diff --git a/src/problems/LZ09/LZ09_F3.h b/src/problems/LZ09/LZ09_F3.h index 1f20042..7722a00 100644 --- a/src/problems/LZ09/LZ09_F3.h +++ b/src/problems/LZ09/LZ09_F3.h @@ -31,16 +31,17 @@ #include #include -class LZ09_F3 : public Problem { +class LZ09_F3 : public Problem +{ public: - LZ09_F3(string solutionType, int ptype=21, int dtype=1, int ltype=23); - void evaluate(Solution *solution); + LZ09_F3(string solutionType, int ptype=21, int dtype=1, int ltype=23); + void evaluate(Solution *solution); - virtual ~LZ09_F3(); + virtual ~LZ09_F3(); private: - LZ09 * LZ09_ ; - double * fx_ ; - double * x_ ; + LZ09 * LZ09_ ; + double * fx_ ; + double * x_ ; }; #endif /* __LZ09_F3_H__ */ diff --git a/src/problems/LZ09/LZ09_F4.cpp b/src/problems/LZ09/LZ09_F4.cpp index aa34899..2b94772 100644 --- a/src/problems/LZ09/LZ09_F4.cpp +++ b/src/problems/LZ09/LZ09_F4.cpp @@ -23,84 +23,94 @@ /** * Constructor */ -LZ09_F4::LZ09_F4(string solutionType, int ptype, int dtype, int ltype) { - numberOfVariables_ = 30; - numberOfObjectives_ = 2; - numberOfConstraints_= 0; - problemName_ = "LZ09_F4"; +LZ09_F4::LZ09_F4(string solutionType, int ptype, int dtype, int ltype) +{ + numberOfVariables_ = 30; + numberOfObjectives_ = 2; + numberOfConstraints_= 0; + problemName_ = "LZ09_F4"; - LZ09_ = new LZ09(numberOfVariables_, - numberOfObjectives_, - ptype, - dtype, - ltype) ; + LZ09_ = new LZ09(numberOfVariables_, + numberOfObjectives_, + ptype, + dtype, + ltype) ; - lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) { - cout << "LZ09_F4::LZ09_F4: Error reserving memory for storing the " - << "variable lower limits" << endl; - exit(-1); - } + lowerLimit_ = new double[numberOfVariables_]; + if (lowerLimit_ == NULL) + { + cout << "LZ09_F4::LZ09_F4: Error reserving memory for storing the " + << "variable lower limits" << endl; + exit(-1); + } - upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) { - cout << "LZ09_F4::LZ09_F4: Error reserving memory for storing the " - << "variable lower limits" << endl; - exit(-1); - } + upperLimit_ = new double[numberOfVariables_]; + if (upperLimit_ == NULL) + { + cout << "LZ09_F4::LZ09_F4: Error reserving memory for storing the " + << "variable lower limits" << endl; + exit(-1); + } - lowerLimit_[0] = 0.0; - upperLimit_[0] = 1.0; - for (int i = 1; i < numberOfVariables_; i++) { - lowerLimit_[i] = -1.0; - upperLimit_[i] = 1.0; - } + lowerLimit_[0] = 0.0; + upperLimit_[0] = 1.0; + for (int i = 1; i < numberOfVariables_; i++) + { + lowerLimit_[i] = -1.0; + upperLimit_[i] = 1.0; + } - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; - } - else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; - else { - cout << "LZ09_F4::LZ09_F4: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + { + solutionType_ = new RealSolutionType(this) ; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = new ArrayRealSolutionType(this) ; + else + { + cout << "LZ09_F4::LZ09_F4: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; + fx_ = new double[numberOfObjectives_] ; + x_ = new double[numberOfVariables_]; } // LZ09_F4::LZ09_F4 /** * Destructor */ -LZ09_F4::~LZ09_F4 () { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; - delete LZ09_ ; +LZ09_F4::~LZ09_F4 () +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; + delete LZ09_ ; } -void LZ09_F4::evaluate(Solution * solution) { - XReal * vars = new XReal(solution); +void LZ09_F4::evaluate(Solution * solution) +{ + XReal * vars = new XReal(solution); - vector * x = new vector(numberOfVariables_) ; - vector * y = new vector(numberOfObjectives_); + vector * x = new vector(numberOfVariables_) ; + vector * y = new vector(numberOfObjectives_); - for (int i = 0; i < numberOfVariables_; i++) { - x->at(i) = vars->getValue(i); - } // for - for (int i = 0; i < numberOfObjectives_; i++) { - y->at(i) = 0.0 ; - } // for + for (int i = 0; i < numberOfVariables_; i++) + { + x->at(i) = vars->getValue(i); + } // for + for (int i = 0; i < numberOfObjectives_; i++) + { + y->at(i) = 0.0 ; + } // for - LZ09_->objective(x, y) ; + LZ09_->objective(x, y) ; - for (int i = 0; i < numberOfObjectives_; i++) - solution->setObjective(i, y->at(i)); - - delete x; - delete y; - delete vars; + for (int i = 0; i < numberOfObjectives_; i++) + solution->setObjective(i, y->at(i)); + + delete x; + delete y; + delete vars; } diff --git a/src/problems/LZ09/LZ09_F4.h b/src/problems/LZ09/LZ09_F4.h index 6efc2fe..ffac555 100644 --- a/src/problems/LZ09/LZ09_F4.h +++ b/src/problems/LZ09/LZ09_F4.h @@ -31,16 +31,17 @@ #include #include -class LZ09_F4 : public Problem { +class LZ09_F4 : public Problem +{ public: - LZ09_F4(string solutionType, int ptype=21, int dtype=1, int ltype=24); - void evaluate(Solution *solution); + LZ09_F4(string solutionType, int ptype=21, int dtype=1, int ltype=24); + void evaluate(Solution *solution); - virtual ~LZ09_F4(); + virtual ~LZ09_F4(); private: - LZ09 * LZ09_ ; - double * fx_ ; - double * x_ ; + LZ09 * LZ09_ ; + double * fx_ ; + double * x_ ; }; #endif /* __LZ09_F4_H__ */ diff --git a/src/problems/LZ09/LZ09_F5.cpp b/src/problems/LZ09/LZ09_F5.cpp index 210afab..95e2d09 100644 --- a/src/problems/LZ09/LZ09_F5.cpp +++ b/src/problems/LZ09/LZ09_F5.cpp @@ -23,84 +23,94 @@ /** * Constructor */ -LZ09_F5::LZ09_F5(string solutionType, int ptype, int dtype, int ltype) { - numberOfVariables_ = 30; - numberOfObjectives_ = 2; - numberOfConstraints_= 0; - problemName_ = "LZ09_F5"; +LZ09_F5::LZ09_F5(string solutionType, int ptype, int dtype, int ltype) +{ + numberOfVariables_ = 30; + numberOfObjectives_ = 2; + numberOfConstraints_= 0; + problemName_ = "LZ09_F5"; - LZ09_ = new LZ09(numberOfVariables_, - numberOfObjectives_, - ptype, - dtype, - ltype) ; + LZ09_ = new LZ09(numberOfVariables_, + numberOfObjectives_, + ptype, + dtype, + ltype) ; - lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) { - cout << "LZ09_F5::LZ09_F5: Error reserving memory for storing the " - << "variable lower limits" << endl; - exit(-1); - } + lowerLimit_ = new double[numberOfVariables_]; + if (lowerLimit_ == NULL) + { + cout << "LZ09_F5::LZ09_F5: Error reserving memory for storing the " + << "variable lower limits" << endl; + exit(-1); + } - upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) { - cout << "LZ09_F5::LZ09_F5: Error reserving memory for storing the " - << "variable lower limits" << endl; - exit(-1); - } + upperLimit_ = new double[numberOfVariables_]; + if (upperLimit_ == NULL) + { + cout << "LZ09_F5::LZ09_F5: Error reserving memory for storing the " + << "variable lower limits" << endl; + exit(-1); + } - lowerLimit_[0] = 0.0; - upperLimit_[0] = 1.0; - for (int i = 1; i < numberOfVariables_; i++) { - lowerLimit_[i] = -1.0; - upperLimit_[i] = 1.0; - } + lowerLimit_[0] = 0.0; + upperLimit_[0] = 1.0; + for (int i = 1; i < numberOfVariables_; i++) + { + lowerLimit_[i] = -1.0; + upperLimit_[i] = 1.0; + } - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; - } - else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; - else { - cout << "LZ09_F5::LZ09_F5: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + { + solutionType_ = new RealSolutionType(this) ; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = new ArrayRealSolutionType(this) ; + else + { + cout << "LZ09_F5::LZ09_F5: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; + fx_ = new double[numberOfObjectives_] ; + x_ = new double[numberOfVariables_]; } // LZ09_F5::LZ09_F5 /** * Destructor */ -LZ09_F5::~LZ09_F5 () { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; - delete LZ09_ ; +LZ09_F5::~LZ09_F5 () +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; + delete LZ09_ ; } -void LZ09_F5::evaluate(Solution * solution) { - XReal * vars = new XReal(solution); +void LZ09_F5::evaluate(Solution * solution) +{ + XReal * vars = new XReal(solution); - vector * x = new vector(numberOfVariables_) ; - vector * y = new vector(numberOfObjectives_); + vector * x = new vector(numberOfVariables_) ; + vector * y = new vector(numberOfObjectives_); - for (int i = 0; i < numberOfVariables_; i++) { - x->at(i) = vars->getValue(i); - } // for - for (int i = 0; i < numberOfObjectives_; i++) { - y->at(i) = 0.0 ; - } // for + for (int i = 0; i < numberOfVariables_; i++) + { + x->at(i) = vars->getValue(i); + } // for + for (int i = 0; i < numberOfObjectives_; i++) + { + y->at(i) = 0.0 ; + } // for - LZ09_->objective(x, y) ; + LZ09_->objective(x, y) ; - for (int i = 0; i < numberOfObjectives_; i++) - solution->setObjective(i, y->at(i)); - - delete x; - delete y; - delete vars; + for (int i = 0; i < numberOfObjectives_; i++) + solution->setObjective(i, y->at(i)); + + delete x; + delete y; + delete vars; } diff --git a/src/problems/LZ09/LZ09_F5.h b/src/problems/LZ09/LZ09_F5.h index f81e839..e7f006c 100644 --- a/src/problems/LZ09/LZ09_F5.h +++ b/src/problems/LZ09/LZ09_F5.h @@ -31,16 +31,17 @@ #include #include -class LZ09_F5 : public Problem { +class LZ09_F5 : public Problem +{ public: - LZ09_F5(string solutionType, int ptype=21, int dtype=1, int ltype=26); - void evaluate(Solution *solution); + LZ09_F5(string solutionType, int ptype=21, int dtype=1, int ltype=26); + void evaluate(Solution *solution); - virtual ~LZ09_F5(); + virtual ~LZ09_F5(); private: - LZ09 * LZ09_ ; - double * fx_ ; - double * x_ ; + LZ09 * LZ09_ ; + double * fx_ ; + double * x_ ; }; #endif /* __LZ09_F5_H__ */ diff --git a/src/problems/LZ09/LZ09_F6.cpp b/src/problems/LZ09/LZ09_F6.cpp index d444689..1862434 100644 --- a/src/problems/LZ09/LZ09_F6.cpp +++ b/src/problems/LZ09/LZ09_F6.cpp @@ -23,84 +23,94 @@ /** * Constructor */ -LZ09_F6::LZ09_F6(string solutionType, int ptype, int dtype, int ltype) { - numberOfVariables_ = 10; - numberOfObjectives_ = 3; - numberOfConstraints_= 0; - problemName_ = "LZ09_F6"; +LZ09_F6::LZ09_F6(string solutionType, int ptype, int dtype, int ltype) +{ + numberOfVariables_ = 10; + numberOfObjectives_ = 3; + numberOfConstraints_= 0; + problemName_ = "LZ09_F6"; - LZ09_ = new LZ09(numberOfVariables_, - numberOfObjectives_, - ptype, - dtype, - ltype) ; + LZ09_ = new LZ09(numberOfVariables_, + numberOfObjectives_, + ptype, + dtype, + ltype) ; - lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) { - cout << "LZ09_F6::LZ09_F6: Error reserving memory for storing the " - << "variable lower limits" << endl; - exit(-1); - } + lowerLimit_ = new double[numberOfVariables_]; + if (lowerLimit_ == NULL) + { + cout << "LZ09_F6::LZ09_F6: Error reserving memory for storing the " + << "variable lower limits" << endl; + exit(-1); + } - upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) { - cout << "LZ09_F6::LZ09_F6: Error reserving memory for storing the " - << "variable lower limits" << endl; - exit(-1); - } + upperLimit_ = new double[numberOfVariables_]; + if (upperLimit_ == NULL) + { + cout << "LZ09_F6::LZ09_F6: Error reserving memory for storing the " + << "variable lower limits" << endl; + exit(-1); + } - lowerLimit_[0] = 0.0; - upperLimit_[0] = 1.0; - for (int i = 1; i < numberOfVariables_; i++) { - lowerLimit_[i] = -1.0; - upperLimit_[i] = 1.0; - } + lowerLimit_[0] = 0.0; + upperLimit_[0] = 1.0; + for (int i = 1; i < numberOfVariables_; i++) + { + lowerLimit_[i] = -1.0; + upperLimit_[i] = 1.0; + } - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; - } - else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; - else { - cout << "LZ09_F6::LZ09_F6: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + { + solutionType_ = new RealSolutionType(this) ; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = new ArrayRealSolutionType(this) ; + else + { + cout << "LZ09_F6::LZ09_F6: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; + fx_ = new double[numberOfObjectives_] ; + x_ = new double[numberOfVariables_]; } // LZ09_F6::LZ09_F6 /** * Destructor */ -LZ09_F6::~LZ09_F6 () { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; - delete LZ09_ ; +LZ09_F6::~LZ09_F6 () +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; + delete LZ09_ ; } -void LZ09_F6::evaluate(Solution * solution) { - XReal * vars = new XReal(solution); +void LZ09_F6::evaluate(Solution * solution) +{ + XReal * vars = new XReal(solution); - vector * x = new vector(numberOfVariables_) ; - vector * y = new vector(numberOfObjectives_); + vector * x = new vector(numberOfVariables_) ; + vector * y = new vector(numberOfObjectives_); - for (int i = 0; i < numberOfVariables_; i++) { - x->at(i) = vars->getValue(i); - } // for - for (int i = 0; i < numberOfObjectives_; i++) { - y->at(i) = 0.0 ; - } // for + for (int i = 0; i < numberOfVariables_; i++) + { + x->at(i) = vars->getValue(i); + } // for + for (int i = 0; i < numberOfObjectives_; i++) + { + y->at(i) = 0.0 ; + } // for - LZ09_->objective(x, y) ; + LZ09_->objective(x, y) ; - for (int i = 0; i < numberOfObjectives_; i++) - solution->setObjective(i, y->at(i)); - - delete x; - delete y; - delete vars; + for (int i = 0; i < numberOfObjectives_; i++) + solution->setObjective(i, y->at(i)); + + delete x; + delete y; + delete vars; } diff --git a/src/problems/LZ09/LZ09_F6.h b/src/problems/LZ09/LZ09_F6.h index d63a8f6..4e310da 100644 --- a/src/problems/LZ09/LZ09_F6.h +++ b/src/problems/LZ09/LZ09_F6.h @@ -31,16 +31,17 @@ #include #include -class LZ09_F6 : public Problem { +class LZ09_F6 : public Problem +{ public: - LZ09_F6(string solutionType, int ptype=31, int dtype=1, int ltype=32); - void evaluate(Solution *solution); + LZ09_F6(string solutionType, int ptype=31, int dtype=1, int ltype=32); + void evaluate(Solution *solution); - virtual ~LZ09_F6(); + virtual ~LZ09_F6(); private: - LZ09 * LZ09_ ; - double * fx_ ; - double * x_ ; + LZ09 * LZ09_ ; + double * fx_ ; + double * x_ ; }; #endif /* __LZ09_F6_H__ */ diff --git a/src/problems/LZ09/LZ09_F7.cpp b/src/problems/LZ09/LZ09_F7.cpp index 139cac9..4cb4a13 100644 --- a/src/problems/LZ09/LZ09_F7.cpp +++ b/src/problems/LZ09/LZ09_F7.cpp @@ -23,84 +23,94 @@ /** * Constructor */ -LZ09_F7::LZ09_F7(string solutionType, int ptype, int dtype, int ltype) { - numberOfVariables_ = 10; - numberOfObjectives_ = 2; - numberOfConstraints_= 0; - problemName_ = "LZ09_F7"; +LZ09_F7::LZ09_F7(string solutionType, int ptype, int dtype, int ltype) +{ + numberOfVariables_ = 10; + numberOfObjectives_ = 2; + numberOfConstraints_= 0; + problemName_ = "LZ09_F7"; - LZ09_ = new LZ09(numberOfVariables_, - numberOfObjectives_, - ptype, - dtype, - ltype) ; + LZ09_ = new LZ09(numberOfVariables_, + numberOfObjectives_, + ptype, + dtype, + ltype) ; - lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) { - cout << "LZ09_F7::LZ09_F7: Error reserving memory for storing the " - << "variable lower limits" << endl; - exit(-1); - } + lowerLimit_ = new double[numberOfVariables_]; + if (lowerLimit_ == NULL) + { + cout << "LZ09_F7::LZ09_F7: Error reserving memory for storing the " + << "variable lower limits" << endl; + exit(-1); + } - upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) { - cout << "LZ09_F7::LZ09_F7: Error reserving memory for storing the " - << "variable lower limits" << endl; - exit(-1); - } + upperLimit_ = new double[numberOfVariables_]; + if (upperLimit_ == NULL) + { + cout << "LZ09_F7::LZ09_F7: Error reserving memory for storing the " + << "variable lower limits" << endl; + exit(-1); + } - lowerLimit_[0] = 0.0; - upperLimit_[0] = 1.0; - for (int i = 1; i < numberOfVariables_; i++) { - lowerLimit_[i] = -1.0; - upperLimit_[i] = 1.0; - } + lowerLimit_[0] = 0.0; + upperLimit_[0] = 1.0; + for (int i = 1; i < numberOfVariables_; i++) + { + lowerLimit_[i] = -1.0; + upperLimit_[i] = 1.0; + } - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; - } - else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; - else { - cout << "LZ09_F7::LZ09_F7: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + { + solutionType_ = new RealSolutionType(this) ; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = new ArrayRealSolutionType(this) ; + else + { + cout << "LZ09_F7::LZ09_F7: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; + fx_ = new double[numberOfObjectives_] ; + x_ = new double[numberOfVariables_]; } // LZ09_F7::LZ09_F7 /** * Destructor */ -LZ09_F7::~LZ09_F7 () { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; - delete LZ09_ ; +LZ09_F7::~LZ09_F7 () +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; + delete LZ09_ ; } -void LZ09_F7::evaluate(Solution * solution) { - XReal * vars = new XReal(solution); +void LZ09_F7::evaluate(Solution * solution) +{ + XReal * vars = new XReal(solution); - vector * x = new vector(numberOfVariables_) ; - vector * y = new vector(numberOfObjectives_); + vector * x = new vector(numberOfVariables_) ; + vector * y = new vector(numberOfObjectives_); - for (int i = 0; i < numberOfVariables_; i++) { - x->at(i) = vars->getValue(i); - } // for - for (int i = 0; i < numberOfObjectives_; i++) { - y->at(i) = 0.0 ; - } // for + for (int i = 0; i < numberOfVariables_; i++) + { + x->at(i) = vars->getValue(i); + } // for + for (int i = 0; i < numberOfObjectives_; i++) + { + y->at(i) = 0.0 ; + } // for - LZ09_->objective(x, y) ; + LZ09_->objective(x, y) ; - for (int i = 0; i < numberOfObjectives_; i++) - solution->setObjective(i, y->at(i)); - - delete x; - delete y; - delete vars; + for (int i = 0; i < numberOfObjectives_; i++) + solution->setObjective(i, y->at(i)); + + delete x; + delete y; + delete vars; } diff --git a/src/problems/LZ09/LZ09_F7.h b/src/problems/LZ09/LZ09_F7.h index bbcefcf..125fd6d 100644 --- a/src/problems/LZ09/LZ09_F7.h +++ b/src/problems/LZ09/LZ09_F7.h @@ -31,16 +31,17 @@ #include #include -class LZ09_F7 : public Problem { +class LZ09_F7 : public Problem +{ public: - LZ09_F7(string solutionType, int ptype=21, int dtype=3, int ltype=21); - void evaluate(Solution *solution); + LZ09_F7(string solutionType, int ptype=21, int dtype=3, int ltype=21); + void evaluate(Solution *solution); - virtual ~LZ09_F7(); + virtual ~LZ09_F7(); private: - LZ09 * LZ09_ ; - double * fx_ ; - double * x_ ; + LZ09 * LZ09_ ; + double * fx_ ; + double * x_ ; }; #endif /* __LZ09_F7_H__ */ diff --git a/src/problems/LZ09/LZ09_F8.cpp b/src/problems/LZ09/LZ09_F8.cpp index 94eff24..23f1dd7 100644 --- a/src/problems/LZ09/LZ09_F8.cpp +++ b/src/problems/LZ09/LZ09_F8.cpp @@ -23,84 +23,94 @@ /** * Constructor */ -LZ09_F8::LZ09_F8(string solutionType, int ptype, int dtype, int ltype) { - numberOfVariables_ = 10; - numberOfObjectives_ = 2; - numberOfConstraints_= 0; - problemName_ = "LZ09_F8"; +LZ09_F8::LZ09_F8(string solutionType, int ptype, int dtype, int ltype) +{ + numberOfVariables_ = 10; + numberOfObjectives_ = 2; + numberOfConstraints_= 0; + problemName_ = "LZ09_F8"; - LZ09_ = new LZ09(numberOfVariables_, - numberOfObjectives_, - ptype, - dtype, - ltype) ; + LZ09_ = new LZ09(numberOfVariables_, + numberOfObjectives_, + ptype, + dtype, + ltype) ; - lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) { - cout << "LZ09_F8::LZ09_F8: Error reserving memory for storing the " - << "variable lower limits" << endl; - exit(-1); - } + lowerLimit_ = new double[numberOfVariables_]; + if (lowerLimit_ == NULL) + { + cout << "LZ09_F8::LZ09_F8: Error reserving memory for storing the " + << "variable lower limits" << endl; + exit(-1); + } - upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) { - cout << "LZ09_F8::LZ09_F8: Error reserving memory for storing the " - << "variable lower limits" << endl; - exit(-1); - } + upperLimit_ = new double[numberOfVariables_]; + if (upperLimit_ == NULL) + { + cout << "LZ09_F8::LZ09_F8: Error reserving memory for storing the " + << "variable lower limits" << endl; + exit(-1); + } - lowerLimit_[0] = 0.0; - upperLimit_[0] = 1.0; - for (int i = 1; i < numberOfVariables_; i++) { - lowerLimit_[i] = -1.0; - upperLimit_[i] = 1.0; - } + lowerLimit_[0] = 0.0; + upperLimit_[0] = 1.0; + for (int i = 1; i < numberOfVariables_; i++) + { + lowerLimit_[i] = -1.0; + upperLimit_[i] = 1.0; + } - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; - } - else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; - else { - cout << "LZ09_F8::LZ09_F8: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + { + solutionType_ = new RealSolutionType(this) ; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = new ArrayRealSolutionType(this) ; + else + { + cout << "LZ09_F8::LZ09_F8: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; + fx_ = new double[numberOfObjectives_] ; + x_ = new double[numberOfVariables_]; } // LZ09_F8::LZ09_F8 /** * Destructor */ -LZ09_F8::~LZ09_F8 () { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; - delete LZ09_ ; +LZ09_F8::~LZ09_F8 () +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; + delete LZ09_ ; } -void LZ09_F8::evaluate(Solution * solution) { - XReal * vars = new XReal(solution); +void LZ09_F8::evaluate(Solution * solution) +{ + XReal * vars = new XReal(solution); - vector * x = new vector(numberOfVariables_) ; - vector * y = new vector(numberOfObjectives_); + vector * x = new vector(numberOfVariables_) ; + vector * y = new vector(numberOfObjectives_); - for (int i = 0; i < numberOfVariables_; i++) { - x->at(i) = vars->getValue(i); - } // for - for (int i = 0; i < numberOfObjectives_; i++) { - y->at(i) = 0.0 ; - } // for + for (int i = 0; i < numberOfVariables_; i++) + { + x->at(i) = vars->getValue(i); + } // for + for (int i = 0; i < numberOfObjectives_; i++) + { + y->at(i) = 0.0 ; + } // for - LZ09_->objective(x, y) ; + LZ09_->objective(x, y) ; - for (int i = 0; i < numberOfObjectives_; i++) - solution->setObjective(i, y->at(i)); - - delete x; - delete y; - delete vars; + for (int i = 0; i < numberOfObjectives_; i++) + solution->setObjective(i, y->at(i)); + + delete x; + delete y; + delete vars; } diff --git a/src/problems/LZ09/LZ09_F8.h b/src/problems/LZ09/LZ09_F8.h index 73faea8..d68d910 100644 --- a/src/problems/LZ09/LZ09_F8.h +++ b/src/problems/LZ09/LZ09_F8.h @@ -31,16 +31,17 @@ #include #include -class LZ09_F8 : public Problem { +class LZ09_F8 : public Problem +{ public: - LZ09_F8(string solutionType, int ptype=21, int dtype=4, int ltype=21); - void evaluate(Solution *solution); + LZ09_F8(string solutionType, int ptype=21, int dtype=4, int ltype=21); + void evaluate(Solution *solution); - virtual ~LZ09_F8(); + virtual ~LZ09_F8(); private: - LZ09 * LZ09_ ; - double * fx_ ; - double * x_ ; + LZ09 * LZ09_ ; + double * fx_ ; + double * x_ ; }; #endif /* __LZ09_F8_H__ */ diff --git a/src/problems/LZ09/LZ09_F9.cpp b/src/problems/LZ09/LZ09_F9.cpp index eb1c4a4..a4f9075 100644 --- a/src/problems/LZ09/LZ09_F9.cpp +++ b/src/problems/LZ09/LZ09_F9.cpp @@ -23,85 +23,95 @@ /** * Constructor */ -LZ09_F9::LZ09_F9(string solutionType, int ptype, int dtype, int ltype) { - numberOfVariables_ = 30; - numberOfObjectives_ = 2; - numberOfConstraints_= 0; - problemName_ = "LZ09_F9"; - - LZ09_ = new LZ09(numberOfVariables_, - numberOfObjectives_, - ptype, - dtype, - ltype) ; - - lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) { - cout << "LZ09_F9::LZ09_F9: Error reserving memory for storing the " - << "variable lower limits" << endl; - exit(-1); - } - - upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) { - cout << "LZ09_F9::LZ09_F9: Error reserving memory for storing the " - << "variable lower limits" << endl; - exit(-1); - } - - lowerLimit_[0] = 0.0; - upperLimit_[0] = 1.0; - for (int i = 1; i < numberOfVariables_; i++) { - lowerLimit_[i] = -1.0; - upperLimit_[i] = 1.0; - } - - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; - } - else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; - else { - cout << "LZ09_F9::LZ09_F9: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } - - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; +LZ09_F9::LZ09_F9(string solutionType, int ptype, int dtype, int ltype) +{ + numberOfVariables_ = 30; + numberOfObjectives_ = 2; + numberOfConstraints_= 0; + problemName_ = "LZ09_F9"; + + LZ09_ = new LZ09(numberOfVariables_, + numberOfObjectives_, + ptype, + dtype, + ltype) ; + + lowerLimit_ = new double[numberOfVariables_]; + if (lowerLimit_ == NULL) + { + cout << "LZ09_F9::LZ09_F9: Error reserving memory for storing the " + << "variable lower limits" << endl; + exit(-1); + } + + upperLimit_ = new double[numberOfVariables_]; + if (upperLimit_ == NULL) + { + cout << "LZ09_F9::LZ09_F9: Error reserving memory for storing the " + << "variable lower limits" << endl; + exit(-1); + } + + lowerLimit_[0] = 0.0; + upperLimit_[0] = 1.0; + for (int i = 1; i < numberOfVariables_; i++) + { + lowerLimit_[i] = -1.0; + upperLimit_[i] = 1.0; + } + + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + { + solutionType_ = new RealSolutionType(this) ; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = new ArrayRealSolutionType(this) ; + else + { + cout << "LZ09_F9::LZ09_F9: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } + + fx_ = new double[numberOfObjectives_] ; + x_ = new double[numberOfVariables_]; } // LZ09_F9::LZ09_F9 /** * Destructor */ -LZ09_F9::~LZ09_F9 () { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; - delete LZ09_ ; +LZ09_F9::~LZ09_F9 () +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; + delete LZ09_ ; } -void LZ09_F9::evaluate(Solution * solution) { - XReal * vars = new XReal(solution); +void LZ09_F9::evaluate(Solution * solution) +{ + XReal * vars = new XReal(solution); + + vector * x = new vector(numberOfVariables_) ; + vector * y = new vector(numberOfObjectives_); + + for (int i = 0; i < numberOfVariables_; i++) + { + x->at(i) = vars->getValue(i); + } // for + for (int i = 0; i < numberOfObjectives_; i++) + { + y->at(i) = 0.0 ; + } // for - vector * x = new vector(numberOfVariables_) ; - vector * y = new vector(numberOfObjectives_); + LZ09_->objective(x, y) ; - for (int i = 0; i < numberOfVariables_; i++) { - x->at(i) = vars->getValue(i); - } // for - for (int i = 0; i < numberOfObjectives_; i++) { - y->at(i) = 0.0 ; - } // for + for (int i = 0; i < numberOfObjectives_; i++) + solution->setObjective(i, y->at(i)); - LZ09_->objective(x, y) ; + delete x; + delete y; + delete vars; - for (int i = 0; i < numberOfObjectives_; i++) - solution->setObjective(i, y->at(i)); - - delete x; - delete y; - delete vars; - } diff --git a/src/problems/LZ09/LZ09_F9.h b/src/problems/LZ09/LZ09_F9.h index 54b355f..62a9bd2 100644 --- a/src/problems/LZ09/LZ09_F9.h +++ b/src/problems/LZ09/LZ09_F9.h @@ -31,16 +31,17 @@ #include #include -class LZ09_F9 : public Problem { +class LZ09_F9 : public Problem +{ public: - LZ09_F9(string solutionType, int ptype=22, int dtype=1, int ltype=22); - void evaluate(Solution *solution); + LZ09_F9(string solutionType, int ptype=22, int dtype=1, int ltype=22); + void evaluate(Solution *solution); - virtual ~LZ09_F9(); + virtual ~LZ09_F9(); private: - LZ09 * LZ09_ ; - double * fx_ ; - double * x_ ; + LZ09 * LZ09_ ; + double * fx_ ; + double * x_ ; }; #endif /* __LZ09_F9_H__ */ diff --git a/src/problems/ProblemFactory.cpp b/src/problems/ProblemFactory.cpp index 6a0a805..5bad382 100644 --- a/src/problems/ProblemFactory.cpp +++ b/src/problems/ProblemFactory.cpp @@ -26,8 +26,9 @@ * Problem factory * @param name : Name of the problem */ -Problem * ProblemFactory::getProblem(char * name) { - return getProblem(name, 0, NULL); +Problem * ProblemFactory::getProblem(char * name) +{ + return getProblem(name, 0, NULL); } @@ -37,19 +38,26 @@ Problem * ProblemFactory::getProblem(char * name) { * @param argc : Number of arguments * @param argv : Array of arguments */ -Problem * ProblemFactory::getProblem(int argc, char ** argv) { - if (argc==2) { - return getProblem(argv[1], 0, NULL); - } else if (argc>2) { - char * argv1 = argv[1]; - for (int i=0; i2) + { + char * argv1 = argv[1]; + for (int i=0; i #include -class ProblemFactory { +class ProblemFactory +{ public: - static Problem * getProblem(char * name); - static Problem * getProblem(int argc, char ** argv); - static Problem * getProblem(char * name, int argc, char ** argv); + static Problem * getProblem(char * name); + static Problem * getProblem(int argc, char ** argv); + static Problem * getProblem(char * name, int argc, char ** argv); }; #endif // __PROBLEM_FACTORY__ diff --git a/src/problems/Schaffer.cpp b/src/problems/Schaffer.cpp index 7d19652..28f6da3 100644 --- a/src/problems/Schaffer.cpp +++ b/src/problems/Schaffer.cpp @@ -26,27 +26,31 @@ * Creates a new instance of the Schaffer problem. * @param solutionType The solution type must "Real", "BinaryReal, and "ArrayReal". */ -Schaffer::Schaffer(string solutionType) { - numberOfVariables_ = 1; - numberOfObjectives_ = 2; - numberOfConstraints_ = 0; - - lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) { - cout << "Schaffer::Schaffer. Error reserving memory for storing the array of lower limits" << endl; - exit(-1) ; - } - - upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) { - cout << "Schaffer::Schaffer. Error reserving memory for storing the array of upper limits" << endl; - exit(-1) ; - } - - int i ; - for (i = 0; i < numberOfVariables_; i++) { - lowerLimit_[i] = -10000.0; - upperLimit_[i] = 10000.0; +Schaffer::Schaffer(string solutionType) +{ + numberOfVariables_ = 1; + numberOfObjectives_ = 2; + numberOfConstraints_ = 0; + + lowerLimit_ = new double[numberOfVariables_]; + if (lowerLimit_ == NULL) + { + cout << "Schaffer::Schaffer. Error reserving memory for storing the array of lower limits" << endl; + exit(-1) ; + } + + upperLimit_ = new double[numberOfVariables_]; + if (upperLimit_ == NULL) + { + cout << "Schaffer::Schaffer. Error reserving memory for storing the array of upper limits" << endl; + exit(-1) ; + } + + int i ; + for (i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = -10000.0; + upperLimit_[i] = 10000.0; } // TO-DO: Solution type initialization @@ -57,10 +61,11 @@ Schaffer::Schaffer(string solutionType) { /** * Destructor */ -Schaffer::~Schaffer() { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; +Schaffer::~Schaffer() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; } // ~Schaffer @@ -68,24 +73,26 @@ Schaffer::~Schaffer() { * Evaluates a solution * @param solution The solution to evaluate */ -void Schaffer::evaluate(Solution *solution) { +void Schaffer::evaluate(Solution *solution) +{ - double *fx; - Variable **variables = solution->getDecisionVariables(); + double *fx; + Variable **variables = solution->getDecisionVariables(); - fx = new double[numberOfObjectives_]; - if (fx == NULL) { - cout << "Schaffer::evaluate: Error reserving memory while evaluating the problem" << endl; + fx = new double[numberOfObjectives_]; + if (fx == NULL) + { + cout << "Schaffer::evaluate: Error reserving memory while evaluating the problem" << endl; exit(-1); - } + } - fx[0] = variables[0]->getValue() * variables[0]->getValue() ; - fx[1] = (variables[0]->getValue() - 2.0) * (variables[0]->getValue() - 2.0); + fx[0] = variables[0]->getValue() * variables[0]->getValue() ; + fx[1] = (variables[0]->getValue() - 2.0) * (variables[0]->getValue() - 2.0); - solution->setObjective(0,fx[0]); - solution->setObjective(1,fx[1]); + solution->setObjective(0,fx[0]); + solution->setObjective(1,fx[1]); - delete [] fx; + delete [] fx; } // evaluate diff --git a/src/problems/Schaffer.h b/src/problems/Schaffer.h index 95ae4e9..048826e 100644 --- a/src/problems/Schaffer.h +++ b/src/problems/Schaffer.h @@ -31,12 +31,13 @@ * @class Schaffer * @brief Class representing problem Schaffer **/ -class Schaffer : public Problem { +class Schaffer : public Problem +{ public: - Schaffer(string solutionType); - ~Schaffer(); - void evaluate(Solution *solution); + Schaffer(string solutionType); + ~Schaffer(); + void evaluate(Solution *solution); }; #endif diff --git a/src/problems/Srinivas.cpp b/src/problems/Srinivas.cpp index 3030b4e..e4c1354 100644 --- a/src/problems/Srinivas.cpp +++ b/src/problems/Srinivas.cpp @@ -3,7 +3,7 @@ // Authors: // Esteban López-Camacho // Antonio J. Nebro -// +// // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // // This program is free software: you can redistribute it and/or modify @@ -15,7 +15,7 @@ // 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 program. If not, see . @@ -26,47 +26,57 @@ * Creates a new instance of the Srinivas problem. * @param solutionType The solution type must "Real" or "BinaryReal */ -Srinivas::Srinivas(string solutionType) { - numberOfVariables_ = 2; - numberOfObjectives_ = 2; - numberOfConstraints_ = 2; - problemName_ = "Srinivas"; - - lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) { - cout << "Srinivas::Srinivas. Error reserving memory for storing the array of lower limits" << endl; - exit(-1) ; - } - - upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) { - cout << "Srinivas::Srinivas. Error reserving memory for storing the array of upper limits" << endl; - exit(-1) ; - } - - for (int var = 0; var < numberOfVariables_; var++){ - lowerLimit_[var] = -20.0; - upperLimit_[var] = 20.0; - } // for - - if (solutionType.compare("BinaryReal")==0) { - solutionType_ = new BinaryRealSolutionType(this); - } else if (solutionType.compare("Real")==0) { - solutionType_ = new RealSolutionType(this); - } else { - cout << "Error: solution type " << solutionType << " invalid" << endl; - exit(-1); - } +Srinivas::Srinivas(string solutionType) +{ + numberOfVariables_ = 2; + numberOfObjectives_ = 2; + numberOfConstraints_ = 2; + problemName_ = "Srinivas"; + + lowerLimit_ = new double[numberOfVariables_]; + if (lowerLimit_ == NULL) + { + cout << "Srinivas::Srinivas. Error reserving memory for storing the array of lower limits" << endl; + exit(-1) ; + } + + upperLimit_ = new double[numberOfVariables_]; + if (upperLimit_ == NULL) + { + cout << "Srinivas::Srinivas. Error reserving memory for storing the array of upper limits" << endl; + exit(-1) ; + } + + for (int var = 0; var < numberOfVariables_; var++) + { + lowerLimit_[var] = -20.0; + upperLimit_[var] = 20.0; + } // for + + if (solutionType.compare("BinaryReal")==0) + { + solutionType_ = new BinaryRealSolutionType(this); + } + else if (solutionType.compare("Real")==0) + { + solutionType_ = new RealSolutionType(this); + } + else + { + cout << "Error: solution type " << solutionType << " invalid" << endl; + exit(-1); + } } // Srinivas /** * Destructor */ -Srinivas::~Srinivas() { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; +Srinivas::~Srinivas() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; } // ~Srinivas @@ -74,61 +84,67 @@ Srinivas::~Srinivas() { * Evaluates a solution * @param solution The solution to evaluate */ -void Srinivas::evaluate(Solution *solution) { - - Variable **variables = solution->getDecisionVariables(); - - double * fx = new double[numberOfObjectives_]; - if (fx == NULL) { - cout << "Srinivas::evaluate: Error reserving memory while evaluating the problem" << endl; +void Srinivas::evaluate(Solution *solution) +{ + + Variable **variables = solution->getDecisionVariables(); + + double * fx = new double[numberOfObjectives_]; + if (fx == NULL) + { + cout << "Srinivas::evaluate: Error reserving memory while evaluating the problem" << endl; exit(-1); - } - - double * x = new double[numberOfVariables_]; - if (x == NULL) { - cout << "Srinivas::evaluate: Error reserving memory for the variable values array" << endl; - exit(-1); - } // if - - double x1 = variables[0]->getValue(); - double x2 = variables[1]->getValue(); - - fx[0] = 2.0 + (x1-2.0)*(x1-2.0) + (x2-1.0)*(x2-1.0); - fx[1] = 9.0 * x1 - (x2-1.0)*(x2-1.0); - - solution->setObjective(0,fx[0]); - solution->setObjective(1,fx[1]); - - delete[]fx; - delete[]x; - + } + + double * x = new double[numberOfVariables_]; + if (x == NULL) + { + cout << "Srinivas::evaluate: Error reserving memory for the variable values array" << endl; + exit(-1); + } // if + + double x1 = variables[0]->getValue(); + double x2 = variables[1]->getValue(); + + fx[0] = 2.0 + (x1-2.0)*(x1-2.0) + (x2-1.0)*(x2-1.0); + fx[1] = 9.0 * x1 - (x2-1.0)*(x2-1.0); + + solution->setObjective(0,fx[0]); + solution->setObjective(1,fx[1]); + + delete[]fx; + delete[]x; + } // evaluate /** * Evaluates the constraint overhead of a solution * @param solution The solution */ -void Srinivas::evaluateConstraints(Solution *solution) { - - double * constraint = new double[this->getNumberOfConstraints()]; - - double x1 = solution->getDecisionVariables()[0]->getValue(); - double x2 = solution->getDecisionVariables()[1]->getValue(); - - constraint[0] = 1.0 - (x1*x1 + x2*x2)/225.0; - constraint[1] = (3.0*x2 - x1)/10.0 - 1.0; - - int number = 0; - double total = 0.0; - for (int i = 0; i < this->getNumberOfConstraints(); i++) { - if (constraint[i]<0.0){ - number++; - total+=constraint[i]; +void Srinivas::evaluateConstraints(Solution *solution) +{ + + double * constraint = new double[this->getNumberOfConstraints()]; + + double x1 = solution->getDecisionVariables()[0]->getValue(); + double x2 = solution->getDecisionVariables()[1]->getValue(); + + constraint[0] = 1.0 - (x1*x1 + x2*x2)/225.0; + constraint[1] = (3.0*x2 - x1)/10.0 - 1.0; + + int number = 0; + double total = 0.0; + for (int i = 0; i < this->getNumberOfConstraints(); i++) + { + if (constraint[i]<0.0) + { + number++; + total+=constraint[i]; + } } - } - - solution->setOverallConstraintViolation(total); - solution->setNumberOfViolatedConstraints(number); - delete [] constraint; + + solution->setOverallConstraintViolation(total); + solution->setNumberOfViolatedConstraints(number); + delete [] constraint; } // evaluateConstraints diff --git a/src/problems/Srinivas.h b/src/problems/Srinivas.h index e06a999..eaf247a 100644 --- a/src/problems/Srinivas.h +++ b/src/problems/Srinivas.h @@ -3,7 +3,7 @@ // Authors: // Esteban López-Camacho // Antonio J. Nebro -// +// // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // // This program is free software: you can redistribute it and/or modify @@ -15,7 +15,7 @@ // 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 program. If not, see . @@ -36,13 +36,14 @@ using namespace std; * @class Srinivas * @brief Class representing problem Srinivas **/ -class Srinivas : public Problem { - +class Srinivas : public Problem +{ + public: - Srinivas(string solutionType); - ~Srinivas(); - void evaluate(Solution *solution); - void evaluateConstraints(Solution * solution); + Srinivas(string solutionType); + ~Srinivas(); + void evaluate(Solution *solution); + void evaluateConstraints(Solution * solution); }; #endif /* __SRINIVAS__ */ diff --git a/src/problems/Tanaka.cpp b/src/problems/Tanaka.cpp index f029da6..dbcc398 100644 --- a/src/problems/Tanaka.cpp +++ b/src/problems/Tanaka.cpp @@ -3,7 +3,7 @@ // Authors: // Esteban López-Camacho // Antonio J. Nebro -// +// // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // // This program is free software: you can redistribute it and/or modify @@ -15,7 +15,7 @@ // 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 program. If not, see . @@ -28,47 +28,57 @@ const double Tanaka::PI = 3.141592653589793; * Creates a new instance of the Tanaka problem. * @param solutionType The solution type must "Real" or "BinaryReal */ -Tanaka::Tanaka(string solutionType) { - numberOfVariables_ = 2; - numberOfObjectives_ = 2; - numberOfConstraints_ = 2; - problemName_ = "Tanaka"; - - lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) { - cout << "Tanaka::Tanaka. Error reserving memory for storing the array of lower limits" << endl; - exit(-1) ; - } - - upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) { - cout << "Tanaka::Tanaka. Error reserving memory for storing the array of upper limits" << endl; - exit(-1) ; - } - - for (int var = 0; var < numberOfVariables_; var++){ - lowerLimit_[var] = 10e-5; - upperLimit_[var] = PI; - } // for - - if (solutionType.compare("BinaryReal")==0) { - solutionType_ = new BinaryRealSolutionType(this); - } else if (solutionType.compare("Real")==0) { - solutionType_ = new RealSolutionType(this); - } else { - cout << "Error: solution type " << solutionType << " invalid" << endl; - exit(-1); - } +Tanaka::Tanaka(string solutionType) +{ + numberOfVariables_ = 2; + numberOfObjectives_ = 2; + numberOfConstraints_ = 2; + problemName_ = "Tanaka"; + + lowerLimit_ = new double[numberOfVariables_]; + if (lowerLimit_ == NULL) + { + cout << "Tanaka::Tanaka. Error reserving memory for storing the array of lower limits" << endl; + exit(-1) ; + } + + upperLimit_ = new double[numberOfVariables_]; + if (upperLimit_ == NULL) + { + cout << "Tanaka::Tanaka. Error reserving memory for storing the array of upper limits" << endl; + exit(-1) ; + } + + for (int var = 0; var < numberOfVariables_; var++) + { + lowerLimit_[var] = 10e-5; + upperLimit_[var] = PI; + } // for + + if (solutionType.compare("BinaryReal")==0) + { + solutionType_ = new BinaryRealSolutionType(this); + } + else if (solutionType.compare("Real")==0) + { + solutionType_ = new RealSolutionType(this); + } + else + { + cout << "Error: solution type " << solutionType << " invalid" << endl; + exit(-1); + } } // Tanaka /** * Destructor */ -Tanaka::~Tanaka() { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; +Tanaka::~Tanaka() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; } // ~Tanaka @@ -76,53 +86,58 @@ Tanaka::~Tanaka() { * Evaluates a solution * @param solution The solution to evaluate */ -void Tanaka::evaluate(Solution *solution) { - - Variable **variables = solution->getDecisionVariables(); - - double * fx = new double[numberOfObjectives_]; - if (fx == NULL) { - cout << "Tanaka::evaluate: Error reserving memory while evaluating the problem" << endl; +void Tanaka::evaluate(Solution *solution) +{ + + Variable **variables = solution->getDecisionVariables(); + + double * fx = new double[numberOfObjectives_]; + if (fx == NULL) + { + cout << "Tanaka::evaluate: Error reserving memory while evaluating the problem" << endl; exit(-1); - } - - fx[0] = variables[0]->getValue(); - fx[1] = variables[1]->getValue(); - - solution->setObjective(0,fx[0]); - solution->setObjective(1,fx[1]); - - delete[]fx ; - + } + + fx[0] = variables[0]->getValue(); + fx[1] = variables[1]->getValue(); + + solution->setObjective(0,fx[0]); + solution->setObjective(1,fx[1]); + + delete[]fx ; + } // evaluate /** * Evaluates the constraint overhead of a solution * @param solution The solution */ -void Tanaka::evaluateConstraints(Solution *solution) { - - double * constraint = new double[this->getNumberOfConstraints()]; - - double x1 = solution->getDecisionVariables()[0]->getValue(); - double x2 = solution->getDecisionVariables()[1]->getValue(); - - constraint[0] = (x1*x1 + x2*x2 - 1.0 - 0.1*cos(16.0*atan(x1/x2))); - constraint[1] = - 2.0 * ( (x1-0.5)*(x1-0.5) + (x2-0.5)*(x2-0.5) - 0.5); - - int number = 0; - double total = 0.0; - for (int i = 0; i < this->getNumberOfConstraints(); i++) { - if (constraint[i]<0.0){ - number++; - total+=constraint[i]; +void Tanaka::evaluateConstraints(Solution *solution) +{ + + double * constraint = new double[this->getNumberOfConstraints()]; + + double x1 = solution->getDecisionVariables()[0]->getValue(); + double x2 = solution->getDecisionVariables()[1]->getValue(); + + constraint[0] = (x1*x1 + x2*x2 - 1.0 - 0.1*cos(16.0*atan(x1/x2))); + constraint[1] = - 2.0 * ( (x1-0.5)*(x1-0.5) + (x2-0.5)*(x2-0.5) - 0.5); + + int number = 0; + double total = 0.0; + for (int i = 0; i < this->getNumberOfConstraints(); i++) + { + if (constraint[i]<0.0) + { + number++; + total+=constraint[i]; + } } - } - - delete [] constraint; - - solution->setOverallConstraintViolation(total); - solution->setNumberOfViolatedConstraints(number); - + + delete [] constraint; + + solution->setOverallConstraintViolation(total); + solution->setNumberOfViolatedConstraints(number); + } // evaluateConstraints diff --git a/src/problems/Tanaka.h b/src/problems/Tanaka.h index e122aba..c5aba6a 100644 --- a/src/problems/Tanaka.h +++ b/src/problems/Tanaka.h @@ -3,7 +3,7 @@ // Authors: // Esteban López-Camacho // Antonio J. Nebro -// +// // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // // This program is free software: you can redistribute it and/or modify @@ -15,7 +15,7 @@ // 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 program. If not, see . @@ -37,17 +37,18 @@ using namespace std; * @class Tanaka * @brief Class representing problem Tanaka **/ -class Tanaka : public Problem { +class Tanaka : public Problem +{ private: - static const double PI; - + static const double PI; + public: - Tanaka(string solutionType); - ~Tanaka(); - void evaluate(Solution *solution); - void evaluateConstraints(Solution * solution); - + Tanaka(string solutionType); + ~Tanaka(); + void evaluate(Solution *solution); + void evaluateConstraints(Solution * solution); + }; #endif /* __TANAKA__ */ diff --git a/src/problems/ZDT/ZDT1.cpp b/src/problems/ZDT/ZDT1.cpp index 3bda639..718236d 100644 --- a/src/problems/ZDT/ZDT1.cpp +++ b/src/problems/ZDT/ZDT1.cpp @@ -20,82 +20,92 @@ #include -ZDT1::ZDT1(string solutionType, int numberOfVariables) { - numberOfVariables_ = numberOfVariables; - numberOfObjectives_ = 2; - numberOfConstraints_ = 0; - problemName_ = "ZDT1"; +ZDT1::ZDT1(string solutionType, int numberOfVariables) +{ + numberOfVariables_ = numberOfVariables; + numberOfObjectives_ = 2; + numberOfConstraints_ = 0; + problemName_ = "ZDT1"; - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } + lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (lowerLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } + upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (upperLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } - for (int i = 0; i < numberOfVariables_; i++) { - lowerLimit_[i] = 0.0; - upperLimit_[i] = 1.0; - } + for (int i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = 0.0; + upperLimit_[i] = 1.0; + } - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; - //cout << "Tipo seleccionado Real" << endl; - } - else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; - else { - cout << "Error: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } - fx_ = new double[numberOfObjectives_] ; + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + { + solutionType_ = new RealSolutionType(this) ; + //cout << "Tipo seleccionado Real" << endl; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = new ArrayRealSolutionType(this) ; + else + { + cout << "Error: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } + fx_ = new double[numberOfObjectives_] ; } -ZDT1::~ZDT1() { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; - delete [] fx_ ; +ZDT1::~ZDT1() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; + delete [] fx_ ; } /** * Evaluates a solution * @param solution The solution to evaluate */ -void ZDT1::evaluate(Solution *solution) { - XReal * x = new XReal(solution); +void ZDT1::evaluate(Solution *solution) +{ + XReal * x = new XReal(solution); - fx_[0] = x->getValue(0) ; - double g = evalG(x) ; - double h = evalH(fx_[0], g) ; - fx_[1] = h * g ; + fx_[0] = x->getValue(0) ; + double g = evalG(x) ; + double h = evalH(fx_[0], g) ; + fx_[1] = h * g ; - solution->setObjective(0,fx_[0]); - solution->setObjective(1,fx_[1]); + solution->setObjective(0,fx_[0]); + solution->setObjective(1,fx_[1]); - delete x ; + delete x ; } // evaluate -double ZDT1::evalG(XReal * x) { - double g = 0.0 ; - for (int i = 1; i < x->getNumberOfDecisionVariables(); i++) - g += x->getValue(i) ; +double ZDT1::evalG(XReal * x) +{ + double g = 0.0 ; + for (int i = 1; i < x->getNumberOfDecisionVariables(); i++) + g += x->getValue(i) ; - double c = 9.0/(numberOfVariables_ - 1) ; - g = c * g ; - g = g + 1.0 ; - return g; + double c = 9.0/(numberOfVariables_ - 1) ; + g = c * g ; + g = g + 1.0 ; + return g; } -double ZDT1::evalH(double f, double g) { - double h = 0.0 ; - h = 1.0 - sqrt(f/g) ; - return h ; +double ZDT1::evalH(double f, double g) +{ + double h = 0.0 ; + h = 1.0 - sqrt(f/g) ; + return h ; } diff --git a/src/problems/ZDT/ZDT1.h b/src/problems/ZDT/ZDT1.h index 1696746..6503143 100644 --- a/src/problems/ZDT/ZDT1.h +++ b/src/problems/ZDT/ZDT1.h @@ -29,17 +29,18 @@ #include #include -class ZDT1 : public Problem { +class ZDT1 : public Problem +{ private: - double evalG(XReal *x) ; - double evalH(double f, double g) ; - double * fx_ ; + double evalG(XReal *x) ; + double evalH(double f, double g) ; + double * fx_ ; public: - ZDT1(string solutionType, int numberOfVariables = 30); - void evaluate(Solution *solution); + ZDT1(string solutionType, int numberOfVariables = 30); + void evaluate(Solution *solution); - ~ZDT1(); + ~ZDT1(); }; #endif /* ZDT1_H_ */ diff --git a/src/problems/ZDT/ZDT2.cpp b/src/problems/ZDT/ZDT2.cpp index c22a061..ae25a4f 100644 --- a/src/problems/ZDT/ZDT2.cpp +++ b/src/problems/ZDT/ZDT2.cpp @@ -20,84 +20,94 @@ #include -ZDT2::ZDT2(string solutionType, int numberOfVariables) { - numberOfVariables_ = numberOfVariables; - numberOfObjectives_ = 2; - numberOfConstraints_ = 0; - problemName_ = "ZDT2"; - - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } - - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } - - for (int i = 0; i < numberOfVariables_; i++) { - lowerLimit_[i] = 0.0; - upperLimit_[i] = 1.0; - } - - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; - //cout << "Tipo seleccionado Real" << endl; - } - else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; - else { - cout << "Error: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } - fx_ = new double[numberOfObjectives_] ; +ZDT2::ZDT2(string solutionType, int numberOfVariables) +{ + numberOfVariables_ = numberOfVariables; + numberOfObjectives_ = 2; + numberOfConstraints_ = 0; + problemName_ = "ZDT2"; + + lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (lowerLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (upperLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + for (int i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = 0.0; + upperLimit_[i] = 1.0; + } + + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + { + solutionType_ = new RealSolutionType(this) ; + //cout << "Tipo seleccionado Real" << endl; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = new ArrayRealSolutionType(this) ; + else + { + cout << "Error: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } + fx_ = new double[numberOfObjectives_] ; } -ZDT2::~ZDT2() { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; - delete [] fx_ ; +ZDT2::~ZDT2() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; + delete [] fx_ ; } /** * Evaluates a solution * @param solution The solution to evaluate */ -void ZDT2::evaluate(Solution *solution) { - XReal * x = new XReal(solution); +void ZDT2::evaluate(Solution *solution) +{ + XReal * x = new XReal(solution); - fx_[0] = x->getValue(0) ; - double g = evalG(x) ; - double h = evalH(fx_[0], g) ; - fx_[1] = h * g ; + fx_[0] = x->getValue(0) ; + double g = evalG(x) ; + double h = evalH(fx_[0], g) ; + fx_[1] = h * g ; - solution->setObjective(0,fx_[0]); - solution->setObjective(1,fx_[1]); + solution->setObjective(0,fx_[0]); + solution->setObjective(1,fx_[1]); - delete x ; + delete x ; } // evaluate -double ZDT2::evalG(XReal * x) { - double g = 0.0 ; - for (int i = 1; i < x->getNumberOfDecisionVariables(); i++) - g += x->getValue(i) ; +double ZDT2::evalG(XReal * x) +{ + double g = 0.0 ; + for (int i = 1; i < x->getNumberOfDecisionVariables(); i++) + g += x->getValue(i) ; - double c = 9.0/(numberOfVariables_ - 1) ; - g = c * g ; - g = g + 1.0 ; - return g; + double c = 9.0/(numberOfVariables_ - 1) ; + g = c * g ; + g = g + 1.0 ; + return g; } -double ZDT2::evalH(double f, double g) { - double h = 0.0 ; - h = 1.0 - pow(f/g, 2.0) ; - return h ; +double ZDT2::evalH(double f, double g) +{ + double h = 0.0 ; + h = 1.0 - pow(f/g, 2.0) ; + return h ; } diff --git a/src/problems/ZDT/ZDT2.h b/src/problems/ZDT/ZDT2.h index 31c6119..d082c8e 100644 --- a/src/problems/ZDT/ZDT2.h +++ b/src/problems/ZDT/ZDT2.h @@ -30,17 +30,18 @@ #include -class ZDT2 : public Problem{ +class ZDT2 : public Problem +{ private: - double evalG(XReal *x) ; - double evalH(double f, double g) ; - double * fx_ ; + double evalG(XReal *x) ; + double evalH(double f, double g) ; + double * fx_ ; public: - ZDT2(string solutionType, int numberOfVariables = 30); - void evaluate(Solution *solution); + ZDT2(string solutionType, int numberOfVariables = 30); + void evaluate(Solution *solution); - virtual ~ZDT2(); + virtual ~ZDT2(); }; #endif /* __ZDT2_H__ */ diff --git a/src/problems/ZDT/ZDT3.cpp b/src/problems/ZDT/ZDT3.cpp index e6d7b46..6518d63 100644 --- a/src/problems/ZDT/ZDT3.cpp +++ b/src/problems/ZDT/ZDT3.cpp @@ -22,83 +22,93 @@ const double ZDT3::PI = 3.141592653589793; -ZDT3::ZDT3(string solutionType, int numberOfVariables) { - numberOfVariables_ = numberOfVariables; - numberOfObjectives_ = 2; - numberOfConstraints_ = 0; - problemName_ = "ZDT3"; - - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } - - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } - - for (int i = 0; i < numberOfVariables_; i++) { - lowerLimit_[i] = 0.0; - upperLimit_[i] = 1.0; - } - - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; - //cout << "Tipo seleccionado Real" << endl; - } - else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; - else { - cout << "Error: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } - fx_ = new double[numberOfObjectives_] ; +ZDT3::ZDT3(string solutionType, int numberOfVariables) +{ + numberOfVariables_ = numberOfVariables; + numberOfObjectives_ = 2; + numberOfConstraints_ = 0; + problemName_ = "ZDT3"; + + lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (lowerLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (upperLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + for (int i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = 0.0; + upperLimit_[i] = 1.0; + } + + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + { + solutionType_ = new RealSolutionType(this) ; + //cout << "Tipo seleccionado Real" << endl; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = new ArrayRealSolutionType(this) ; + else + { + cout << "Error: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } + fx_ = new double[numberOfObjectives_] ; } -ZDT3::~ZDT3() { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; - delete [] fx_ ; +ZDT3::~ZDT3() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; + delete [] fx_ ; } /** * Evaluates a solution * @param solution The solution to evaluate */ -void ZDT3::evaluate(Solution *solution) { - XReal * x = new XReal(solution); +void ZDT3::evaluate(Solution *solution) +{ + XReal * x = new XReal(solution); - fx_[0] = x->getValue(0) ; - double g = evalG(x) ; - double h = evalH(fx_[0], g) ; - fx_[1] = h * g ; + fx_[0] = x->getValue(0) ; + double g = evalG(x) ; + double h = evalH(fx_[0], g) ; + fx_[1] = h * g ; - solution->setObjective(0,fx_[0]); - solution->setObjective(1,fx_[1]); + solution->setObjective(0,fx_[0]); + solution->setObjective(1,fx_[1]); - delete x ; + delete x ; } // evaluate -double ZDT3::evalG(XReal * x) { - double g = 0.0 ; - for (int i = 1; i < x->getNumberOfDecisionVariables(); i++) - g += x->getValue(i) ; +double ZDT3::evalG(XReal * x) +{ + double g = 0.0 ; + for (int i = 1; i < x->getNumberOfDecisionVariables(); i++) + g += x->getValue(i) ; - double c = 9.0/(numberOfVariables_ - 1) ; - g = c * g ; - g = g + 1.0 ; - return g; + double c = 9.0/(numberOfVariables_ - 1) ; + g = c * g ; + g = g + 1.0 ; + return g; } -double ZDT3::evalH(double f, double g) { - double h = 0.0 ; - h = 1.0 - sqrt(f/g) - (f/g)*sin(10.0*PI*f); - return h ; +double ZDT3::evalH(double f, double g) +{ + double h = 0.0 ; + h = 1.0 - sqrt(f/g) - (f/g)*sin(10.0*PI*f); + return h ; } diff --git a/src/problems/ZDT/ZDT3.h b/src/problems/ZDT/ZDT3.h index 87ddd72..e9e6131 100644 --- a/src/problems/ZDT/ZDT3.h +++ b/src/problems/ZDT/ZDT3.h @@ -31,17 +31,18 @@ #include -class ZDT3 : public Problem { +class ZDT3 : public Problem +{ private: - double evalG(XReal *x) ; - double evalH(double f, double g) ; - double * fx_ ; - static const double PI ; + double evalG(XReal *x) ; + double evalH(double f, double g) ; + double * fx_ ; + static const double PI ; public: - ZDT3(string solutionType, int numberOfVariables = 30); - void evaluate(Solution *solution); - virtual ~ZDT3(); + ZDT3(string solutionType, int numberOfVariables = 30); + void evaluate(Solution *solution); + virtual ~ZDT3(); }; #endif /* __ZDT3_H__ */ diff --git a/src/problems/ZDT/ZDT4.cpp b/src/problems/ZDT/ZDT4.cpp index bb17a62..739d5a0 100644 --- a/src/problems/ZDT/ZDT4.cpp +++ b/src/problems/ZDT/ZDT4.cpp @@ -22,84 +22,94 @@ const double ZDT4::PI = 3.141592653589793; -ZDT4::ZDT4(string solutionType, int numberOfVariables) { - numberOfVariables_ = numberOfVariables; - numberOfObjectives_ = 2; - numberOfConstraints_ = 0; - problemName_ = "ZDT4"; - - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } - - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } - - lowerLimit_[0] = 0.0; - upperLimit_[0] = 1.0; - for (int i = 1; i < numberOfVariables_; i++) { - lowerLimit_[i] = -5.0; - upperLimit_[i] = 5.0; - } - - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; - //cout << "Tipo seleccionado Real" << endl; - } - else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; - else { - cout << "Error: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } - fx_ = new double[numberOfObjectives_] ; +ZDT4::ZDT4(string solutionType, int numberOfVariables) +{ + numberOfVariables_ = numberOfVariables; + numberOfObjectives_ = 2; + numberOfConstraints_ = 0; + problemName_ = "ZDT4"; + + lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (lowerLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (upperLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + lowerLimit_[0] = 0.0; + upperLimit_[0] = 1.0; + for (int i = 1; i < numberOfVariables_; i++) + { + lowerLimit_[i] = -5.0; + upperLimit_[i] = 5.0; + } + + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + { + solutionType_ = new RealSolutionType(this) ; + //cout << "Tipo seleccionado Real" << endl; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = new ArrayRealSolutionType(this) ; + else + { + cout << "Error: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } + fx_ = new double[numberOfObjectives_] ; } -ZDT4::~ZDT4() { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; - delete [] fx_ ; +ZDT4::~ZDT4() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; + delete [] fx_ ; } /** * Evaluates a solution * @param solution The solution to evaluate */ -void ZDT4::evaluate(Solution *solution) { - XReal * x = new XReal(solution); - double * fx = new double[numberOfObjectives_] ; +void ZDT4::evaluate(Solution *solution) +{ + XReal * x = new XReal(solution); + double * fx = new double[numberOfObjectives_] ; - fx_[0] = x->getValue(0) ; - double g = evalG(x) ; - double h = evalH(fx_[0], g) ; - fx_[1] = h * g ; + fx_[0] = x->getValue(0) ; + double g = evalG(x) ; + double h = evalH(fx_[0], g) ; + fx_[1] = h * g ; - solution->setObjective(0,fx_[0]); - solution->setObjective(1,fx_[1]); + solution->setObjective(0,fx_[0]); + solution->setObjective(1,fx_[1]); - delete [] fx ; - delete x ; + delete [] fx ; + delete x ; } // evaluate -double ZDT4::evalG(XReal * x) { - double g = 0.0 ; - for (int i = 1; i < x->getNumberOfDecisionVariables(); i++) - g += pow(x->getValue(i), 2.0) - - 10.0 * cos(4.0 * PI * x->getValue(i)); +double ZDT4::evalG(XReal * x) +{ + double g = 0.0 ; + for (int i = 1; i < x->getNumberOfDecisionVariables(); i++) + g += pow(x->getValue(i), 2.0) - + 10.0 * cos(4.0 * PI * x->getValue(i)); - double c = 1.0 + 10.0 * (numberOfVariables_ - 1) ; - return g + c; + double c = 1.0 + 10.0 * (numberOfVariables_ - 1) ; + return g + c; } -double ZDT4::evalH(double f, double g) { - return 1.0 - sqrt(f/g) ; +double ZDT4::evalH(double f, double g) +{ + return 1.0 - sqrt(f/g) ; } diff --git a/src/problems/ZDT/ZDT4.h b/src/problems/ZDT/ZDT4.h index cb45a96..7d751b1 100644 --- a/src/problems/ZDT/ZDT4.h +++ b/src/problems/ZDT/ZDT4.h @@ -31,17 +31,18 @@ #include -class ZDT4 : public Problem { +class ZDT4 : public Problem +{ private: - double evalG(XReal *x) ; - double evalH(double f, double g) ; - double * fx_ ; - static const double PI ; + double evalG(XReal *x) ; + double evalH(double f, double g) ; + double * fx_ ; + static const double PI ; public: - ZDT4(string solutionType, int numberOfVariables = 10); - void evaluate(Solution *solution); - virtual ~ZDT4(); + ZDT4(string solutionType, int numberOfVariables = 10); + void evaluate(Solution *solution); + virtual ~ZDT4(); }; #endif /* __ZDT4_H__ */ diff --git a/src/problems/ZDT/ZDT5.cpp b/src/problems/ZDT/ZDT5.cpp index ad71de1..16cc6f3 100644 --- a/src/problems/ZDT/ZDT5.cpp +++ b/src/problems/ZDT/ZDT5.cpp @@ -20,77 +20,89 @@ #include "ZDT5.h" -ZDT5::ZDT5(string solutionType, int numberOfVariables) { - cout << "Solutiontype: " << solutionType << endl ; - numberOfVariables_ = numberOfVariables; - numberOfObjectives_ = 2; - numberOfConstraints_ = 0; - problemName_ = "ZDT5"; - - cout << "Problem: " << problemName_ << endl ; - - length_ = new int[numberOfVariables_]; - length_[0] = 30; - for (int var = 1; var < numberOfVariables_; var++) { - length_[var] = 5; - } - - if (solutionType.compare("Binary") == 0) - solutionType_ = new BinarySolutionType(this) ; - else { - cout << "Error: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } - fx_ = new double[numberOfObjectives_] ; +ZDT5::ZDT5(string solutionType, int numberOfVariables) +{ + cout << "Solutiontype: " << solutionType << endl ; + numberOfVariables_ = numberOfVariables; + numberOfObjectives_ = 2; + numberOfConstraints_ = 0; + problemName_ = "ZDT5"; + + cout << "Problem: " << problemName_ << endl ; + + length_ = new int[numberOfVariables_]; + length_[0] = 30; + for (int var = 1; var < numberOfVariables_; var++) + { + length_[var] = 5; + } + + if (solutionType.compare("Binary") == 0) + solutionType_ = new BinarySolutionType(this) ; + else + { + cout << "Error: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } + fx_ = new double[numberOfObjectives_] ; } // ZDT5::ZDT5 -ZDT5::~ZDT5() { - delete [] length_ ; - delete [] fx_ ; +ZDT5::~ZDT5() +{ + delete [] length_ ; + delete [] fx_ ; } /** * Evaluates a solution * @param solution The solution to evaluate */ -void ZDT5::evaluate(Solution *solution) { - Binary * variable ; - int counter ; +void ZDT5::evaluate(Solution *solution) +{ + Binary * variable ; + int counter ; - variable = (Binary *)(solution->getDecisionVariables()[0]) ; + variable = (Binary *)(solution->getDecisionVariables()[0]) ; - fx_[0] = 1 + variable->cardinality(); + fx_[0] = 1 + variable->cardinality(); - double g = evalG(solution) ; - double h = evalH(fx_[0],g) ; - fx_[1] = h * g ; + double g = evalG(solution) ; + double h = evalH(fx_[0],g) ; + fx_[1] = h * g ; - solution->setObjective(0,fx_[0]); - solution->setObjective(1,fx_[1]); + solution->setObjective(0,fx_[0]); + solution->setObjective(1,fx_[1]); } // evaluate -double ZDT5::evalG(Solution * solution) { - double res = 0.0; - Binary * variable ; +double ZDT5::evalG(Solution * solution) +{ + double res = 0.0; + Binary * variable ; - for (int i = 1; i < numberOfVariables_; i++) { - variable = (Binary *)(solution->getDecisionVariables()[i]) ; - res += evalV(variable->cardinality()); - } + for (int i = 1; i < numberOfVariables_; i++) + { + variable = (Binary *)(solution->getDecisionVariables()[i]) ; + res += evalV(variable->cardinality()); + } - return res; + return res; } -double ZDT5::evalH(double f, double g) { - return 1 / f; +double ZDT5::evalH(double f, double g) +{ + return 1 / f; } -double ZDT5::evalV(double value) { - if (value < 5.0) { - return 2.0 + value; - } else { - return 1.0; - } +double ZDT5::evalV(double value) +{ + if (value < 5.0) + { + return 2.0 + value; + } + else + { + return 1.0; + } } diff --git a/src/problems/ZDT/ZDT5.h b/src/problems/ZDT/ZDT5.h index 2ca5806..eff8874 100644 --- a/src/problems/ZDT/ZDT5.h +++ b/src/problems/ZDT/ZDT5.h @@ -27,18 +27,19 @@ #include #include -class ZDT5 : public Problem { +class ZDT5 : public Problem +{ private: - double evalG(Solution *x) ; - double evalH(double f, double g) ; - double evalV(double) ; + double evalG(Solution *x) ; + double evalH(double f, double g) ; + double evalV(double) ; - double * fx_ ; + double * fx_ ; public: - ZDT5(string solutionType, int numberOfVariables = 11); - void evaluate(Solution *solution); + ZDT5(string solutionType, int numberOfVariables = 11); + void evaluate(Solution *solution); - virtual ~ZDT5(); + virtual ~ZDT5(); }; #endif /* __ZDT5_H__ */ diff --git a/src/problems/ZDT/ZDT6.cpp b/src/problems/ZDT/ZDT6.cpp index c6b6064..f237647 100644 --- a/src/problems/ZDT/ZDT6.cpp +++ b/src/problems/ZDT/ZDT6.cpp @@ -22,83 +22,93 @@ const double ZDT6::PI = 3.141592653589793; -ZDT6::ZDT6(string solutionType, int numberOfVariables) { - numberOfVariables_ = numberOfVariables; - numberOfObjectives_ = 2; - numberOfConstraints_ = 0; - problemName_ = "ZDT6"; - - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } - - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; - exit(-1); - } - - for (int i = 0; i < numberOfVariables_; i++) { - lowerLimit_[i] = 0.0; - upperLimit_[i] = 1.0; - } - - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; - //cout << "Tipo seleccionado Real" << endl; - } - else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; - else { - cout << "Error: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } - fx_ = new double[numberOfObjectives_] ; +ZDT6::ZDT6(string solutionType, int numberOfVariables) +{ + numberOfVariables_ = numberOfVariables; + numberOfObjectives_ = 2; + numberOfConstraints_ = 0; + problemName_ = "ZDT6"; + + lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (lowerLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (upperLimit_ == NULL) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + for (int i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = 0.0; + upperLimit_[i] = 1.0; + } + + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + { + solutionType_ = new RealSolutionType(this) ; + //cout << "Tipo seleccionado Real" << endl; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = new ArrayRealSolutionType(this) ; + else + { + cout << "Error: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } + fx_ = new double[numberOfObjectives_] ; } -ZDT6::~ZDT6() { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; - delete [] fx_ ; +ZDT6::~ZDT6() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; + delete [] fx_ ; } /** * Evaluates a solution * @param solution The solution to evaluate */ -void ZDT6::evaluate(Solution *solution) { - XReal * x = new XReal(solution); +void ZDT6::evaluate(Solution *solution) +{ + XReal * x = new XReal(solution); - double x1 = x->getValue(0) ; - fx_[0] = 1.0 - exp(-4.0*x1) * pow(sin(6.0*PI*x1), 6.0) ; - double g = evalG(x) ; - double h = evalH(fx_[0], g) ; - fx_[1] = h * g ; + double x1 = x->getValue(0) ; + fx_[0] = 1.0 - exp(-4.0*x1) * pow(sin(6.0*PI*x1), 6.0) ; + double g = evalG(x) ; + double h = evalH(fx_[0], g) ; + fx_[1] = h * g ; - solution->setObjective(0,fx_[0]); - solution->setObjective(1,fx_[1]); + solution->setObjective(0,fx_[0]); + solution->setObjective(1,fx_[1]); - delete x ; + delete x ; } // evaluate -double ZDT6::evalG(XReal * x) { - double g = 0.0 ; - for (int i = 1; i < x->getNumberOfDecisionVariables(); i++) - g += x->getValue(i) ; - - g = g / (numberOfVariables_ - 1) ; - g = pow(g, 0.25) ; - g = 0.9 * g ; - g = g + 1.0 ; - return g; +double ZDT6::evalG(XReal * x) +{ + double g = 0.0 ; + for (int i = 1; i < x->getNumberOfDecisionVariables(); i++) + g += x->getValue(i) ; + + g = g / (numberOfVariables_ - 1) ; + g = pow(g, 0.25) ; + g = 0.9 * g ; + g = g + 1.0 ; + return g; } -double ZDT6::evalH(double f, double g) { - return 1.0 - pow((f/g), 2.0) ; +double ZDT6::evalH(double f, double g) +{ + return 1.0 - pow((f/g), 2.0) ; } diff --git a/src/problems/ZDT/ZDT6.h b/src/problems/ZDT/ZDT6.h index affd9be..3499c42 100644 --- a/src/problems/ZDT/ZDT6.h +++ b/src/problems/ZDT/ZDT6.h @@ -30,17 +30,18 @@ #include #include -class ZDT6 : public Problem { +class ZDT6 : public Problem +{ private: - double evalG(XReal *x) ; - double evalH(double f, double g) ; - double * fx_ ; - static const double PI ; + double evalG(XReal *x) ; + double evalH(double f, double g) ; + double * fx_ ; + static const double PI ; public: - ZDT6(string solutionType, int numberOfVariables = 10); - void evaluate(Solution *solution); - virtual ~ZDT6(); + ZDT6(string solutionType, int numberOfVariables = 10); + void evaluate(Solution *solution); + virtual ~ZDT6(); }; #endif /* __ZDT6_H__ */ diff --git a/src/problems/singleObjective/CEC2005Problem.cpp b/src/problems/singleObjective/CEC2005Problem.cpp index 8fcad0d..a53af21 100644 --- a/src/problems/singleObjective/CEC2005Problem.cpp +++ b/src/problems/singleObjective/CEC2005Problem.cpp @@ -31,25 +31,27 @@ const double CEC2005Problem::PI = 3.141592653589793; * @param problemId CEC2005 problem id * @param numberOfVariables Number of variables of the problem */ -CEC2005Problem::CEC2005Problem(string solutionType, int problemID, int numberOfVariables) { - numberOfVariables_ = numberOfVariables ; - numberOfObjectives_ = 1; - numberOfConstraints_ = 0; +CEC2005Problem::CEC2005Problem(string solutionType, int problemID, int numberOfVariables) +{ + numberOfVariables_ = numberOfVariables ; + numberOfObjectives_ = 1; + numberOfConstraints_ = 0; - Benchmark * cec2005ProblemFactory = new Benchmark() ; - testFunction_ = cec2005ProblemFactory->testFunctionFactory(problemID, numberOfVariables) ; - delete cec2005ProblemFactory; + Benchmark * cec2005ProblemFactory = new Benchmark() ; + testFunction_ = cec2005ProblemFactory->testFunctionFactory(problemID, numberOfVariables) ; + delete cec2005ProblemFactory; - problemName_ = "CEC2005: " + testFunction_->name(); + problemName_ = "CEC2005: " + testFunction_->name(); - upperLimit_ = new double[numberOfVariables_]; - lowerLimit_ = new double[numberOfVariables_]; + upperLimit_ = new double[numberOfVariables_]; + lowerLimit_ = new double[numberOfVariables_]; - double ulimit = 0 ; - double llimit = 0 ; + double ulimit = 0 ; + double llimit = 0 ; - switch (problemID) { + switch (problemID) + { case 1: case 2: case 3: @@ -57,17 +59,18 @@ CEC2005Problem::CEC2005Problem(string solutionType, int problemID, int numberOfV case 5: case 6: case 14: - ulimit = 100; - llimit = -100 ; - break ; + ulimit = 100; + llimit = -100 ; + break ; case 7: case 25: - ulimit = std::numeric_limits::max(); - llimit = -std::numeric_limits::max(); - break ; + ulimit = std::numeric_limits::max(); + llimit = -std::numeric_limits::max(); + break ; case 8: - ulimit = 32; llimit = -32 ; - break ; + ulimit = 32; + llimit = -32 ; + break ; case 9: case 10: case 15: @@ -80,32 +83,38 @@ CEC2005Problem::CEC2005Problem(string solutionType, int problemID, int numberOfV case 22: case 23: case 24: - ulimit = 5; llimit = -5 ; - break ; + ulimit = 5; + llimit = -5 ; + break ; case 11: - ulimit = 0.5; llimit = -0.5 ; - break ; + ulimit = 0.5; + llimit = -0.5 ; + break ; case 12: - ulimit = PI; llimit = -PI ; - break ; + ulimit = PI; + llimit = -PI ; + break ; case 13: - ulimit = 3; llimit = 1 ; - break ; - } - - for (int var = 0; var < numberOfVariables_; var++){ - lowerLimit_[var] = llimit ; - upperLimit_[var] = ulimit ; - } // for - - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) - solutionType_ = new RealSolutionType(this) ; - else { - cout << "Error: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } // if + ulimit = 3; + llimit = 1 ; + break ; + } + + for (int var = 0; var < numberOfVariables_; var++) + { + lowerLimit_[var] = llimit ; + upperLimit_[var] = ulimit ; + } // for + + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + solutionType_ = new RealSolutionType(this) ; + else + { + cout << "Error: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } // if } // CEC2005Problem @@ -113,11 +122,12 @@ CEC2005Problem::CEC2005Problem(string solutionType, int problemID, int numberOfV /** * Destructor */ -CEC2005Problem::~CEC2005Problem() { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; - delete testFunction_; +CEC2005Problem::~CEC2005Problem() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; + delete testFunction_; } // ~CEC2005Problem @@ -125,19 +135,21 @@ CEC2005Problem::~CEC2005Problem() { * Evaluates a solution * @param solution The solution to evaluate */ -void CEC2005Problem::evaluate(Solution *solution) { - Variable ** decisionVariables = solution->getDecisionVariables(); - double * x = new double[numberOfVariables_] ; +void CEC2005Problem::evaluate(Solution *solution) +{ + Variable ** decisionVariables = solution->getDecisionVariables(); + double * x = new double[numberOfVariables_] ; - for (int i = 0 ; i < numberOfVariables_; i++) { - x[i] = decisionVariables[i]->getValue() ; - } + for (int i = 0 ; i < numberOfVariables_; i++) + { + x[i] = decisionVariables[i]->getValue() ; + } - double result ; - result = testFunction_->f(x) ; + double result ; + result = testFunction_->f(x) ; - delete [] x; + delete [] x; - solution->setObjective(0, result); + solution->setObjective(0, result); } // evaluate diff --git a/src/problems/singleObjective/CEC2005Problem.h b/src/problems/singleObjective/CEC2005Problem.h index f15fe31..d538c32 100644 --- a/src/problems/singleObjective/CEC2005Problem.h +++ b/src/problems/singleObjective/CEC2005Problem.h @@ -36,16 +36,17 @@ * @class CEC2005Problem * @brief Class representing all problems in CEC2005 **/ -class CEC2005Problem : public Problem { +class CEC2005Problem : public Problem +{ private: - TestFunc * testFunction_ ; - static const double PI; + TestFunc * testFunction_ ; + static const double PI; public: - CEC2005Problem(string solutionType, int problemID, int numberOfVariables = 10); - ~CEC2005Problem(); - void evaluate(Solution *solution); + CEC2005Problem(string solutionType, int problemID, int numberOfVariables = 10); + ~CEC2005Problem(); + void evaluate(Solution *solution); }; #endif /* __CEC_2005_PROBLEM__ */ diff --git a/src/problems/singleObjective/Griewank.cpp b/src/problems/singleObjective/Griewank.cpp index 0b8d1f6..7114e3c 100644 --- a/src/problems/singleObjective/Griewank.cpp +++ b/src/problems/singleObjective/Griewank.cpp @@ -2,7 +2,7 @@ // // Authors: // Esteban López-Camacho -// +// // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // // This program is free software: you can redistribute it and/or modify @@ -14,7 +14,7 @@ // 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 program. If not, see . @@ -28,47 +28,53 @@ * @param solutionType The solution type must "Real", "BinaryReal, and "ArrayReal". * @param numberOfVariables Number of variables of the problem */ -Griewank::Griewank(string solutionType, int numberOfVariables) { - numberOfVariables_ = numberOfVariables; - numberOfObjectives_ = 1; - numberOfConstraints_ = 0; - problemName_ = "Griewank"; - - lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) { - cout << "Griewank::Griewank. Error reserving memory for storing the array of lower limits" << endl; - exit(-1) ; - } // if - - upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) { - cout << "Griewank::Griewank. Error reserving memory for storing the array of upper limits" << endl; - exit(-1) ; - } // if - - for (int i = 0; i < numberOfVariables_; i++) { - lowerLimit_[i] = -600.0; - upperLimit_[i] = 600.0; - } // for - - if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; - else if (solutionType.compare("Real") == 0) - solutionType_ = new RealSolutionType(this) ; - else { - cout << "Error: solution type " << solutionType << " invalid" << endl; - exit(-1) ; - } // if +Griewank::Griewank(string solutionType, int numberOfVariables) +{ + numberOfVariables_ = numberOfVariables; + numberOfObjectives_ = 1; + numberOfConstraints_ = 0; + problemName_ = "Griewank"; + + lowerLimit_ = new double[numberOfVariables_]; + if (lowerLimit_ == NULL) + { + cout << "Griewank::Griewank. Error reserving memory for storing the array of lower limits" << endl; + exit(-1) ; + } // if + + upperLimit_ = new double[numberOfVariables_]; + if (upperLimit_ == NULL) + { + cout << "Griewank::Griewank. Error reserving memory for storing the array of upper limits" << endl; + exit(-1) ; + } // if + + for (int i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = -600.0; + upperLimit_[i] = 600.0; + } // for + + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = new BinaryRealSolutionType(this) ; + else if (solutionType.compare("Real") == 0) + solutionType_ = new RealSolutionType(this) ; + else + { + cout << "Error: solution type " << solutionType << " invalid" << endl; + exit(-1) ; + } // if } // Griewank /** * Destructor */ -Griewank::~Griewank() { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; +Griewank::~Griewank() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; } // ~Griewank @@ -76,19 +82,21 @@ Griewank::~Griewank() { * Evaluates a solution * @param solution The solution to evaluate */ -void Griewank::evaluate(Solution *solution) { - Variable **decisionVariables = solution->getDecisionVariables(); - - double sum = 0.0 ; - double mult = 1.0 ; - double d = 4000.0 ; - - for (int var = 0; var < numberOfVariables_; var++) { - sum += decisionVariables[var]->getValue() * - decisionVariables[var]->getValue() ; - mult *= cos(decisionVariables[var]->getValue()/sqrt(var+1)) ; - } - - solution->setObjective(0, 1.0/d * sum - mult + 1.0) ; +void Griewank::evaluate(Solution *solution) +{ + Variable **decisionVariables = solution->getDecisionVariables(); + + double sum = 0.0 ; + double mult = 1.0 ; + double d = 4000.0 ; + + for (int var = 0; var < numberOfVariables_; var++) + { + sum += decisionVariables[var]->getValue() * + decisionVariables[var]->getValue() ; + mult *= cos(decisionVariables[var]->getValue()/sqrt(var+1)) ; + } + + solution->setObjective(0, 1.0/d * sum - mult + 1.0) ; } // evaluate diff --git a/src/problems/singleObjective/Griewank.h b/src/problems/singleObjective/Griewank.h index 653fdd9..b2e77cf 100644 --- a/src/problems/singleObjective/Griewank.h +++ b/src/problems/singleObjective/Griewank.h @@ -2,7 +2,7 @@ // // Authors: // Esteban López-Camacho -// +// // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // // This program is free software: you can redistribute it and/or modify @@ -14,7 +14,7 @@ // 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 program. If not, see . @@ -31,12 +31,13 @@ * @class Griewank * @brief Class representing problem Griewank **/ -class Griewank : public Problem { - +class Griewank : public Problem +{ + public: - Griewank(string solutionType, int numberOfVariables = 10); - ~Griewank(); - void evaluate(Solution *solution); + Griewank(string solutionType, int numberOfVariables = 10); + ~Griewank(); + void evaluate(Solution *solution); }; #endif /* __GRIEWANK__ */ diff --git a/src/problems/singleObjective/OneMax.cpp b/src/problems/singleObjective/OneMax.cpp index 9c847e0..da04b82 100644 --- a/src/problems/singleObjective/OneMax.cpp +++ b/src/problems/singleObjective/OneMax.cpp @@ -23,44 +23,48 @@ /** * Class constructor */ -OneMax::OneMax(int numberOfBits, int numberOfStrings) { - numberOfVariables_ = numberOfStrings; - numberOfObjectives_ = 1; - numberOfConstraints_ = 0; - problemName_ = "OneMax"; +OneMax::OneMax(int numberOfBits, int numberOfStrings) +{ + numberOfVariables_ = numberOfStrings; + numberOfObjectives_ = 1; + numberOfConstraints_ = 0; + problemName_ = "OneMax"; - solutionType_ = new BinarySolutionType(this) ; - length_ = new int[numberOfVariables_]; - for (int i = 0; i < numberOfVariables_; i++) - length_ [i] = numberOfBits ; + solutionType_ = new BinarySolutionType(this) ; + length_ = new int[numberOfVariables_]; + for (int i = 0; i < numberOfVariables_; i++) + length_ [i] = numberOfBits ; } // OneMax -OneMax::~OneMax() { - delete []length_ ; - delete solutionType_; +OneMax::~OneMax() +{ + delete []length_ ; + delete solutionType_; } // ~OneMax - /** - * Evaluates a solution - * @param solution The solution to evaluate - */ -void OneMax::evaluate(Solution * solution) { - Binary * variable ; - int counter ; +/** + * Evaluates a solution + * @param solution The solution to evaluate + */ +void OneMax::evaluate(Solution * solution) +{ + Binary * variable ; + int counter ; - counter = 0 ; - for (int i = 0; i < numberOfVariables_ ; i++) { - variable = (Binary *)(solution->getDecisionVariables()[i]) ; - counter += variable->cardinality() ; - } - /* - variable = (Binary *)(solution->getDecisionVariables()[0]) ; - counter = 0 ; + counter = 0 ; + for (int i = 0; i < numberOfVariables_ ; i++) + { + variable = (Binary *)(solution->getDecisionVariables()[i]) ; + counter += variable->cardinality() ; + } + /* + variable = (Binary *)(solution->getDecisionVariables()[0]) ; + counter = 0 ; - for (int i = 0; i < variable->getNumberOfBits() ; i++) - if (variable->getIth(i) == true) - counter ++ ; - */ + for (int i = 0; i < variable->getNumberOfBits() ; i++) + if (variable->getIth(i) == true) + counter ++ ; + */ // OneMax is a maximization problem: multiply by -1 to minimize solution->setObjective(0, - 1.0*counter); } // evaluate diff --git a/src/problems/singleObjective/OneMax.h b/src/problems/singleObjective/OneMax.h index 3a0092e..49382fc 100644 --- a/src/problems/singleObjective/OneMax.h +++ b/src/problems/singleObjective/OneMax.h @@ -25,11 +25,12 @@ #include #include -class OneMax : public Problem { +class OneMax : public Problem +{ public: - OneMax(int numberOfBits, int numberOfStrings = 1); - ~OneMax(); - void evaluate(Solution *solution); + OneMax(int numberOfBits, int numberOfStrings = 1); + ~OneMax(); + void evaluate(Solution *solution); }; diff --git a/src/problems/singleObjective/Rastrigin.cpp b/src/problems/singleObjective/Rastrigin.cpp index 3987dd6..7964e9e 100644 --- a/src/problems/singleObjective/Rastrigin.cpp +++ b/src/problems/singleObjective/Rastrigin.cpp @@ -3,7 +3,7 @@ // Authors: // Antonio J. Nebro // Esteban López-Camacho -// +// // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // // This program is free software: you can redistribute it and/or modify @@ -15,7 +15,7 @@ // 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 program. If not, see . @@ -29,41 +29,46 @@ const double Rastrigin::PI = 3.141592653589793; * @param solutionType The solution type must "Real", "BinaryReal, and "ArrayReal". * @param numberOfVariables Number of variables of the problem */ -Rastrigin::Rastrigin(string solutionType, int numberOfVariables) { - numberOfVariables_ = numberOfVariables; - numberOfObjectives_ = 1; - numberOfConstraints_ = 0; - problemName_ = "Rastrigin"; - - lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) { - cout << "Rastrigin::Rastrigin. Error reserving memory for storing the array of lower limits" << endl; - exit(-1) ; - } - - upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) { - cout << "Rastrigin::Rastrigin. Error reserving memory for storing the array of upper limits" << endl; - exit(-1) ; - } - - for (int i = 0; i < numberOfVariables_; i++) { - lowerLimit_[i] = -5.12; - upperLimit_[i] = 5.12; - } - - // TODO: Solution type initialization - solutionType_ = new RealSolutionType(this); +Rastrigin::Rastrigin(string solutionType, int numberOfVariables) +{ + numberOfVariables_ = numberOfVariables; + numberOfObjectives_ = 1; + numberOfConstraints_ = 0; + problemName_ = "Rastrigin"; + + lowerLimit_ = new double[numberOfVariables_]; + if (lowerLimit_ == NULL) + { + cout << "Rastrigin::Rastrigin. Error reserving memory for storing the array of lower limits" << endl; + exit(-1) ; + } + + upperLimit_ = new double[numberOfVariables_]; + if (upperLimit_ == NULL) + { + cout << "Rastrigin::Rastrigin. Error reserving memory for storing the array of upper limits" << endl; + exit(-1) ; + } + + for (int i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = -5.12; + upperLimit_[i] = 5.12; + } + + // TODO: Solution type initialization + solutionType_ = new RealSolutionType(this); } // Rastrigin /** * Destructor */ -Rastrigin::~Rastrigin() { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; +Rastrigin::~Rastrigin() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; } // ~Rastrigin @@ -71,39 +76,43 @@ Rastrigin::~Rastrigin() { * Evaluates a solution * @param solution The solution to evaluate */ -void Rastrigin::evaluate(Solution *solution) { - //double fx [numberOfObjectives_] ; - //double x [numberOfVariables_]; - Variable **variables = solution->getDecisionVariables(); - - double * fx = new double[numberOfObjectives_]; //(double *)malloc(sizeof(double) * numberOfObjectives_); - if (fx == NULL) { - cout << "Rastrigin::evaluate: Error reserving memory while evaluating the problem" << endl; +void Rastrigin::evaluate(Solution *solution) +{ + //double fx [numberOfObjectives_] ; + //double x [numberOfVariables_]; + Variable **variables = solution->getDecisionVariables(); + + double * fx = new double[numberOfObjectives_]; //(double *)malloc(sizeof(double) * numberOfObjectives_); + if (fx == NULL) + { + cout << "Rastrigin::evaluate: Error reserving memory while evaluating the problem" << endl; exit(-1); - } - - double * x = new double[numberOfVariables_]; - if (x == NULL) { - cout << "Rastrigin::evaluate: Error reserving memory for the variable values array" << endl; - exit(-1); - } // if - - for (int i = 0; i < numberOfVariables_; i++) - x[i] = variables[i]->getValue() ; - - // First function - double result = 0.0 ; - double a = 10.0 ; - double w = 2*PI ; - - for (int i = 0; i < numberOfVariables_; i++) { - result += x[i]*x[i] - a*cos(w*x[i]) ; - } - - fx[0] = a*numberOfVariables_ + result ; - - solution->setObjective(0,fx[0]); - delete[]fx ; - delete[]x; + } + + double * x = new double[numberOfVariables_]; + if (x == NULL) + { + cout << "Rastrigin::evaluate: Error reserving memory for the variable values array" << endl; + exit(-1); + } // if + + for (int i = 0; i < numberOfVariables_; i++) + x[i] = variables[i]->getValue() ; + + // First function + double result = 0.0 ; + double a = 10.0 ; + double w = 2*PI ; + + for (int i = 0; i < numberOfVariables_; i++) + { + result += x[i]*x[i] - a*cos(w*x[i]) ; + } + + fx[0] = a*numberOfVariables_ + result ; + + solution->setObjective(0,fx[0]); + delete[]fx ; + delete[]x; } // evaluate diff --git a/src/problems/singleObjective/Rastrigin.h b/src/problems/singleObjective/Rastrigin.h index 4fc6c22..9c68c04 100644 --- a/src/problems/singleObjective/Rastrigin.h +++ b/src/problems/singleObjective/Rastrigin.h @@ -3,7 +3,7 @@ // Authors: // Antonio J. Nebro // Esteban López-Camacho -// +// // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // // This program is free software: you can redistribute it and/or modify @@ -15,7 +15,7 @@ // 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 program. If not, see . @@ -31,16 +31,17 @@ * @class Rastrigin * @brief Class representing problem Rastrigin **/ -class Rastrigin : public Problem { - +class Rastrigin : public Problem +{ + public: - Rastrigin(string solutionType, int numberOfVariables = 10); - ~Rastrigin(); - void evaluate(Solution *solution); - + Rastrigin(string solutionType, int numberOfVariables = 10); + ~Rastrigin(); + void evaluate(Solution *solution); + private: - static const double PI; - + static const double PI; + }; #endif /* __RASTRIGIN__ */ diff --git a/src/problems/singleObjective/Rosenbrock.cpp b/src/problems/singleObjective/Rosenbrock.cpp index dabbfe9..7a4ad67 100644 --- a/src/problems/singleObjective/Rosenbrock.cpp +++ b/src/problems/singleObjective/Rosenbrock.cpp @@ -3,7 +3,7 @@ // Authors: // Antonio J. Nebro // Esteban López-Camacho -// +// // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // // This program is free software: you can redistribute it and/or modify @@ -15,7 +15,7 @@ // 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 program. If not, see . @@ -27,42 +27,47 @@ * @param solutionType The solution type must "Real", "BinaryReal, and "ArrayReal". * @param numberOfVariables Number of variables of the problem */ -Rosenbrock::Rosenbrock(string solutionType, int numberOfVariables) { - numberOfVariables_ = numberOfVariables; - numberOfObjectives_ = 1; - numberOfConstraints_ = 0; - problemName_ = "Rosenbrock"; - - lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) { - cout << "Rosenbrock::Rosenbrock. Error reserving memory for storing the array of lower limits" << endl; - exit(-1) ; - } - - upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) { - cout << "Rosenbrock::Rosenbrock. Error reserving memory for storing the array of upper limits" << endl; - exit(-1) ; - } - - int i ; - for (i = 0; i < numberOfVariables_; i++) { - lowerLimit_[i] = -5.12; - upperLimit_[i] = 5.12; +Rosenbrock::Rosenbrock(string solutionType, int numberOfVariables) +{ + numberOfVariables_ = numberOfVariables; + numberOfObjectives_ = 1; + numberOfConstraints_ = 0; + problemName_ = "Rosenbrock"; + + lowerLimit_ = new double[numberOfVariables_]; + if (lowerLimit_ == NULL) + { + cout << "Rosenbrock::Rosenbrock. Error reserving memory for storing the array of lower limits" << endl; + exit(-1) ; + } + + upperLimit_ = new double[numberOfVariables_]; + if (upperLimit_ == NULL) + { + cout << "Rosenbrock::Rosenbrock. Error reserving memory for storing the array of upper limits" << endl; + exit(-1) ; + } + + int i ; + for (i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = -5.12; + upperLimit_[i] = 5.12; } // TODO: Solution type initialization - solutionType_ = new RealSolutionType(this); + solutionType_ = new RealSolutionType(this); } // Rosenbrock /** * Destructor */ -Rosenbrock::~Rosenbrock() { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; +Rosenbrock::~Rosenbrock() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; } // ~Rosenbrock @@ -70,35 +75,39 @@ Rosenbrock::~Rosenbrock() { * Evaluates a solution * @param solution The solution to evaluate */ -void Rosenbrock::evaluate(Solution *solution) { - //double fx [numberOfObjectives_] ; - //double x [numberOfVariables_]; - Variable **variables = solution->getDecisionVariables(); - - double * fx = new double[numberOfObjectives_]; //(double *)malloc(sizeof(double) * numberOfObjectives_); - if (fx == NULL) { - cout << "Rosenbrock::evaluate: Error reserving memory while evaluating the problem" << endl; +void Rosenbrock::evaluate(Solution *solution) +{ + //double fx [numberOfObjectives_] ; + //double x [numberOfVariables_]; + Variable **variables = solution->getDecisionVariables(); + + double * fx = new double[numberOfObjectives_]; //(double *)malloc(sizeof(double) * numberOfObjectives_); + if (fx == NULL) + { + cout << "Rosenbrock::evaluate: Error reserving memory while evaluating the problem" << endl; exit(-1); - } - - double * x = new double[numberOfVariables_]; - if (x == NULL) { - cout << "Rosenbrock::evaluate: Error reserving memory for the variable values array" << endl; - exit(-1); - } // if - - for (int i = 0; i < numberOfVariables_; i++) - x[i] = variables[i]->getValue() ; - - double sum = 0.0; - for (int var = 0; var < numberOfVariables_-1; var++) { - sum += 100.0 * (x[var+1]-x[var]*x[var])*(x[var+1]-x[var]*x[var]) +(x[var]-1)*(x[var]-1) ; - } - - fx[0] = sum ; - - solution->setObjective(0,fx[0]); - delete[]fx ; - delete[]x; + } + + double * x = new double[numberOfVariables_]; + if (x == NULL) + { + cout << "Rosenbrock::evaluate: Error reserving memory for the variable values array" << endl; + exit(-1); + } // if + + for (int i = 0; i < numberOfVariables_; i++) + x[i] = variables[i]->getValue() ; + + double sum = 0.0; + for (int var = 0; var < numberOfVariables_-1; var++) + { + sum += 100.0 * (x[var+1]-x[var]*x[var])*(x[var+1]-x[var]*x[var]) +(x[var]-1)*(x[var]-1) ; + } + + fx[0] = sum ; + + solution->setObjective(0,fx[0]); + delete[]fx ; + delete[]x; } // evaluate diff --git a/src/problems/singleObjective/Rosenbrock.h b/src/problems/singleObjective/Rosenbrock.h index 0ad35dd..af062a1 100644 --- a/src/problems/singleObjective/Rosenbrock.h +++ b/src/problems/singleObjective/Rosenbrock.h @@ -3,7 +3,7 @@ // Authors: // Antonio J. Nebro // Esteban López-Camacho -// +// // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // // This program is free software: you can redistribute it and/or modify @@ -15,7 +15,7 @@ // 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 program. If not, see . @@ -30,12 +30,13 @@ * @class Rosenbrock * @brief Class representing problem Rosenbrock **/ -class Rosenbrock : public Problem { - +class Rosenbrock : public Problem +{ + public: - Rosenbrock(string solutionType, int numberOfVariables = 10); - ~Rosenbrock(); - void evaluate(Solution *solution); + Rosenbrock(string solutionType, int numberOfVariables = 10); + ~Rosenbrock(); + void evaluate(Solution *solution); }; #endif diff --git a/src/problems/singleObjective/Sphere.cpp b/src/problems/singleObjective/Sphere.cpp index 5dc22f6..26b631d 100644 --- a/src/problems/singleObjective/Sphere.cpp +++ b/src/problems/singleObjective/Sphere.cpp @@ -3,7 +3,7 @@ // Authors: // Antonio J. Nebro // Juan J. Durillo -// +// // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // // This program is free software: you can redistribute it and/or modify @@ -15,7 +15,7 @@ // 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 program. If not, see . @@ -27,42 +27,47 @@ * @param solutionType The solution type must "Real", "BinaryReal, and "ArrayReal". * @param numberOfVariables Number of variables of the problem */ -Sphere::Sphere(string solutionType, int numberOfVariables) { - numberOfVariables_ = numberOfVariables; - numberOfObjectives_ = 1; - numberOfConstraints_ = 0; - problemName_ = "Sphere"; - - lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) { - cout << "Sphere::Sphere. Error reserving memory for storing the array of lower limits" << endl; - exit(-1) ; - } - - upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) { - cout << "Sphere::Sphere. Error reserving memory for storing the array of upper limits" << endl; - exit(-1) ; - } - - int i ; - for (i = 0; i < numberOfVariables_; i++) { - lowerLimit_[i] = -5.12; - upperLimit_[i] = 5.12; +Sphere::Sphere(string solutionType, int numberOfVariables) +{ + numberOfVariables_ = numberOfVariables; + numberOfObjectives_ = 1; + numberOfConstraints_ = 0; + problemName_ = "Sphere"; + + lowerLimit_ = new double[numberOfVariables_]; + if (lowerLimit_ == NULL) + { + cout << "Sphere::Sphere. Error reserving memory for storing the array of lower limits" << endl; + exit(-1) ; + } + + upperLimit_ = new double[numberOfVariables_]; + if (upperLimit_ == NULL) + { + cout << "Sphere::Sphere. Error reserving memory for storing the array of upper limits" << endl; + exit(-1) ; + } + + int i ; + for (i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = -5.12; + upperLimit_[i] = 5.12; } // TODO: Solution type initialization - solutionType_ = new RealSolutionType(this); + solutionType_ = new RealSolutionType(this); } // Sphere /** * Destructor */ -Sphere::~Sphere() { - delete [] lowerLimit_ ; - delete [] upperLimit_ ; - delete solutionType_ ; +Sphere::~Sphere() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; } // ~Sphere @@ -70,37 +75,41 @@ Sphere::~Sphere() { * Evaluates a solution * @param solution The solution to evaluate */ -void Sphere::evaluate(Solution *solution) { - //double fx [numberOfObjectives_] ; - //double x [numberOfVariables_]; - Variable **variables = solution->getDecisionVariables(); - - double * fx = new double[numberOfObjectives_]; //(double *)malloc(sizeof(double) * numberOfObjectives_); - if (fx == NULL) { - cout << "Sphere::evaluate: Error reserving memory while evaluating the problem" << endl; +void Sphere::evaluate(Solution *solution) +{ + //double fx [numberOfObjectives_] ; + //double x [numberOfVariables_]; + Variable **variables = solution->getDecisionVariables(); + + double * fx = new double[numberOfObjectives_]; //(double *)malloc(sizeof(double) * numberOfObjectives_); + if (fx == NULL) + { + cout << "Sphere::evaluate: Error reserving memory while evaluating the problem" << endl; exit(-1); - } - - double * x = new double[numberOfVariables_]; - if (x == NULL) { - cout << "Sphere::evaluate: Error reserving memory for the variable values array" << endl; - exit(-1); - } // if - - for (int i = 0; i < numberOfVariables_; i++) - x[i] = variables[i]->getValue() ; - - double sum = 0.0; - for (int var = 0; var < numberOfVariables_; var++) { - sum += pow(x[var], 2.0); - } - - - fx[0] = sum ; - - solution->setObjective(0,fx[0]); - delete[]fx ; - delete[]x; + } + + double * x = new double[numberOfVariables_]; + if (x == NULL) + { + cout << "Sphere::evaluate: Error reserving memory for the variable values array" << endl; + exit(-1); + } // if + + for (int i = 0; i < numberOfVariables_; i++) + x[i] = variables[i]->getValue() ; + + double sum = 0.0; + for (int var = 0; var < numberOfVariables_; var++) + { + sum += pow(x[var], 2.0); + } + + + fx[0] = sum ; + + solution->setObjective(0,fx[0]); + delete[]fx ; + delete[]x; } // evaluate diff --git a/src/problems/singleObjective/Sphere.h b/src/problems/singleObjective/Sphere.h index 04ebec3..a77f8b1 100644 --- a/src/problems/singleObjective/Sphere.h +++ b/src/problems/singleObjective/Sphere.h @@ -3,7 +3,7 @@ // Authors: // Antonio J. Nebro // Juan J. Durillo -// +// // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // // This program is free software: you can redistribute it and/or modify @@ -15,7 +15,7 @@ // 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 program. If not, see . @@ -31,12 +31,13 @@ * @class Sphere * @brief Class representing problem Sphere **/ -class Sphere : public Problem { - +class Sphere : public Problem +{ + public: - Sphere(string solutionType, int numberOfVariables = 10); - ~Sphere(); - void evaluate(Solution *solution); + Sphere(string solutionType, int numberOfVariables = 10); + ~Sphere(); + void evaluate(Solution *solution); }; #endif diff --git a/src/problems/singleObjective/cec2005Competition/Benchmark.cpp b/src/problems/singleObjective/cec2005Competition/Benchmark.cpp index 5723ec9..331f6b6 100644 --- a/src/problems/singleObjective/cec2005Competition/Benchmark.cpp +++ b/src/problems/singleObjective/cec2005Competition/Benchmark.cpp @@ -42,16 +42,18 @@ Benchmark::Benchmark() : Benchmark(DEFAULT_FILE_BIAS) {} /* * Constructor */ -Benchmark::Benchmark(string file_bias) { - m_biases = new double[NUM_TEST_FUNC]; - loadRowVectorFromFile(file_bias, NUM_TEST_FUNC, m_biases); +Benchmark::Benchmark(string file_bias) +{ + m_biases = new double[NUM_TEST_FUNC]; + loadRowVectorFromFile(file_bias, NUM_TEST_FUNC, m_biases); } /* * Destructor */ -Benchmark::~Benchmark() { - delete [] m_biases; +Benchmark::~Benchmark() +{ + delete [] m_biases; } /** @@ -64,485 +66,562 @@ normal_distribution Benchmark::dist (0,1); /** * Use this function to manufacture new test function objects. */ -TestFunc * Benchmark::testFunctionFactory(int func_num, int dimension) { - switch (func_num) { +TestFunc * Benchmark::testFunctionFactory(int func_num, int dimension) +{ + switch (func_num) + { case 1: - return new F01ShiftedSphere(dimension, m_biases[func_num-1]); - break; + return new F01ShiftedSphere(dimension, m_biases[func_num-1]); + break; case 2: - return new F02ShiftedSchwefel(dimension, m_biases[func_num-1]); - break; + return new F02ShiftedSchwefel(dimension, m_biases[func_num-1]); + break; case 3: - return new F03ShiftedRotatedHighCondElliptic(dimension, m_biases[func_num-1]); - break; + return new F03ShiftedRotatedHighCondElliptic(dimension, m_biases[func_num-1]); + break; case 4: - return new F04ShiftedSchwefelNoise(dimension, m_biases[func_num-1]); - break; + return new F04ShiftedSchwefelNoise(dimension, m_biases[func_num-1]); + break; case 5: - return new F05SchwefelGlobalOptBound(dimension, m_biases[func_num-1]); - break; + return new F05SchwefelGlobalOptBound(dimension, m_biases[func_num-1]); + break; case 6: - return new F06ShiftedRosenbrock(dimension, m_biases[func_num-1]); - break; + return new F06ShiftedRosenbrock(dimension, m_biases[func_num-1]); + break; case 7: - return new F07ShiftedRotatedGriewank(dimension, m_biases[func_num-1]); - break; + return new F07ShiftedRotatedGriewank(dimension, m_biases[func_num-1]); + break; case 8: - return new F08ShiftedRotatedAckleyGlobalOptBound(dimension, m_biases[func_num-1]); - break; + return new F08ShiftedRotatedAckleyGlobalOptBound(dimension, m_biases[func_num-1]); + break; case 9: - return new F09ShiftedRastrigin(dimension, m_biases[func_num-1]); - break; + return new F09ShiftedRastrigin(dimension, m_biases[func_num-1]); + break; case 10: - return new F10ShiftedRotatedRastrigin(dimension, m_biases[func_num-1]); - break; + return new F10ShiftedRotatedRastrigin(dimension, m_biases[func_num-1]); + break; case 11: - return new F11ShiftedRotatedWeierstrass(dimension, m_biases[func_num-1]); - break; + return new F11ShiftedRotatedWeierstrass(dimension, m_biases[func_num-1]); + break; case 12: - return new F12Schwefel(dimension, m_biases[func_num-1]); - break; + return new F12Schwefel(dimension, m_biases[func_num-1]); + break; case 13: - return new F13ShiftedExpandedGriewankRosenbrock(dimension, m_biases[func_num-1]); - break; + return new F13ShiftedExpandedGriewankRosenbrock(dimension, m_biases[func_num-1]); + break; case 14: - return new F14ShiftedRotatedExpandedScaffer(dimension, m_biases[func_num-1]); - break; + return new F14ShiftedRotatedExpandedScaffer(dimension, m_biases[func_num-1]); + break; case 15: - return new F15HybridComposition1(dimension, m_biases[func_num-1]); - break; + return new F15HybridComposition1(dimension, m_biases[func_num-1]); + break; case 16: - return new F16RotatedHybridComposition1(dimension, m_biases[func_num-1]); - break; + return new F16RotatedHybridComposition1(dimension, m_biases[func_num-1]); + break; case 17: - return new F17RotatedHybridComposition1Noise(dimension, m_biases[func_num-1]); - break; + return new F17RotatedHybridComposition1Noise(dimension, m_biases[func_num-1]); + break; case 18: - return new F18RotatedHybridComposition2(dimension, m_biases[func_num-1]); - break; + return new F18RotatedHybridComposition2(dimension, m_biases[func_num-1]); + break; case 19: - return new F19RotatedHybridComposition2NarrowBasinGlobalOpt(dimension, m_biases[func_num-1]); - break; + return new F19RotatedHybridComposition2NarrowBasinGlobalOpt(dimension, m_biases[func_num-1]); + break; case 20: - return new F20RotatedHybridComposition2GlobalOptBound(dimension, m_biases[func_num-1]); - break; + return new F20RotatedHybridComposition2GlobalOptBound(dimension, m_biases[func_num-1]); + break; case 21: - return new F21RotatedHybridComposition3(dimension, m_biases[func_num-1]); - break; + return new F21RotatedHybridComposition3(dimension, m_biases[func_num-1]); + break; case 22: - return new F22RotatedHybridComposition3HighCondNumMatrix(dimension, m_biases[func_num-1]); - break; + return new F22RotatedHybridComposition3HighCondNumMatrix(dimension, m_biases[func_num-1]); + break; case 23: - return new F23NoncontinuousRotatedHybridComposition3(dimension, m_biases[func_num-1]); - break; + return new F23NoncontinuousRotatedHybridComposition3(dimension, m_biases[func_num-1]); + break; case 24: - return new F24RotatedHybridComposition4(dimension, m_biases[func_num-1]); - break; + return new F24RotatedHybridComposition4(dimension, m_biases[func_num-1]); + break; case 25: - return new F25RotatedHybridComposition4Bound(dimension, m_biases[func_num-1]); - break; + return new F25RotatedHybridComposition4Bound(dimension, m_biases[func_num-1]); + break; default: - cerr << "Incorrect number of function. Expected an integer between " << - "1 and 25." << endl; - exit(-1); - } + cerr << "Incorrect number of function. Expected an integer between " << + "1 and 25." << endl; + exit(-1); + } } /** * Sphere function */ -double Benchmark::sphere(double * x, int length) { - double sum = 0.0; - for (int i = 0; i num_func; - int num_dim = job->num_dim; - - // Get the raw weights - double wMax = -numeric_limits::max(); - for (int i=0; iz[i], x, job->o[i], length); - for (int j=0; jz[i][j] * job->z[i][j]); +double Benchmark::hybrid_composition(double* x, HCJob* job, int length) +{ + + int num_func = job->num_func; + int num_dim = job->num_dim; + + // Get the raw weights + double wMax = -numeric_limits::max(); + for (int i=0; iz[i], x, job->o[i], length); + for (int j=0; jz[i][j] * job->z[i][j]); + } + job->w[i] = exp(-1.0 * sumSqr / (2.0 * num_dim * job->sigma[i] * job->sigma[i])); + if (wMax < job->w[i]) + wMax = job->w[i]; + } + + // Modify the weights + double wSum = 0.0; + double w1mMaxPow = 1.0 - pow(wMax, 10.0); + for (int i=0; iw[i] != wMax) + { + job->w[i] *= w1mMaxPow; + } + wSum += job->w[i]; } - job->w[i] = exp(-1.0 * sumSqr / (2.0 * num_dim * job->sigma[i] * job->sigma[i])); - if (wMax < job->w[i]) - wMax = job->w[i]; - } - - // Modify the weights - double wSum = 0.0; - double w1mMaxPow = 1.0 - pow(wMax, 10.0); - for (int i=0; iw[i] != wMax) { - job->w[i] *= w1mMaxPow; + + // Normalize the weights + for (int i=0; iw[i] /= wSum; } - wSum += job->w[i]; - } - - // Normalize the weights - for (int i=0; iw[i] /= wSum; - } - - double sumF = 0.0; - for (int i=0; iz[i][j] /= job->lambda[i]; + + double sumF = 0.0; + for (int i=0; iz[i][j] /= job->lambda[i]; + } + rotate(job->zM[i], job->z[i], job->M[i], length); + sumF += + job->w[i] * + ( + job->C * job->basic_func(i, job->zM[i], length) / job->fmax[i] + + job->biases[i] + ); } - rotate(job->zM[i], job->z[i], job->M[i], length); - sumF += - job->w[i] * - ( - job->C * job->basic_func(i, job->zM[i], length) / job->fmax[i] + - job->biases[i] - ); - } - return sumF; + return sumF; } /** * Rotate */ -void Benchmark::rotate(double * results, double * x, double ** matrix, int length) { - xA(results, x, matrix, length); +void Benchmark::rotate(double * results, double * x, double ** matrix, int length) +{ + xA(results, x, matrix, length); } /** * (1xD) row vector * (DxD) matrix = (1xD) row vector */ -void Benchmark::xA(double * result, double * x, double ** A, int length) { - for (int i = 0 ; i < length ; i ++) { - result[i] = 0.0; - for (int j = 0 ; j < length ; j ++) { - result[i] += (x[j] * A[j][i]); +void Benchmark::xA(double * result, double * x, double ** A, int length) +{ + for (int i = 0 ; i < length ; i ++) + { + result[i] = 0.0; + for (int j = 0 ; j < length ; j ++) + { + result[i] += (x[j] * A[j][i]); + } } - } } /** * (DxD) matrix * (Dx1) column vector = (Dx1) column vector */ -void Benchmark::Ax(double * result, double ** A, double * x, int length) { - for (int i = 0 ; i < length ; i++) { - result[i] = 0.0; - for (int j = 0 ; j < length ; j++) { - result[i] += (A[i][j] * x[j]); +void Benchmark::Ax(double * result, double ** A, double * x, int length) +{ + for (int i = 0 ; i < length ; i++) + { + result[i] = 0.0; + for (int j = 0 ; j < length ; j++) + { + result[i] += (A[i][j] * x[j]); + } } - } } -void Benchmark::loadRowVectorFromFile(string file, int columns, double * row) { +void Benchmark::loadRowVectorFromFile(string file, int columns, double * row) +{ - // Open the file - ifstream in(file.c_str()); - if( !in ) { - cerr << "Benchmark::loadRowVectorFromFile: failed when reading from file : " << - file << endl; - exit(-1); - } else { + // Open the file + ifstream in(file.c_str()); + if( !in ) + { + cerr << "Benchmark::loadRowVectorFromFile: failed when reading from file : " << + file << endl; + exit(-1); + } + else + { - loadRowVector(in, columns, row); - in.close(); + loadRowVector(in, columns, row); + in.close(); - } + } } -void Benchmark::loadRowVector(ifstream& in, int columns, double * row) { - string aux; - - if (getline(in, aux)) { - - istringstream iss(aux); - for (int i = 0; i < columns; i++) { - string stToken; - iss >> stToken; - if (stToken.compare("")!=0) { - row[i] = atof(stToken.c_str()); - } else { +void Benchmark::loadRowVector(ifstream& in, int columns, double * row) +{ + string aux; + + if (getline(in, aux)) + { + + istringstream iss(aux); + for (int i = 0; i < columns; i++) + { + string stToken; + iss >> stToken; + if (stToken.compare("")!=0) + { + row[i] = atof(stToken.c_str()); + } + else + { + cerr << "Benchmark::loadRowVector: unexpected format encountered when " << + "reading from file (incorrect number of tokens)." << endl; + exit(-1); + } + } + } + else + { cerr << "Benchmark::loadRowVector: unexpected format encountered when " << - "reading from file (incorrect number of tokens)." << endl; + "reading from file (zero lines found)." << endl; exit(-1); - } } - } else { - cerr << "Benchmark::loadRowVector: unexpected format encountered when " << - "reading from file (zero lines found)." << endl; - exit(-1); - } -} - -void Benchmark::loadNMatrixFromFile(string file, int N, int rows, int columns, double*** matrix) { - ifstream in(file.c_str()); - if (!in) { - cerr << "Benchmark::loadNMatrixFromFile: failed when reading from file : " << - file << endl; - exit(-1); - } else { - for (int i=0; i int sgn(T val) { +template int sgn(T val) +{ return (T(0) < val) - (val < T(0)); } -class Benchmark { +class Benchmark +{ private: - static const string DEFAULT_FILE_BIAS; + static const string DEFAULT_FILE_BIAS; - static const int NUM_TEST_FUNC; + static const int NUM_TEST_FUNC; - // For certain functions, some essential data can be calculated beforehand. - // Hence, a maximum supported number of dimensions should be specified. - // Specifiy the number of dimensions here if you need more. - static const int MAX_SUPPORT_DIM; - static const double PIx2; + // For certain functions, some essential data can be calculated beforehand. + // Hence, a maximum supported number of dimensions should be specified. + // Specifiy the number of dimensions here if you need more. + static const int MAX_SUPPORT_DIM; + static const double PIx2; - // Instance variables - double * m_biases; + // Instance variables + double * m_biases; public: - Benchmark(); - Benchmark(string file_bias); - ~Benchmark(); - - // Random number generator - static mt19937 e2; - static normal_distribution dist; - - TestFunc * testFunctionFactory(int func_num, int dimension); - - // Basic functions - static double sphere(double * x, int length); - static double sphere_noise(double * x, int length); - static double schwefel_102(double * x, int length); - static double rosenbrock(double * x, int length); - static double F2(double x, double y); - static double griewank(double * x, int length); - static double F8(double x); - static double ackley(double * x, int length); - static double myRound(double x); - static double myXRound(double x, double o); - static double myXRound(double x); - static double rastrigin(double * x, int length); - static double rastriginNonCont(double * x, int length); - static double weierstrass(double * x, int length); - static double weierstrass(double * x, int length, double a, double b, int Kmax); - static double F8F2(double * x, int length); - static double ScafferF6(double x, double y); - static double EScafferF6(double * x, int length); - static double EScafferF6NonCont(double * x, int length); - static double elliptic(double* x, int length); - static double hybrid_composition(double * x, HCJob * job, int length); - - // Elementary operations - static void shift(double * results, double * x, double * o, int length); - static void rotate(double * results, double * x, double ** matrix, int length); - - // Matrix & vector operations - static void xA(double * result, double * x, double ** A, int length); - static void Ax(double * result, double ** A, double * x, int length); - - // Utility functions for loading data from given text files - static void loadRowVectorFromFile(string file, int columns, double * row); - static void loadRowVector(ifstream& brSrc, int columns, double * row); - static void loadNMatrixFromFile(string file, int N, int rows, int columns, double*** matrix); - static void loadMatrixFromFile(string file, int rows, int columns, double ** matrix); - static void loadMatrix(ifstream& brSrc, int rows, int columns, double ** matrix); + Benchmark(); + Benchmark(string file_bias); + ~Benchmark(); + + // Random number generator + static mt19937 e2; + static normal_distribution dist; + + TestFunc * testFunctionFactory(int func_num, int dimension); + + // Basic functions + static double sphere(double * x, int length); + static double sphere_noise(double * x, int length); + static double schwefel_102(double * x, int length); + static double rosenbrock(double * x, int length); + static double F2(double x, double y); + static double griewank(double * x, int length); + static double F8(double x); + static double ackley(double * x, int length); + static double myRound(double x); + static double myXRound(double x, double o); + static double myXRound(double x); + static double rastrigin(double * x, int length); + static double rastriginNonCont(double * x, int length); + static double weierstrass(double * x, int length); + static double weierstrass(double * x, int length, double a, double b, int Kmax); + static double F8F2(double * x, int length); + static double ScafferF6(double x, double y); + static double EScafferF6(double * x, int length); + static double EScafferF6NonCont(double * x, int length); + static double elliptic(double* x, int length); + static double hybrid_composition(double * x, HCJob * job, int length); + + // Elementary operations + static void shift(double * results, double * x, double * o, int length); + static void rotate(double * results, double * x, double ** matrix, int length); + + // Matrix & vector operations + static void xA(double * result, double * x, double ** A, int length); + static void Ax(double * result, double ** A, double * x, int length); + + // Utility functions for loading data from given text files + static void loadRowVectorFromFile(string file, int columns, double * row); + static void loadRowVector(ifstream& brSrc, int columns, double * row); + static void loadNMatrixFromFile(string file, int N, int rows, int columns, double*** matrix); + static void loadMatrixFromFile(string file, int rows, int columns, double ** matrix); + static void loadMatrix(ifstream& brSrc, int rows, int columns, double ** matrix); }; // Benchmark diff --git a/src/problems/singleObjective/cec2005Competition/F01ShiftedSphere.cpp b/src/problems/singleObjective/cec2005Competition/F01ShiftedSphere.cpp index c367694..737bb5c 100644 --- a/src/problems/singleObjective/cec2005Competition/F01ShiftedSphere.cpp +++ b/src/problems/singleObjective/cec2005Competition/F01ShiftedSphere.cpp @@ -32,7 +32,8 @@ const string F01ShiftedSphere::DEFAULT_FILE_DATA = "../../data/cec2005Competitio * Constructor. */ F01ShiftedSphere::F01ShiftedSphere(int dimension, double bias) - : F01ShiftedSphere(dimension, bias, DEFAULT_FILE_DATA) { + : F01ShiftedSphere(dimension, bias, DEFAULT_FILE_DATA) +{ } // F01ShiftedSphere @@ -40,14 +41,15 @@ F01ShiftedSphere::F01ShiftedSphere(int dimension, double bias) * Constructor */ F01ShiftedSphere::F01ShiftedSphere(int dimension, double bias, string file_data) - : TestFunc(dimension, bias, FUNCTION_NAME) { + : TestFunc(dimension, bias, FUNCTION_NAME) +{ - // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_z = new double[m_dimension]; + // Note: dimension starts from 0 + m_o = new double[m_dimension]; + m_z = new double[m_dimension]; - // Load the shifted global optimum - Benchmark::loadRowVectorFromFile(file_data, m_dimension, m_o); + // Load the shifted global optimum + Benchmark::loadRowVectorFromFile(file_data, m_dimension, m_o); } // F01ShiftedSphere @@ -55,23 +57,25 @@ F01ShiftedSphere::F01ShiftedSphere(int dimension, double bias, string file_data) /** * Destructor */ -F01ShiftedSphere::~F01ShiftedSphere() { - delete [] m_o; - delete [] m_z; +F01ShiftedSphere::~F01ShiftedSphere() +{ + delete [] m_o; + delete [] m_z; } // ~F01ShiftedSphere /** * Function body */ -double F01ShiftedSphere::f(double * x) { - double result = 0.0; +double F01ShiftedSphere::f(double * x) +{ + double result = 0.0; - Benchmark::shift(m_z, x, m_o, m_dimension); + Benchmark::shift(m_z, x, m_o, m_dimension); - result = Benchmark::sphere(m_z, m_dimension); + result = Benchmark::sphere(m_z, m_dimension); - result += m_bias; + result += m_bias; - return result; + return result; } diff --git a/src/problems/singleObjective/cec2005Competition/F01ShiftedSphere.h b/src/problems/singleObjective/cec2005Competition/F01ShiftedSphere.h index f7e4777..c4d43d1 100644 --- a/src/problems/singleObjective/cec2005Competition/F01ShiftedSphere.h +++ b/src/problems/singleObjective/cec2005Competition/F01ShiftedSphere.h @@ -25,28 +25,29 @@ #include #include -class F01ShiftedSphere : public TestFunc { +class F01ShiftedSphere : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; - // Shifted global optimum - double * m_o; + // Shifted global optimum + double * m_o; - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_z; + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_z; public: - F01ShiftedSphere(int dimension, double bias); - F01ShiftedSphere(int dimension, double bias, string file_data); - ~F01ShiftedSphere(); + F01ShiftedSphere(int dimension, double bias); + F01ShiftedSphere(int dimension, double bias, string file_data); + ~F01ShiftedSphere(); - double f (double * x); + double f (double * x); }; // F01ShiftedSphere diff --git a/src/problems/singleObjective/cec2005Competition/F02ShiftedSchwefel.cpp b/src/problems/singleObjective/cec2005Competition/F02ShiftedSchwefel.cpp index a7e4f80..2c56ba9 100644 --- a/src/problems/singleObjective/cec2005Competition/F02ShiftedSchwefel.cpp +++ b/src/problems/singleObjective/cec2005Competition/F02ShiftedSchwefel.cpp @@ -32,7 +32,8 @@ const string F02ShiftedSchwefel::DEFAULT_FILE_DATA = "../../data/cec2005Competit * Constructor. */ F02ShiftedSchwefel::F02ShiftedSchwefel(int dimension, double bias) - : F02ShiftedSchwefel(dimension, bias, DEFAULT_FILE_DATA) { + : F02ShiftedSchwefel(dimension, bias, DEFAULT_FILE_DATA) +{ } // F02ShiftedSchwefel @@ -40,14 +41,15 @@ F02ShiftedSchwefel::F02ShiftedSchwefel(int dimension, double bias) * Constructor */ F02ShiftedSchwefel::F02ShiftedSchwefel(int dimension, double bias, string file_data) - : TestFunc(dimension, bias, FUNCTION_NAME) { + : TestFunc(dimension, bias, FUNCTION_NAME) +{ - // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_z = new double[m_dimension]; + // Note: dimension starts from 0 + m_o = new double[m_dimension]; + m_z = new double[m_dimension]; - // Load the shifted global optimum - Benchmark::loadRowVectorFromFile(file_data, m_dimension, m_o); + // Load the shifted global optimum + Benchmark::loadRowVectorFromFile(file_data, m_dimension, m_o); } // F02ShiftedSchwefel @@ -55,23 +57,25 @@ F02ShiftedSchwefel::F02ShiftedSchwefel(int dimension, double bias, string file_d /** * Destructor */ -F02ShiftedSchwefel::~F02ShiftedSchwefel() { - delete [] m_o; - delete [] m_z; +F02ShiftedSchwefel::~F02ShiftedSchwefel() +{ + delete [] m_o; + delete [] m_z; } // ~F02ShiftedSchwefel /** * Function body */ -double F02ShiftedSchwefel::f(double * x) { - double result = 0.0; +double F02ShiftedSchwefel::f(double * x) +{ + double result = 0.0; - Benchmark::shift(m_z, x, m_o, m_dimension); + Benchmark::shift(m_z, x, m_o, m_dimension); - result = Benchmark::schwefel_102(m_z, m_dimension); + result = Benchmark::schwefel_102(m_z, m_dimension); - result += m_bias; + result += m_bias; - return result; + return result; } diff --git a/src/problems/singleObjective/cec2005Competition/F02ShiftedSchwefel.h b/src/problems/singleObjective/cec2005Competition/F02ShiftedSchwefel.h index 019fe18..52c078c 100644 --- a/src/problems/singleObjective/cec2005Competition/F02ShiftedSchwefel.h +++ b/src/problems/singleObjective/cec2005Competition/F02ShiftedSchwefel.h @@ -25,28 +25,29 @@ #include #include -class F02ShiftedSchwefel : public TestFunc { +class F02ShiftedSchwefel : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; - // Shifted global optimum - double * m_o; + // Shifted global optimum + double * m_o; - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_z; + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_z; public: - F02ShiftedSchwefel(int dimension, double bias); - F02ShiftedSchwefel(int dimension, double bias, string file_data); - ~F02ShiftedSchwefel(); + F02ShiftedSchwefel(int dimension, double bias); + F02ShiftedSchwefel(int dimension, double bias, string file_data); + ~F02ShiftedSchwefel(); - double f (double * x); + double f (double * x); }; // F02ShiftedSchwefel diff --git a/src/problems/singleObjective/cec2005Competition/F03ShiftedRotatedHighCondElliptic.cpp b/src/problems/singleObjective/cec2005Competition/F03ShiftedRotatedHighCondElliptic.cpp index d8ca2e9..a4e762d 100644 --- a/src/problems/singleObjective/cec2005Competition/F03ShiftedRotatedHighCondElliptic.cpp +++ b/src/problems/singleObjective/cec2005Competition/F03ShiftedRotatedHighCondElliptic.cpp @@ -34,7 +34,8 @@ const string F03ShiftedRotatedHighCondElliptic::DEFAULT_FILE_MX_SUFFIX = ".txt"; * Constructor. */ F03ShiftedRotatedHighCondElliptic::F03ShiftedRotatedHighCondElliptic(int dimension, double bias) - : F03ShiftedRotatedHighCondElliptic(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) { + : F03ShiftedRotatedHighCondElliptic(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) +{ } // F03ShiftedRotatedHighCondElliptic @@ -42,23 +43,25 @@ F03ShiftedRotatedHighCondElliptic::F03ShiftedRotatedHighCondElliptic(int dimensi * Constructor */ F03ShiftedRotatedHighCondElliptic::F03ShiftedRotatedHighCondElliptic(int dimension, double bias, string file_data, string file_m) - : TestFunc(dimension, bias, FUNCTION_NAME) { - - // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_matrix = new double*[m_dimension]; - for (int i=0; i #include -class F03ShiftedRotatedHighCondElliptic : public TestFunc { +class F03ShiftedRotatedHighCondElliptic : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; + static const string DEFAULT_FILE_MX_PREFIX; + static const string DEFAULT_FILE_MX_SUFFIX; - // Shifted global optimum - double * m_o; - double ** m_matrix; + // Shifted global optimum + double * m_o; + double ** m_matrix; - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_z; - double * m_zM; + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_z; + double * m_zM; - double constant; + double constant; - string getFileMxName(string prefix, int dimension, string suffix); + string getFileMxName(string prefix, int dimension, string suffix); public: - F03ShiftedRotatedHighCondElliptic(int dimension, double bias); - F03ShiftedRotatedHighCondElliptic(int dimension, double bias, string file_data, string file_m); - ~F03ShiftedRotatedHighCondElliptic(); + F03ShiftedRotatedHighCondElliptic(int dimension, double bias); + F03ShiftedRotatedHighCondElliptic(int dimension, double bias, string file_data, string file_m); + ~F03ShiftedRotatedHighCondElliptic(); - double f (double * x); + double f (double * x); }; // F03ShiftedRotatedHighCondElliptic diff --git a/src/problems/singleObjective/cec2005Competition/F04ShiftedSchwefelNoise.cpp b/src/problems/singleObjective/cec2005Competition/F04ShiftedSchwefelNoise.cpp index c583a89..39ec23e 100644 --- a/src/problems/singleObjective/cec2005Competition/F04ShiftedSchwefelNoise.cpp +++ b/src/problems/singleObjective/cec2005Competition/F04ShiftedSchwefelNoise.cpp @@ -32,7 +32,8 @@ const string F04ShiftedSchwefelNoise::DEFAULT_FILE_DATA = "../../data/cec2005Com * Constructor. */ F04ShiftedSchwefelNoise::F04ShiftedSchwefelNoise(int dimension, double bias) - : F04ShiftedSchwefelNoise(dimension, bias, DEFAULT_FILE_DATA) { + : F04ShiftedSchwefelNoise(dimension, bias, DEFAULT_FILE_DATA) +{ } // F04ShiftedSchwefelNoise @@ -40,14 +41,15 @@ F04ShiftedSchwefelNoise::F04ShiftedSchwefelNoise(int dimension, double bias) * Constructor */ F04ShiftedSchwefelNoise::F04ShiftedSchwefelNoise(int dimension, double bias, string file_data) - : TestFunc(dimension, bias, FUNCTION_NAME) { + : TestFunc(dimension, bias, FUNCTION_NAME) +{ - // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_z = new double[m_dimension]; + // Note: dimension starts from 0 + m_o = new double[m_dimension]; + m_z = new double[m_dimension]; - // Load the shifted global optimum - Benchmark::loadRowVectorFromFile(file_data, m_dimension, m_o); + // Load the shifted global optimum + Benchmark::loadRowVectorFromFile(file_data, m_dimension, m_o); } // F04ShiftedSchwefelNoise @@ -55,27 +57,29 @@ F04ShiftedSchwefelNoise::F04ShiftedSchwefelNoise(int dimension, double bias, str /** * Destructor */ -F04ShiftedSchwefelNoise::~F04ShiftedSchwefelNoise() { - delete [] m_o; - delete [] m_z; +F04ShiftedSchwefelNoise::~F04ShiftedSchwefelNoise() +{ + delete [] m_o; + delete [] m_z; } // ~F04ShiftedSchwefelNoise /** * Function body */ -double F04ShiftedSchwefelNoise::f(double * x) { - double result = 0.0; +double F04ShiftedSchwefelNoise::f(double * x) +{ + double result = 0.0; - Benchmark::shift(m_z, x, m_o, m_dimension); + Benchmark::shift(m_z, x, m_o, m_dimension); - result = Benchmark::schwefel_102(m_z, m_dimension); + result = Benchmark::schwefel_102(m_z, m_dimension); - // NOISE - // Comment the next line to remove the noise - result *= (1.0 + 0.4 * fabs(Benchmark::dist(Benchmark::e2))); + // NOISE + // Comment the next line to remove the noise + result *= (1.0 + 0.4 * fabs(Benchmark::dist(Benchmark::e2))); - result += m_bias; + result += m_bias; - return result; + return result; } diff --git a/src/problems/singleObjective/cec2005Competition/F04ShiftedSchwefelNoise.h b/src/problems/singleObjective/cec2005Competition/F04ShiftedSchwefelNoise.h index e8825c9..546c326 100644 --- a/src/problems/singleObjective/cec2005Competition/F04ShiftedSchwefelNoise.h +++ b/src/problems/singleObjective/cec2005Competition/F04ShiftedSchwefelNoise.h @@ -25,28 +25,29 @@ #include #include -class F04ShiftedSchwefelNoise : public TestFunc { +class F04ShiftedSchwefelNoise : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; - // Shifted global optimum - double * m_o; + // Shifted global optimum + double * m_o; - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_z; + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_z; public: - F04ShiftedSchwefelNoise(int dimension, double bias); - F04ShiftedSchwefelNoise(int dimension, double bias, string file_data); - ~F04ShiftedSchwefelNoise(); + F04ShiftedSchwefelNoise(int dimension, double bias); + F04ShiftedSchwefelNoise(int dimension, double bias, string file_data); + ~F04ShiftedSchwefelNoise(); - double f (double * x); + double f (double * x); }; // F04ShiftedSchwefelNoise diff --git a/src/problems/singleObjective/cec2005Competition/F05SchwefelGlobalOptBound.cpp b/src/problems/singleObjective/cec2005Competition/F05SchwefelGlobalOptBound.cpp index 389f048..ff199b5 100644 --- a/src/problems/singleObjective/cec2005Competition/F05SchwefelGlobalOptBound.cpp +++ b/src/problems/singleObjective/cec2005Competition/F05SchwefelGlobalOptBound.cpp @@ -32,7 +32,8 @@ const string F05SchwefelGlobalOptBound::DEFAULT_FILE_DATA = "../../data/cec2005C * Constructor. */ F05SchwefelGlobalOptBound::F05SchwefelGlobalOptBound(int dimension, double bias) - : F05SchwefelGlobalOptBound(dimension, bias, DEFAULT_FILE_DATA) { + : F05SchwefelGlobalOptBound(dimension, bias, DEFAULT_FILE_DATA) +{ } // F05SchwefelGlobalOptBound @@ -40,44 +41,56 @@ F05SchwefelGlobalOptBound::F05SchwefelGlobalOptBound(int dimension, double bias) * Constructor */ F05SchwefelGlobalOptBound::F05SchwefelGlobalOptBound(int dimension, double bias, string file_data) - : TestFunc(dimension, bias, FUNCTION_NAME) { - - // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_A = new double*[m_dimension]; - for (int i=0; i= floor((3.0 * m_dimension) / 4.0)) { - m_o[i] = 100.0; - } else { - m_o[i] = m_data[0][i]; + : TestFunc(dimension, bias, FUNCTION_NAME) +{ + + // Note: dimension starts from 0 + m_o = new double[m_dimension]; + m_A = new double*[m_dimension]; + for (int i=0; i= floor((3.0 * m_dimension) / 4.0)) + { + m_o[i] = 100.0; + } + else + { + m_o[i] = m_data[0][i]; + } + } + for (int i = 0 ; i < m_dimension ; i ++) + { + for (int j = 0 ; j < m_dimension ; j ++) + { + m_A[i][j] = m_data[i+1][j]; + } } - } - Benchmark::Ax(m_B, m_A, m_o, m_dimension); + Benchmark::Ax(m_B, m_A, m_o, m_dimension); - for (int i=0; i::max(); - - Benchmark::Ax(m_z, m_A, x, m_dimension); - - for (int i = 0 ; i < m_dimension ; i ++) { - double temp = fabs(m_z[i] - m_B[i]); - if (max < temp) { - max = temp; +double F05SchwefelGlobalOptBound::f(double * x) +{ + double max = -numeric_limits::max(); + + Benchmark::Ax(m_z, m_A, x, m_dimension); + + for (int i = 0 ; i < m_dimension ; i ++) + { + double temp = fabs(m_z[i] - m_B[i]); + if (max < temp) + { + max = temp; + } } - } - return (max + m_bias); + return (max + m_bias); } diff --git a/src/problems/singleObjective/cec2005Competition/F05SchwefelGlobalOptBound.h b/src/problems/singleObjective/cec2005Competition/F05SchwefelGlobalOptBound.h index 17f7fc2..b6215c9 100644 --- a/src/problems/singleObjective/cec2005Competition/F05SchwefelGlobalOptBound.h +++ b/src/problems/singleObjective/cec2005Competition/F05SchwefelGlobalOptBound.h @@ -25,30 +25,31 @@ #include #include -class F05SchwefelGlobalOptBound : public TestFunc { +class F05SchwefelGlobalOptBound : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; - // Shifted global optimum - double * m_o; - double ** m_A; + // Shifted global optimum + double * m_o; + double ** m_A; - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_B; - double * m_z; + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_B; + double * m_z; public: - F05SchwefelGlobalOptBound(int dimension, double bias); - F05SchwefelGlobalOptBound(int dimension, double bias, string file_data); - ~F05SchwefelGlobalOptBound(); + F05SchwefelGlobalOptBound(int dimension, double bias); + F05SchwefelGlobalOptBound(int dimension, double bias, string file_data); + ~F05SchwefelGlobalOptBound(); - double f (double * x); + double f (double * x); }; // F05SchwefelGlobalOptBound diff --git a/src/problems/singleObjective/cec2005Competition/F06ShiftedRosenbrock.cpp b/src/problems/singleObjective/cec2005Competition/F06ShiftedRosenbrock.cpp index b5624ab..f525229 100644 --- a/src/problems/singleObjective/cec2005Competition/F06ShiftedRosenbrock.cpp +++ b/src/problems/singleObjective/cec2005Competition/F06ShiftedRosenbrock.cpp @@ -32,7 +32,8 @@ const string F06ShiftedRosenbrock::DEFAULT_FILE_DATA = "../../data/cec2005Compet * Constructor. */ F06ShiftedRosenbrock::F06ShiftedRosenbrock(int dimension, double bias) - : F06ShiftedRosenbrock(dimension, bias, DEFAULT_FILE_DATA) { + : F06ShiftedRosenbrock(dimension, bias, DEFAULT_FILE_DATA) +{ } // F06ShiftedRosenbrock @@ -40,20 +41,22 @@ F06ShiftedRosenbrock::F06ShiftedRosenbrock(int dimension, double bias) * Constructor */ F06ShiftedRosenbrock::F06ShiftedRosenbrock(int dimension, double bias, string file_data) - : TestFunc(dimension, bias, FUNCTION_NAME) { + : TestFunc(dimension, bias, FUNCTION_NAME) +{ - // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_z = new double[m_dimension]; + // Note: dimension starts from 0 + m_o = new double[m_dimension]; + m_z = new double[m_dimension]; - // Load the shifted global optimum - Benchmark::loadRowVectorFromFile(file_data, m_dimension, m_o); + // Load the shifted global optimum + Benchmark::loadRowVectorFromFile(file_data, m_dimension, m_o); - // z = x - o + 1 = x - (o - 1) - // Do the "(o - 1)" part first - for (int i = 0 ; i < m_dimension ; i ++) { - m_o[i] -= 1.0; - } + // z = x - o + 1 = x - (o - 1) + // Do the "(o - 1)" part first + for (int i = 0 ; i < m_dimension ; i ++) + { + m_o[i] -= 1.0; + } } // F06ShiftedRosenbrock @@ -61,23 +64,25 @@ F06ShiftedRosenbrock::F06ShiftedRosenbrock(int dimension, double bias, string fi /** * Destructor */ -F06ShiftedRosenbrock::~F06ShiftedRosenbrock() { - delete [] m_o; - delete [] m_z; +F06ShiftedRosenbrock::~F06ShiftedRosenbrock() +{ + delete [] m_o; + delete [] m_z; } // ~F06ShiftedRosenbrock /** * Function body */ -double F06ShiftedRosenbrock::f(double * x) { - double result = 0.0; +double F06ShiftedRosenbrock::f(double * x) +{ + double result = 0.0; - Benchmark::shift(m_z, x, m_o, m_dimension); + Benchmark::shift(m_z, x, m_o, m_dimension); - result = Benchmark::rosenbrock(m_z, m_dimension); + result = Benchmark::rosenbrock(m_z, m_dimension); - result += m_bias; + result += m_bias; - return result; + return result; } diff --git a/src/problems/singleObjective/cec2005Competition/F06ShiftedRosenbrock.h b/src/problems/singleObjective/cec2005Competition/F06ShiftedRosenbrock.h index 958b8e6..8eb2bd5 100644 --- a/src/problems/singleObjective/cec2005Competition/F06ShiftedRosenbrock.h +++ b/src/problems/singleObjective/cec2005Competition/F06ShiftedRosenbrock.h @@ -25,28 +25,29 @@ #include #include -class F06ShiftedRosenbrock : public TestFunc { +class F06ShiftedRosenbrock : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; - // Shifted global optimum - double * m_o; + // Shifted global optimum + double * m_o; - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_z; + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_z; public: - F06ShiftedRosenbrock(int dimension, double bias); - F06ShiftedRosenbrock(int dimension, double bias, string file_data); - ~F06ShiftedRosenbrock(); + F06ShiftedRosenbrock(int dimension, double bias); + F06ShiftedRosenbrock(int dimension, double bias, string file_data); + ~F06ShiftedRosenbrock(); - double f (double * x); + double f (double * x); }; // F06ShiftedRosenbrock diff --git a/src/problems/singleObjective/cec2005Competition/F07ShiftedRotatedGriewank.cpp b/src/problems/singleObjective/cec2005Competition/F07ShiftedRotatedGriewank.cpp index 8887f03..d74771c 100644 --- a/src/problems/singleObjective/cec2005Competition/F07ShiftedRotatedGriewank.cpp +++ b/src/problems/singleObjective/cec2005Competition/F07ShiftedRotatedGriewank.cpp @@ -34,7 +34,8 @@ const string F07ShiftedRotatedGriewank::DEFAULT_FILE_MX_SUFFIX = ".txt"; * Constructor. */ F07ShiftedRotatedGriewank::F07ShiftedRotatedGriewank(int dimension, double bias) - : F07ShiftedRotatedGriewank(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) { + : F07ShiftedRotatedGriewank(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) +{ } // F07ShiftedRotatedGriewank @@ -42,21 +43,23 @@ F07ShiftedRotatedGriewank::F07ShiftedRotatedGriewank(int dimension, double bias) * Constructor */ F07ShiftedRotatedGriewank::F07ShiftedRotatedGriewank(int dimension, double bias, string file_data, string file_m) - : TestFunc(dimension, bias, FUNCTION_NAME) { - - // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_matrix = new double*[m_dimension]; - for (int i=0; i #include -class F07ShiftedRotatedGriewank : public TestFunc { +class F07ShiftedRotatedGriewank : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; + static const string DEFAULT_FILE_MX_PREFIX; + static const string DEFAULT_FILE_MX_SUFFIX; - // Shifted global optimum - double * m_o; - double ** m_matrix; + // Shifted global optimum + double * m_o; + double ** m_matrix; - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_z; - double * m_zM; + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_z; + double * m_zM; - string getFileMxName(string prefix, int dimension, string suffix); + string getFileMxName(string prefix, int dimension, string suffix); public: - F07ShiftedRotatedGriewank(int dimension, double bias); - F07ShiftedRotatedGriewank(int dimension, double bias, string file_data, string file_m); - ~F07ShiftedRotatedGriewank(); + F07ShiftedRotatedGriewank(int dimension, double bias); + F07ShiftedRotatedGriewank(int dimension, double bias, string file_data, string file_m); + ~F07ShiftedRotatedGriewank(); - double f (double * x); + double f (double * x); }; // F07ShiftedRotatedGriewank diff --git a/src/problems/singleObjective/cec2005Competition/F08ShiftedRotatedAckleyGlobalOptBound.cpp b/src/problems/singleObjective/cec2005Competition/F08ShiftedRotatedAckleyGlobalOptBound.cpp index 7770bd8..45003fd 100644 --- a/src/problems/singleObjective/cec2005Competition/F08ShiftedRotatedAckleyGlobalOptBound.cpp +++ b/src/problems/singleObjective/cec2005Competition/F08ShiftedRotatedAckleyGlobalOptBound.cpp @@ -34,7 +34,8 @@ const string F08ShiftedRotatedAckleyGlobalOptBound::DEFAULT_FILE_MX_SUFFIX = ".t * Constructor. */ F08ShiftedRotatedAckleyGlobalOptBound::F08ShiftedRotatedAckleyGlobalOptBound(int dimension, double bias) - : F08ShiftedRotatedAckleyGlobalOptBound(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) { + : F08ShiftedRotatedAckleyGlobalOptBound(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) +{ } // F08ShiftedRotatedAckleyGlobalOptBound @@ -42,25 +43,28 @@ F08ShiftedRotatedAckleyGlobalOptBound::F08ShiftedRotatedAckleyGlobalOptBound(int * Constructor */ F08ShiftedRotatedAckleyGlobalOptBound::F08ShiftedRotatedAckleyGlobalOptBound(int dimension, double bias, string file_data, string file_m) - : TestFunc(dimension, bias, FUNCTION_NAME) { - - // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_matrix = new double*[m_dimension]; - for (int i=0; i #include -class F08ShiftedRotatedAckleyGlobalOptBound : public TestFunc { +class F08ShiftedRotatedAckleyGlobalOptBound : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; + static const string DEFAULT_FILE_MX_PREFIX; + static const string DEFAULT_FILE_MX_SUFFIX; - // Shifted global optimum - double * m_o; - double ** m_matrix; + // Shifted global optimum + double * m_o; + double ** m_matrix; - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_z; - double * m_zM; + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_z; + double * m_zM; - string getFileMxName(string prefix, int dimension, string suffix); + string getFileMxName(string prefix, int dimension, string suffix); public: - F08ShiftedRotatedAckleyGlobalOptBound(int dimension, double bias); - F08ShiftedRotatedAckleyGlobalOptBound(int dimension, double bias, string file_data, string file_m); - ~F08ShiftedRotatedAckleyGlobalOptBound(); + F08ShiftedRotatedAckleyGlobalOptBound(int dimension, double bias); + F08ShiftedRotatedAckleyGlobalOptBound(int dimension, double bias, string file_data, string file_m); + ~F08ShiftedRotatedAckleyGlobalOptBound(); - double f (double * x); + double f (double * x); }; // F08ShiftedRotatedAckleyGlobalOptBound diff --git a/src/problems/singleObjective/cec2005Competition/F09ShiftedRastrigin.cpp b/src/problems/singleObjective/cec2005Competition/F09ShiftedRastrigin.cpp index 2964a21..5a4afff 100644 --- a/src/problems/singleObjective/cec2005Competition/F09ShiftedRastrigin.cpp +++ b/src/problems/singleObjective/cec2005Competition/F09ShiftedRastrigin.cpp @@ -32,7 +32,8 @@ const string F09ShiftedRastrigin::DEFAULT_FILE_DATA = "../../data/cec2005Competi * Constructor. */ F09ShiftedRastrigin::F09ShiftedRastrigin(int dimension, double bias) - : F09ShiftedRastrigin(dimension, bias, DEFAULT_FILE_DATA) { + : F09ShiftedRastrigin(dimension, bias, DEFAULT_FILE_DATA) +{ } // F09ShiftedRastrigin @@ -40,14 +41,15 @@ F09ShiftedRastrigin::F09ShiftedRastrigin(int dimension, double bias) * Constructor */ F09ShiftedRastrigin::F09ShiftedRastrigin(int dimension, double bias, string file_data) - : TestFunc(dimension, bias, FUNCTION_NAME) { + : TestFunc(dimension, bias, FUNCTION_NAME) +{ - // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_z = new double[m_dimension]; + // Note: dimension starts from 0 + m_o = new double[m_dimension]; + m_z = new double[m_dimension]; - // Load the shifted global optimum - Benchmark::loadRowVectorFromFile(file_data, m_dimension, m_o); + // Load the shifted global optimum + Benchmark::loadRowVectorFromFile(file_data, m_dimension, m_o); } // F09ShiftedRastrigin @@ -55,23 +57,25 @@ F09ShiftedRastrigin::F09ShiftedRastrigin(int dimension, double bias, string file /** * Destructor */ -F09ShiftedRastrigin::~F09ShiftedRastrigin() { - delete [] m_o; - delete [] m_z; +F09ShiftedRastrigin::~F09ShiftedRastrigin() +{ + delete [] m_o; + delete [] m_z; } // ~F09ShiftedRastrigin /** * Function body */ -double F09ShiftedRastrigin::f(double * x) { - double result = 0.0; +double F09ShiftedRastrigin::f(double * x) +{ + double result = 0.0; - Benchmark::shift(m_z, x, m_o, m_dimension); + Benchmark::shift(m_z, x, m_o, m_dimension); - result = Benchmark::rastrigin(m_z, m_dimension); + result = Benchmark::rastrigin(m_z, m_dimension); - result += m_bias; + result += m_bias; - return result; + return result; } diff --git a/src/problems/singleObjective/cec2005Competition/F09ShiftedRastrigin.h b/src/problems/singleObjective/cec2005Competition/F09ShiftedRastrigin.h index 45e1183..3fd4923 100644 --- a/src/problems/singleObjective/cec2005Competition/F09ShiftedRastrigin.h +++ b/src/problems/singleObjective/cec2005Competition/F09ShiftedRastrigin.h @@ -25,28 +25,29 @@ #include #include -class F09ShiftedRastrigin : public TestFunc { +class F09ShiftedRastrigin : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; - // Shifted global optimum - double * m_o; + // Shifted global optimum + double * m_o; - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_z; + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_z; public: - F09ShiftedRastrigin(int dimension, double bias); - F09ShiftedRastrigin(int dimension, double bias, string file_data); - ~F09ShiftedRastrigin(); + F09ShiftedRastrigin(int dimension, double bias); + F09ShiftedRastrigin(int dimension, double bias, string file_data); + ~F09ShiftedRastrigin(); - double f (double * x); + double f (double * x); }; // F09ShiftedRastrigin diff --git a/src/problems/singleObjective/cec2005Competition/F10ShiftedRotatedRastrigin.cpp b/src/problems/singleObjective/cec2005Competition/F10ShiftedRotatedRastrigin.cpp index f474ca1..fd187b8 100644 --- a/src/problems/singleObjective/cec2005Competition/F10ShiftedRotatedRastrigin.cpp +++ b/src/problems/singleObjective/cec2005Competition/F10ShiftedRotatedRastrigin.cpp @@ -34,7 +34,8 @@ const string F10ShiftedRotatedRastrigin::DEFAULT_FILE_MX_SUFFIX = ".txt"; * Constructor. */ F10ShiftedRotatedRastrigin::F10ShiftedRotatedRastrigin(int dimension, double bias) - : F10ShiftedRotatedRastrigin(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) { + : F10ShiftedRotatedRastrigin(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) +{ } // F10ShiftedRotatedRastrigin @@ -42,21 +43,23 @@ F10ShiftedRotatedRastrigin::F10ShiftedRotatedRastrigin(int dimension, double bia * Constructor */ F10ShiftedRotatedRastrigin::F10ShiftedRotatedRastrigin(int dimension, double bias, string file_data, string file_m) - : TestFunc(dimension, bias, FUNCTION_NAME) { - - // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_matrix = new double*[m_dimension]; - for (int i=0; i #include -class F10ShiftedRotatedRastrigin : public TestFunc { +class F10ShiftedRotatedRastrigin : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; + static const string DEFAULT_FILE_MX_PREFIX; + static const string DEFAULT_FILE_MX_SUFFIX; - // Shifted global optimum - double * m_o; - double ** m_matrix; + // Shifted global optimum + double * m_o; + double ** m_matrix; - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_z; - double * m_zM; + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_z; + double * m_zM; - string getFileMxName(string prefix, int dimension, string suffix); + string getFileMxName(string prefix, int dimension, string suffix); public: - F10ShiftedRotatedRastrigin(int dimension, double bias); - F10ShiftedRotatedRastrigin(int dimension, double bias, string file_data, string file_m); - ~F10ShiftedRotatedRastrigin(); + F10ShiftedRotatedRastrigin(int dimension, double bias); + F10ShiftedRotatedRastrigin(int dimension, double bias, string file_data, string file_m); + ~F10ShiftedRotatedRastrigin(); - double f (double * x); + double f (double * x); }; // F10ShiftedRotatedRastrigin diff --git a/src/problems/singleObjective/cec2005Competition/F11ShiftedRotatedWeierstrass.cpp b/src/problems/singleObjective/cec2005Competition/F11ShiftedRotatedWeierstrass.cpp index f8e689f..e525019 100644 --- a/src/problems/singleObjective/cec2005Competition/F11ShiftedRotatedWeierstrass.cpp +++ b/src/problems/singleObjective/cec2005Competition/F11ShiftedRotatedWeierstrass.cpp @@ -38,7 +38,8 @@ const double F11ShiftedRotatedWeierstrass::b = 3.0; * Constructor. */ F11ShiftedRotatedWeierstrass::F11ShiftedRotatedWeierstrass(int dimension, double bias) - : F11ShiftedRotatedWeierstrass(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) { + : F11ShiftedRotatedWeierstrass(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) +{ } // F11ShiftedRotatedWeierstrass @@ -46,21 +47,23 @@ F11ShiftedRotatedWeierstrass::F11ShiftedRotatedWeierstrass(int dimension, double * Constructor */ F11ShiftedRotatedWeierstrass::F11ShiftedRotatedWeierstrass(int dimension, double bias, string file_data, string file_m) - : TestFunc(dimension, bias, FUNCTION_NAME) { - - // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_matrix = new double*[m_dimension]; - for (int i=0; i #include -class F11ShiftedRotatedWeierstrass : public TestFunc { +class F11ShiftedRotatedWeierstrass : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; + static const string DEFAULT_FILE_MX_PREFIX; + static const string DEFAULT_FILE_MX_SUFFIX; - static const int Kmax; - static const double a; - static const double b; + static const int Kmax; + static const double a; + static const double b; - // Shifted global optimum - double * m_o; - double ** m_matrix; + // Shifted global optimum + double * m_o; + double ** m_matrix; - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_z; - double * m_zM; + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_z; + double * m_zM; - string getFileMxName(string prefix, int dimension, string suffix); + string getFileMxName(string prefix, int dimension, string suffix); public: - F11ShiftedRotatedWeierstrass(int dimension, double bias); - F11ShiftedRotatedWeierstrass(int dimension, double bias, string file_data, string file_m); - ~F11ShiftedRotatedWeierstrass(); + F11ShiftedRotatedWeierstrass(int dimension, double bias); + F11ShiftedRotatedWeierstrass(int dimension, double bias, string file_data, string file_m); + ~F11ShiftedRotatedWeierstrass(); - double f (double * x); + double f (double * x); }; // F11ShiftedRotatedWeierstrass diff --git a/src/problems/singleObjective/cec2005Competition/F12Schwefel.cpp b/src/problems/singleObjective/cec2005Competition/F12Schwefel.cpp index 7011d9d..65ad8d8 100644 --- a/src/problems/singleObjective/cec2005Competition/F12Schwefel.cpp +++ b/src/problems/singleObjective/cec2005Competition/F12Schwefel.cpp @@ -32,7 +32,8 @@ const string F12Schwefel::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionReso * Constructor. */ F12Schwefel::F12Schwefel(int dimension, double bias) - : F12Schwefel(dimension, bias, DEFAULT_FILE_DATA) { + : F12Schwefel(dimension, bias, DEFAULT_FILE_DATA) +{ } // F12Schwefel @@ -40,52 +41,61 @@ F12Schwefel::F12Schwefel(int dimension, double bias) * Constructor */ F12Schwefel::F12Schwefel(int dimension, double bias, string file_data) - : TestFunc(dimension, bias, FUNCTION_NAME) { - - // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_a = new double*[m_dimension]; - for (int i = 0; i < m_dimension; i++) { - m_a[i] = new double[m_dimension]; - } - m_b = new double*[m_dimension]; - for (int i = 0; i < m_dimension; i++) { - m_b[i] = new double[m_dimension]; - } - - m_A = new double[m_dimension]; - m_B = new double[m_dimension]; - - // Data: - // 1. a 100x100 - // 2. b 100x100 - // 3. alpha 1x100 - double ** m_data = new double*[100+100+1]; - for (int i = 0; i < (100+100+1); i++) { - m_data[i] = new double[m_dimension]; - } - - // Load the shifted global optimum - Benchmark::loadMatrixFromFile(file_data, (100+100+1), m_dimension, m_data); - for (int i = 0 ; i < m_dimension; i++) { - for (int j = 0 ; j < m_dimension; j++) { - m_a[i][j] = m_data[i][j]; - m_b[i][j] = m_data[100+i][j]; + : TestFunc(dimension, bias, FUNCTION_NAME) +{ + + // Note: dimension starts from 0 + m_o = new double[m_dimension]; + m_a = new double*[m_dimension]; + for (int i = 0; i < m_dimension; i++) + { + m_a[i] = new double[m_dimension]; + } + m_b = new double*[m_dimension]; + for (int i = 0; i < m_dimension; i++) + { + m_b[i] = new double[m_dimension]; + } + + m_A = new double[m_dimension]; + m_B = new double[m_dimension]; + + // Data: + // 1. a 100x100 + // 2. b 100x100 + // 3. alpha 1x100 + double ** m_data = new double*[100+100+1]; + for (int i = 0; i < (100+100+1); i++) + { + m_data[i] = new double[m_dimension]; + } + + // Load the shifted global optimum + Benchmark::loadMatrixFromFile(file_data, (100+100+1), m_dimension, m_data); + for (int i = 0 ; i < m_dimension; i++) + { + for (int j = 0 ; j < m_dimension; j++) + { + m_a[i][j] = m_data[i][j]; + m_b[i][j] = m_data[100+i][j]; + } + m_o[i] = m_data[100+100][i]; } - m_o[i] = m_data[100+100][i]; - } - for (int i = 0; i < m_dimension; i++) { - m_A[i] = 0.0; - for (int j = 0; j < m_dimension; j++) { - m_A[i] += (m_a[i][j] * sin(m_o[j]) + m_b[i][j] * cos(m_o[j])); + for (int i = 0; i < m_dimension; i++) + { + m_A[i] = 0.0; + for (int j = 0; j < m_dimension; j++) + { + m_A[i] += (m_a[i][j] * sin(m_o[j]) + m_b[i][j] * cos(m_o[j])); + } } - } - for (int i = 0; i < (100+100+1); i++) { - delete [] m_data[i]; - } - delete [] m_data; + for (int i = 0; i < (100+100+1); i++) + { + delete [] m_data[i]; + } + delete [] m_data; } // F12Schwefel @@ -93,36 +103,42 @@ F12Schwefel::F12Schwefel(int dimension, double bias, string file_data) /** * Destructor */ -F12Schwefel::~F12Schwefel() { - delete [] m_o; - for (int i = 0; i < m_dimension; i++) { - delete [] m_a[i]; - } - delete [] m_a; - for (int i = 0; i #include -class F12Schwefel : public TestFunc { +class F12Schwefel : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; - // Shifted global optimum - double * m_o; - double ** m_a; - double ** m_b; + // Shifted global optimum + double * m_o; + double ** m_a; + double ** m_b; - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_A; - double * m_B; + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_A; + double * m_B; public: - F12Schwefel(int dimension, double bias); - F12Schwefel(int dimension, double bias, string file_data); - ~F12Schwefel(); + F12Schwefel(int dimension, double bias); + F12Schwefel(int dimension, double bias, string file_data); + ~F12Schwefel(); - double f (double * x); + double f (double * x); }; // F12Schwefel diff --git a/src/problems/singleObjective/cec2005Competition/F13ShiftedExpandedGriewankRosenbrock.cpp b/src/problems/singleObjective/cec2005Competition/F13ShiftedExpandedGriewankRosenbrock.cpp index df5a240..7c34af4 100644 --- a/src/problems/singleObjective/cec2005Competition/F13ShiftedExpandedGriewankRosenbrock.cpp +++ b/src/problems/singleObjective/cec2005Competition/F13ShiftedExpandedGriewankRosenbrock.cpp @@ -32,7 +32,8 @@ const string F13ShiftedExpandedGriewankRosenbrock::DEFAULT_FILE_DATA = "../../da * Constructor. */ F13ShiftedExpandedGriewankRosenbrock::F13ShiftedExpandedGriewankRosenbrock(int dimension, double bias) - : F13ShiftedExpandedGriewankRosenbrock(dimension, bias, DEFAULT_FILE_DATA) { + : F13ShiftedExpandedGriewankRosenbrock(dimension, bias, DEFAULT_FILE_DATA) +{ } // F13ShiftedExpandedGriewankRosenbrock @@ -40,20 +41,22 @@ F13ShiftedExpandedGriewankRosenbrock::F13ShiftedExpandedGriewankRosenbrock(int d * Constructor */ F13ShiftedExpandedGriewankRosenbrock::F13ShiftedExpandedGriewankRosenbrock(int dimension, double bias, string file_data) - : TestFunc(dimension, bias, FUNCTION_NAME) { + : TestFunc(dimension, bias, FUNCTION_NAME) +{ - // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_z = new double[m_dimension]; + // Note: dimension starts from 0 + m_o = new double[m_dimension]; + m_z = new double[m_dimension]; - // Load the shifted global optimum - Benchmark::loadRowVectorFromFile(file_data, m_dimension, m_o); + // Load the shifted global optimum + Benchmark::loadRowVectorFromFile(file_data, m_dimension, m_o); - // z = x - o + 1 = x - (o - 1) - // Do the "(o - 1)" part first - for (int i = 0 ; i < m_dimension ; i++) { - m_o[i] -= 1.0; - } + // z = x - o + 1 = x - (o - 1) + // Do the "(o - 1)" part first + for (int i = 0 ; i < m_dimension ; i++) + { + m_o[i] -= 1.0; + } } // F13ShiftedExpandedGriewankRosenbrock @@ -61,23 +64,25 @@ F13ShiftedExpandedGriewankRosenbrock::F13ShiftedExpandedGriewankRosenbrock(int d /** * Destructor */ -F13ShiftedExpandedGriewankRosenbrock::~F13ShiftedExpandedGriewankRosenbrock() { - delete [] m_o; - delete [] m_z; +F13ShiftedExpandedGriewankRosenbrock::~F13ShiftedExpandedGriewankRosenbrock() +{ + delete [] m_o; + delete [] m_z; } // ~F13ShiftedExpandedGriewankRosenbrock /** * Function body */ -double F13ShiftedExpandedGriewankRosenbrock::f(double * x) { - double result = 0.0; +double F13ShiftedExpandedGriewankRosenbrock::f(double * x) +{ + double result = 0.0; - Benchmark::shift(m_z, x, m_o, m_dimension); + Benchmark::shift(m_z, x, m_o, m_dimension); - result = Benchmark::F8F2(m_z, m_dimension); + result = Benchmark::F8F2(m_z, m_dimension); - result += m_bias; + result += m_bias; - return result; + return result; } diff --git a/src/problems/singleObjective/cec2005Competition/F13ShiftedExpandedGriewankRosenbrock.h b/src/problems/singleObjective/cec2005Competition/F13ShiftedExpandedGriewankRosenbrock.h index 6c33859..daf5b7a 100644 --- a/src/problems/singleObjective/cec2005Competition/F13ShiftedExpandedGriewankRosenbrock.h +++ b/src/problems/singleObjective/cec2005Competition/F13ShiftedExpandedGriewankRosenbrock.h @@ -25,28 +25,29 @@ #include #include -class F13ShiftedExpandedGriewankRosenbrock : public TestFunc { +class F13ShiftedExpandedGriewankRosenbrock : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; - // Shifted global optimum - double * m_o; + // Shifted global optimum + double * m_o; - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_z; + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_z; public: - F13ShiftedExpandedGriewankRosenbrock(int dimension, double bias); - F13ShiftedExpandedGriewankRosenbrock(int dimension, double bias, string file_data); - ~F13ShiftedExpandedGriewankRosenbrock(); + F13ShiftedExpandedGriewankRosenbrock(int dimension, double bias); + F13ShiftedExpandedGriewankRosenbrock(int dimension, double bias, string file_data); + ~F13ShiftedExpandedGriewankRosenbrock(); - double f (double * x); + double f (double * x); }; // F13ShiftedExpandedGriewankRosenbrock diff --git a/src/problems/singleObjective/cec2005Competition/F14ShiftedRotatedExpandedScaffer.cpp b/src/problems/singleObjective/cec2005Competition/F14ShiftedRotatedExpandedScaffer.cpp index c4c866b..af40250 100644 --- a/src/problems/singleObjective/cec2005Competition/F14ShiftedRotatedExpandedScaffer.cpp +++ b/src/problems/singleObjective/cec2005Competition/F14ShiftedRotatedExpandedScaffer.cpp @@ -34,7 +34,8 @@ const string F14ShiftedRotatedExpandedScaffer::DEFAULT_FILE_MX_SUFFIX = ".txt"; * Constructor. */ F14ShiftedRotatedExpandedScaffer::F14ShiftedRotatedExpandedScaffer(int dimension, double bias) - : F14ShiftedRotatedExpandedScaffer(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) { + : F14ShiftedRotatedExpandedScaffer(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) +{ } // F14ShiftedRotatedExpandedScaffer @@ -42,21 +43,23 @@ F14ShiftedRotatedExpandedScaffer::F14ShiftedRotatedExpandedScaffer(int dimension * Constructor */ F14ShiftedRotatedExpandedScaffer::F14ShiftedRotatedExpandedScaffer(int dimension, double bias, string file_data, string file_m) - : TestFunc(dimension, bias, FUNCTION_NAME) { - - // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_matrix = new double*[m_dimension]; - for (int i=0; i #include -class F14ShiftedRotatedExpandedScaffer : public TestFunc { +class F14ShiftedRotatedExpandedScaffer : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; + static const string DEFAULT_FILE_MX_PREFIX; + static const string DEFAULT_FILE_MX_SUFFIX; - // Shifted global optimum - double * m_o; - double ** m_matrix; + // Shifted global optimum + double * m_o; + double ** m_matrix; - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_z; - double * m_zM; + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_z; + double * m_zM; - string getFileMxName(string prefix, int dimension, string suffix); + string getFileMxName(string prefix, int dimension, string suffix); public: - F14ShiftedRotatedExpandedScaffer(int dimension, double bias); - F14ShiftedRotatedExpandedScaffer(int dimension, double bias, string file_data, string file_m); - ~F14ShiftedRotatedExpandedScaffer(); + F14ShiftedRotatedExpandedScaffer(int dimension, double bias); + F14ShiftedRotatedExpandedScaffer(int dimension, double bias, string file_data, string file_m); + ~F14ShiftedRotatedExpandedScaffer(); - double f (double * x); + double f (double * x); }; // F14ShiftedRotatedExpandedScaffer diff --git a/src/problems/singleObjective/cec2005Competition/F15HybridComposition1.cpp b/src/problems/singleObjective/cec2005Competition/F15HybridComposition1.cpp index 7057325..0f92cbd 100644 --- a/src/problems/singleObjective/cec2005Competition/F15HybridComposition1.cpp +++ b/src/problems/singleObjective/cec2005Competition/F15HybridComposition1.cpp @@ -28,20 +28,23 @@ const string F15HybridComposition1::FUNCTION_NAME = "Hybrid Composition Function const string F15HybridComposition1::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/hybrid_func1_data.txt"; -const double F15HybridComposition1::m_sigma[NUM_FUNC] = { - 1.0, 1.0, 1.0, 1.0, 1.0, - 1.0, 1.0, 1.0, 1.0, 1.0 +const double F15HybridComposition1::m_sigma[NUM_FUNC] = +{ + 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0 }; -const double F15HybridComposition1::m_lambda[NUM_FUNC] = { - 1.0, 1.0, 10.0, 10.0, - 5.0/60.0, 5.0/60.0, 5.0/32.0, 5.0/32.0, - 5.0/100.0, 5.0/100.0 +const double F15HybridComposition1::m_lambda[NUM_FUNC] = +{ + 1.0, 1.0, 10.0, 10.0, + 5.0/60.0, 5.0/60.0, 5.0/32.0, 5.0/32.0, + 5.0/100.0, 5.0/100.0 }; -const double F15HybridComposition1::m_func_biases[NUM_FUNC] = { - 0.0, 100.0, 200.0, 300.0, 400.0, - 500.0, 600.0, 700.0, 800.0, 900.0 +const double F15HybridComposition1::m_func_biases[NUM_FUNC] = +{ + 0.0, 100.0, 200.0, 300.0, 400.0, + 500.0, 600.0, 700.0, 800.0, 900.0 }; @@ -49,7 +52,8 @@ const double F15HybridComposition1::m_func_biases[NUM_FUNC] = { * Constructor. */ F15HybridComposition1::F15HybridComposition1(int dimension, double bias) - : F15HybridComposition1(dimension, bias, DEFAULT_FILE_DATA) { + : F15HybridComposition1(dimension, bias, DEFAULT_FILE_DATA) +{ } // F15HybridComposition1 @@ -57,66 +61,75 @@ F15HybridComposition1::F15HybridComposition1(int dimension, double bias) * Constructor */ F15HybridComposition1::F15HybridComposition1(int dimension, double bias, string file_data) - : TestFunc(dimension, bias, FUNCTION_NAME) { - - // Note: dimension starts from 0 - m_o = new double*[NUM_FUNC]; - m_M = new double**[NUM_FUNC]; - - m_testPoint = new double[m_dimension]; - m_testPointM = new double[m_dimension]; - m_fmax = new double[NUM_FUNC]; - - m_w = new double[NUM_FUNC]; - m_z = new double*[NUM_FUNC]; - m_zM = new double*[NUM_FUNC]; - - for (int i=0; inum_func = NUM_FUNC; + theJob->num_dim = m_dimension; + theJob->C = 2000.0; + for (int i=0; isigma[i] = m_sigma[i]; + theJob->biases[i] = m_func_biases[i]; + theJob->lambda[i] = m_lambda[i]; } - } - - // Initialize the hybrid composition job object - theJob = new MyHCJob(NUM_FUNC); - theJob->num_func = NUM_FUNC; - theJob->num_dim = m_dimension; - theJob->C = 2000.0; - for (int i=0; isigma[i] = m_sigma[i]; - theJob->biases[i] = m_func_biases[i]; - theJob->lambda[i] = m_lambda[i]; - } - theJob->o = m_o; - theJob->M = m_M; - theJob->w = m_w; - theJob->z = m_z; - theJob->zM = m_zM; - // Calculate/estimate the fmax for all the functions involved - for (int i=0; io = m_o; + theJob->M = m_M; + theJob->w = m_w; + theJob->z = m_z; + theJob->zM = m_zM; + // Calculate/estimate the fmax for all the functions involved + for (int i=0; ibasic_func(i, m_testPointM, m_dimension)); } - Benchmark::rotate(m_testPointM, m_testPoint, m_M[i], m_dimension); - m_fmax[i] = fabs(theJob->basic_func(i, m_testPointM, m_dimension)); - } - theJob->fmax = m_fmax; + theJob->fmax = m_fmax; } // F15HybridComposition1 @@ -124,78 +137,85 @@ F15HybridComposition1::F15HybridComposition1(int dimension, double bias, string /** * Destructor */ -F15HybridComposition1::~F15HybridComposition1() { - - for (int i=0; i #include -class F15HybridComposition1 : public TestFunc { +class F15HybridComposition1 : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; - // Number of functions - static const int NUM_FUNC = 10; + // Number of functions + static const int NUM_FUNC = 10; - // Shifted global optimum - double ** m_o; - double *** m_M; - static const double m_sigma[NUM_FUNC]; - static const double m_lambda[NUM_FUNC]; - static const double m_func_biases[NUM_FUNC]; - double * m_testPoint; - double * m_testPointM; - double * m_fmax; + // Shifted global optimum + double ** m_o; + double *** m_M; + static const double m_sigma[NUM_FUNC]; + static const double m_lambda[NUM_FUNC]; + static const double m_func_biases[NUM_FUNC]; + double * m_testPoint; + double * m_testPointM; + double * m_fmax; - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_w; - double ** m_z; - double ** m_zM; + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_w; + double ** m_z; + double ** m_zM; - class MyHCJob : public HCJob { - public: - MyHCJob(int numFunc); - double basic_func(int func_no, double* x, int length); - }; + class MyHCJob : public HCJob + { + public: + MyHCJob(int numFunc); + double basic_func(int func_no, double* x, int length); + }; - MyHCJob * theJob; + MyHCJob * theJob; public: - F15HybridComposition1(int dimension, double bias); - F15HybridComposition1(int dimension, double bias, string file_data); - ~F15HybridComposition1(); + F15HybridComposition1(int dimension, double bias); + F15HybridComposition1(int dimension, double bias, string file_data); + ~F15HybridComposition1(); - double f (double * x); + double f (double * x); }; // F15HybridComposition1 diff --git a/src/problems/singleObjective/cec2005Competition/F16RotatedHybridComposition1.cpp b/src/problems/singleObjective/cec2005Competition/F16RotatedHybridComposition1.cpp index 23e5f2e..774add3 100644 --- a/src/problems/singleObjective/cec2005Competition/F16RotatedHybridComposition1.cpp +++ b/src/problems/singleObjective/cec2005Competition/F16RotatedHybridComposition1.cpp @@ -29,20 +29,23 @@ const string F16RotatedHybridComposition1::DEFAULT_FILE_DATA = "../../data/cec20 const string F16RotatedHybridComposition1::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func1_M_D"; const string F16RotatedHybridComposition1::DEFAULT_FILE_MX_SUFFIX = ".txt"; -const double F16RotatedHybridComposition1::m_sigma[NUM_FUNC] = { - 1.0, 1.0, 1.0, 1.0, 1.0, - 1.0, 1.0, 1.0, 1.0, 1.0 +const double F16RotatedHybridComposition1::m_sigma[NUM_FUNC] = +{ + 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0 }; -const double F16RotatedHybridComposition1::m_lambda[NUM_FUNC] = { - 1.0, 1.0, 10.0, 10.0, - 5.0/60.0, 5.0/60.0, 5.0/32.0, 5.0/32.0, - 5.0/100.0, 5.0/100.0 +const double F16RotatedHybridComposition1::m_lambda[NUM_FUNC] = +{ + 1.0, 1.0, 10.0, 10.0, + 5.0/60.0, 5.0/60.0, 5.0/32.0, 5.0/32.0, + 5.0/100.0, 5.0/100.0 }; -const double F16RotatedHybridComposition1::m_func_biases[NUM_FUNC] = { - 0.0, 100.0, 200.0, 300.0, 400.0, - 500.0, 600.0, 700.0, 800.0, 900.0 +const double F16RotatedHybridComposition1::m_func_biases[NUM_FUNC] = +{ + 0.0, 100.0, 200.0, 300.0, 400.0, + 500.0, 600.0, 700.0, 800.0, 900.0 }; @@ -50,7 +53,8 @@ const double F16RotatedHybridComposition1::m_func_biases[NUM_FUNC] = { * Constructor. */ F16RotatedHybridComposition1::F16RotatedHybridComposition1(int dimension, double bias) - : F16RotatedHybridComposition1(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) { + : F16RotatedHybridComposition1(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) +{ } // F16RotatedHybridComposition1 @@ -58,59 +62,65 @@ F16RotatedHybridComposition1::F16RotatedHybridComposition1(int dimension, double * Constructor */ F16RotatedHybridComposition1::F16RotatedHybridComposition1(int dimension, double bias, string file_data, string file_m) - : TestFunc(dimension, bias, FUNCTION_NAME) { - - // Note: dimension starts from 0 - m_o = new double*[NUM_FUNC]; - m_M = new double**[NUM_FUNC]; - - m_testPoint = new double[m_dimension]; - m_testPointM = new double[m_dimension]; - m_fmax = new double[NUM_FUNC]; - - m_w = new double[NUM_FUNC]; - m_z = new double*[NUM_FUNC]; - m_zM = new double*[NUM_FUNC]; - - for (int i=0; inum_func = NUM_FUNC; - theJob->num_dim = m_dimension; - theJob->C = 2000.0; - for (int i=0; isigma[i] = m_sigma[i]; - theJob->biases[i] = m_func_biases[i]; - theJob->lambda[i] = m_lambda[i]; - } - theJob->o = m_o; - theJob->M = m_M; - theJob->w = m_w; - theJob->z = m_z; - theJob->zM = m_zM; - // Calculate/estimate the fmax for all the functions involved - for (int i=0; inum_func = NUM_FUNC; + theJob->num_dim = m_dimension; + theJob->C = 2000.0; + for (int i=0; isigma[i] = m_sigma[i]; + theJob->biases[i] = m_func_biases[i]; + theJob->lambda[i] = m_lambda[i]; + } + theJob->o = m_o; + theJob->M = m_M; + theJob->w = m_w; + theJob->z = m_z; + theJob->zM = m_zM; + // Calculate/estimate the fmax for all the functions involved + for (int i=0; ibasic_func(i, m_testPointM, m_dimension)); } - Benchmark::rotate(m_testPointM, m_testPoint, m_M[i], m_dimension); - m_fmax[i] = fabs(theJob->basic_func(i, m_testPointM, m_dimension)); - } - theJob->fmax = m_fmax; + theJob->fmax = m_fmax; } // F16RotatedHybridComposition1 @@ -118,85 +128,93 @@ F16RotatedHybridComposition1::F16RotatedHybridComposition1(int dimension, double /** * Destructor */ -F16RotatedHybridComposition1::~F16RotatedHybridComposition1() { - - for (int i=0; i #include -class F16RotatedHybridComposition1 : public TestFunc { +class F16RotatedHybridComposition1 : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; - - // Number of functions - static const int NUM_FUNC = 10; - - // Shifted global optimum - double ** m_o; - double *** m_M; - static const double m_sigma[NUM_FUNC]; - static const double m_lambda[NUM_FUNC]; - static const double m_func_biases[NUM_FUNC]; - double * m_testPoint; - double * m_testPointM; - double * m_fmax; - - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_w; - double ** m_z; - double ** m_zM; - - class MyHCJob : public HCJob { - public: - MyHCJob(int numFunc); - double basic_func(int func_no, double* x, int length); - }; - - MyHCJob * theJob; - - string getFileMxName(string prefix, int dimension, string suffix); + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; + static const string DEFAULT_FILE_MX_PREFIX; + static const string DEFAULT_FILE_MX_SUFFIX; + + // Number of functions + static const int NUM_FUNC = 10; + + // Shifted global optimum + double ** m_o; + double *** m_M; + static const double m_sigma[NUM_FUNC]; + static const double m_lambda[NUM_FUNC]; + static const double m_func_biases[NUM_FUNC]; + double * m_testPoint; + double * m_testPointM; + double * m_fmax; + + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_w; + double ** m_z; + double ** m_zM; + + class MyHCJob : public HCJob + { + public: + MyHCJob(int numFunc); + double basic_func(int func_no, double* x, int length); + }; + + MyHCJob * theJob; + + string getFileMxName(string prefix, int dimension, string suffix); public: - F16RotatedHybridComposition1(int dimension, double bias); - F16RotatedHybridComposition1(int dimension, double bias, string file_data, string file_m); - ~F16RotatedHybridComposition1(); + F16RotatedHybridComposition1(int dimension, double bias); + F16RotatedHybridComposition1(int dimension, double bias, string file_data, string file_m); + ~F16RotatedHybridComposition1(); - double f (double * x); + double f (double * x); }; // F16RotatedHybridComposition1 diff --git a/src/problems/singleObjective/cec2005Competition/F17RotatedHybridComposition1Noise.cpp b/src/problems/singleObjective/cec2005Competition/F17RotatedHybridComposition1Noise.cpp index 16fd83e..f42e604 100644 --- a/src/problems/singleObjective/cec2005Competition/F17RotatedHybridComposition1Noise.cpp +++ b/src/problems/singleObjective/cec2005Competition/F17RotatedHybridComposition1Noise.cpp @@ -29,20 +29,23 @@ const string F17RotatedHybridComposition1Noise::DEFAULT_FILE_DATA = "../../data/ const string F17RotatedHybridComposition1Noise::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func1_M_D"; const string F17RotatedHybridComposition1Noise::DEFAULT_FILE_MX_SUFFIX = ".txt"; -const double F17RotatedHybridComposition1Noise::m_sigma[NUM_FUNC] = { - 1.0, 1.0, 1.0, 1.0, 1.0, - 1.0, 1.0, 1.0, 1.0, 1.0 +const double F17RotatedHybridComposition1Noise::m_sigma[NUM_FUNC] = +{ + 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0 }; -const double F17RotatedHybridComposition1Noise::m_lambda[NUM_FUNC] = { - 1.0, 1.0, 10.0, 10.0, - 5.0/60.0, 5.0/60.0, 5.0/32.0, 5.0/32.0, - 5.0/100.0, 5.0/100.0 +const double F17RotatedHybridComposition1Noise::m_lambda[NUM_FUNC] = +{ + 1.0, 1.0, 10.0, 10.0, + 5.0/60.0, 5.0/60.0, 5.0/32.0, 5.0/32.0, + 5.0/100.0, 5.0/100.0 }; -const double F17RotatedHybridComposition1Noise::m_func_biases[NUM_FUNC] = { - 0.0, 100.0, 200.0, 300.0, 400.0, - 500.0, 600.0, 700.0, 800.0, 900.0 +const double F17RotatedHybridComposition1Noise::m_func_biases[NUM_FUNC] = +{ + 0.0, 100.0, 200.0, 300.0, 400.0, + 500.0, 600.0, 700.0, 800.0, 900.0 }; @@ -50,7 +53,8 @@ const double F17RotatedHybridComposition1Noise::m_func_biases[NUM_FUNC] = { * Constructor. */ F17RotatedHybridComposition1Noise::F17RotatedHybridComposition1Noise(int dimension, double bias) - : F17RotatedHybridComposition1Noise(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) { + : F17RotatedHybridComposition1Noise(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) +{ } // F17RotatedHybridComposition1Noise @@ -58,59 +62,65 @@ F17RotatedHybridComposition1Noise::F17RotatedHybridComposition1Noise(int dimensi * Constructor */ F17RotatedHybridComposition1Noise::F17RotatedHybridComposition1Noise(int dimension, double bias, string file_data, string file_m) - : TestFunc(dimension, bias, FUNCTION_NAME) { - - // Note: dimension starts from 0 - m_o = new double*[NUM_FUNC]; - m_M = new double**[NUM_FUNC]; - - m_testPoint = new double[m_dimension]; - m_testPointM = new double[m_dimension]; - m_fmax = new double[NUM_FUNC]; - - m_w = new double[NUM_FUNC]; - m_z = new double*[NUM_FUNC]; - m_zM = new double*[NUM_FUNC]; - - for (int i=0; inum_func = NUM_FUNC; - theJob->num_dim = m_dimension; - theJob->C = 2000.0; - for (int i=0; isigma[i] = m_sigma[i]; - theJob->biases[i] = m_func_biases[i]; - theJob->lambda[i] = m_lambda[i]; - } - theJob->o = m_o; - theJob->M = m_M; - theJob->w = m_w; - theJob->z = m_z; - theJob->zM = m_zM; - // Calculate/estimate the fmax for all the functions involved - for (int i=0; inum_func = NUM_FUNC; + theJob->num_dim = m_dimension; + theJob->C = 2000.0; + for (int i=0; isigma[i] = m_sigma[i]; + theJob->biases[i] = m_func_biases[i]; + theJob->lambda[i] = m_lambda[i]; + } + theJob->o = m_o; + theJob->M = m_M; + theJob->w = m_w; + theJob->z = m_z; + theJob->zM = m_zM; + // Calculate/estimate the fmax for all the functions involved + for (int i=0; ibasic_func(i, m_testPointM, m_dimension)); } - Benchmark::rotate(m_testPointM, m_testPoint, m_M[i], m_dimension); - m_fmax[i] = fabs(theJob->basic_func(i, m_testPointM, m_dimension)); - } - theJob->fmax = m_fmax; + theJob->fmax = m_fmax; } // F17RotatedHybridComposition1Noise @@ -118,89 +128,97 @@ F17RotatedHybridComposition1Noise::F17RotatedHybridComposition1Noise(int dimensi /** * Destructor */ -F17RotatedHybridComposition1Noise::~F17RotatedHybridComposition1Noise() { - - for (int i=0; i #include -class F17RotatedHybridComposition1Noise : public TestFunc { +class F17RotatedHybridComposition1Noise : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; - - // Number of functions - static const int NUM_FUNC = 10; - - // Shifted global optimum - double ** m_o; - double *** m_M; - static const double m_sigma[NUM_FUNC]; - static const double m_lambda[NUM_FUNC]; - static const double m_func_biases[NUM_FUNC]; - double * m_testPoint; - double * m_testPointM; - double * m_fmax; - - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_w; - double ** m_z; - double ** m_zM; - - class MyHCJob : public HCJob { - public: - MyHCJob(int numFunc); - double basic_func(int func_no, double* x, int length); - }; - - MyHCJob * theJob; - - string getFileMxName(string prefix, int dimension, string suffix); + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; + static const string DEFAULT_FILE_MX_PREFIX; + static const string DEFAULT_FILE_MX_SUFFIX; + + // Number of functions + static const int NUM_FUNC = 10; + + // Shifted global optimum + double ** m_o; + double *** m_M; + static const double m_sigma[NUM_FUNC]; + static const double m_lambda[NUM_FUNC]; + static const double m_func_biases[NUM_FUNC]; + double * m_testPoint; + double * m_testPointM; + double * m_fmax; + + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_w; + double ** m_z; + double ** m_zM; + + class MyHCJob : public HCJob + { + public: + MyHCJob(int numFunc); + double basic_func(int func_no, double* x, int length); + }; + + MyHCJob * theJob; + + string getFileMxName(string prefix, int dimension, string suffix); public: - F17RotatedHybridComposition1Noise(int dimension, double bias); - F17RotatedHybridComposition1Noise(int dimension, double bias, string file_data, string file_m); - ~F17RotatedHybridComposition1Noise(); + F17RotatedHybridComposition1Noise(int dimension, double bias); + F17RotatedHybridComposition1Noise(int dimension, double bias, string file_data, string file_m); + ~F17RotatedHybridComposition1Noise(); - double f (double * x); + double f (double * x); }; // F17RotatedHybridComposition1Noise diff --git a/src/problems/singleObjective/cec2005Competition/F18RotatedHybridComposition2.cpp b/src/problems/singleObjective/cec2005Competition/F18RotatedHybridComposition2.cpp index dbee489..994161f 100644 --- a/src/problems/singleObjective/cec2005Competition/F18RotatedHybridComposition2.cpp +++ b/src/problems/singleObjective/cec2005Competition/F18RotatedHybridComposition2.cpp @@ -29,19 +29,22 @@ const string F18RotatedHybridComposition2::DEFAULT_FILE_DATA = "../../data/cec20 const string F18RotatedHybridComposition2::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func2_M_D"; const string F18RotatedHybridComposition2::DEFAULT_FILE_MX_SUFFIX = ".txt"; -const double F18RotatedHybridComposition2::m_sigma[NUM_FUNC] = { - 1.0, 2.0, 1.5, 1.5, 1.0, 1.0, - 1.5, 1.5, 2.0, 2.0 +const double F18RotatedHybridComposition2::m_sigma[NUM_FUNC] = +{ + 1.0, 2.0, 1.5, 1.5, 1.0, 1.0, + 1.5, 1.5, 2.0, 2.0 }; -const double F18RotatedHybridComposition2::m_lambda[NUM_FUNC] = { - 2.0*5.0/32.0, 5.0/32.0, 2.0*1, 1.0, 2.0*5.0/100.0, - 5.0/100.0, 2.0*10.0, 10.0, 2.0*5.0/60.0, 5.0/60.0 +const double F18RotatedHybridComposition2::m_lambda[NUM_FUNC] = +{ + 2.0*5.0/32.0, 5.0/32.0, 2.0*1, 1.0, 2.0*5.0/100.0, + 5.0/100.0, 2.0*10.0, 10.0, 2.0*5.0/60.0, 5.0/60.0 }; -const double F18RotatedHybridComposition2::m_func_biases[NUM_FUNC] = { - 0.0, 100.0, 200.0, 300.0, 400.0, - 500.0, 600.0, 700.0, 800.0, 900.0 +const double F18RotatedHybridComposition2::m_func_biases[NUM_FUNC] = +{ + 0.0, 100.0, 200.0, 300.0, 400.0, + 500.0, 600.0, 700.0, 800.0, 900.0 }; @@ -49,7 +52,8 @@ const double F18RotatedHybridComposition2::m_func_biases[NUM_FUNC] = { * Constructor. */ F18RotatedHybridComposition2::F18RotatedHybridComposition2(int dimension, double bias) - : F18RotatedHybridComposition2(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) { + : F18RotatedHybridComposition2(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) +{ } // F18RotatedHybridComposition2 @@ -57,62 +61,69 @@ F18RotatedHybridComposition2::F18RotatedHybridComposition2(int dimension, double * Constructor */ F18RotatedHybridComposition2::F18RotatedHybridComposition2(int dimension, double bias, string file_data, string file_m) - : TestFunc(dimension, bias, FUNCTION_NAME) { - - // Note: dimension starts from 0 - m_o = new double*[NUM_FUNC]; - m_M = new double**[NUM_FUNC]; - - m_testPoint = new double[m_dimension]; - m_testPointM = new double[m_dimension]; - m_fmax = new double[NUM_FUNC]; - - m_w = new double[NUM_FUNC]; - m_z = new double*[NUM_FUNC]; - m_zM = new double*[NUM_FUNC]; - - for (int i=0; inum_func = NUM_FUNC; - theJob->num_dim = m_dimension; - theJob->C = 2000.0; - for (int i=0; isigma[i] = m_sigma[i]; - theJob->biases[i] = m_func_biases[i]; - theJob->lambda[i] = m_lambda[i]; - } - theJob->o = m_o; - theJob->M = m_M; - theJob->w = m_w; - theJob->z = m_z; - theJob->zM = m_zM; - // Calculate/estimate the fmax for all the functions involved - for (int i=0; inum_func = NUM_FUNC; + theJob->num_dim = m_dimension; + theJob->C = 2000.0; + for (int i=0; isigma[i] = m_sigma[i]; + theJob->biases[i] = m_func_biases[i]; + theJob->lambda[i] = m_lambda[i]; + } + theJob->o = m_o; + theJob->M = m_M; + theJob->w = m_w; + theJob->z = m_z; + theJob->zM = m_zM; + // Calculate/estimate the fmax for all the functions involved + for (int i=0; ibasic_func(i, m_testPointM, m_dimension)); } - Benchmark::rotate(m_testPointM, m_testPoint, m_M[i], m_dimension); - m_fmax[i] = fabs(theJob->basic_func(i, m_testPointM, m_dimension)); - } - theJob->fmax = m_fmax; + theJob->fmax = m_fmax; } // F18RotatedHybridComposition2 @@ -120,85 +131,93 @@ F18RotatedHybridComposition2::F18RotatedHybridComposition2(int dimension, double /** * Destructor */ -F18RotatedHybridComposition2::~F18RotatedHybridComposition2() { - - for (int i=0; i #include -class F18RotatedHybridComposition2 : public TestFunc { +class F18RotatedHybridComposition2 : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; - - // Number of functions - static const int NUM_FUNC = 10; - - // Shifted global optimum - double ** m_o; - double *** m_M; - static const double m_sigma[NUM_FUNC]; - static const double m_lambda[NUM_FUNC]; - static const double m_func_biases[NUM_FUNC]; - double * m_testPoint; - double * m_testPointM; - double * m_fmax; - - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_w; - double ** m_z; - double ** m_zM; - - class MyHCJob : public HCJob { - public: - MyHCJob(int numFunc); - double basic_func(int func_no, double* x, int length); - }; - - MyHCJob * theJob; - - string getFileMxName(string prefix, int dimension, string suffix); + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; + static const string DEFAULT_FILE_MX_PREFIX; + static const string DEFAULT_FILE_MX_SUFFIX; + + // Number of functions + static const int NUM_FUNC = 10; + + // Shifted global optimum + double ** m_o; + double *** m_M; + static const double m_sigma[NUM_FUNC]; + static const double m_lambda[NUM_FUNC]; + static const double m_func_biases[NUM_FUNC]; + double * m_testPoint; + double * m_testPointM; + double * m_fmax; + + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_w; + double ** m_z; + double ** m_zM; + + class MyHCJob : public HCJob + { + public: + MyHCJob(int numFunc); + double basic_func(int func_no, double* x, int length); + }; + + MyHCJob * theJob; + + string getFileMxName(string prefix, int dimension, string suffix); public: - F18RotatedHybridComposition2(int dimension, double bias); - F18RotatedHybridComposition2(int dimension, double bias, string file_data, string file_m); - ~F18RotatedHybridComposition2(); + F18RotatedHybridComposition2(int dimension, double bias); + F18RotatedHybridComposition2(int dimension, double bias, string file_data, string file_m); + ~F18RotatedHybridComposition2(); - double f (double * x); + double f (double * x); }; // F18RotatedHybridComposition2 diff --git a/src/problems/singleObjective/cec2005Competition/F19RotatedHybridComposition2NarrowBasinGlobalOpt.cpp b/src/problems/singleObjective/cec2005Competition/F19RotatedHybridComposition2NarrowBasinGlobalOpt.cpp index 2893edc..72552ad 100644 --- a/src/problems/singleObjective/cec2005Competition/F19RotatedHybridComposition2NarrowBasinGlobalOpt.cpp +++ b/src/problems/singleObjective/cec2005Competition/F19RotatedHybridComposition2NarrowBasinGlobalOpt.cpp @@ -29,19 +29,22 @@ const string F19RotatedHybridComposition2NarrowBasinGlobalOpt::DEFAULT_FILE_DATA const string F19RotatedHybridComposition2NarrowBasinGlobalOpt::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func2_M_D"; const string F19RotatedHybridComposition2NarrowBasinGlobalOpt::DEFAULT_FILE_MX_SUFFIX = ".txt"; -const double F19RotatedHybridComposition2NarrowBasinGlobalOpt::m_sigma[NUM_FUNC] = { - 1.0, 2.0, 1.5, 1.5, 1.0, 1.0, - 1.5, 1.5, 2.0, 2.0 +const double F19RotatedHybridComposition2NarrowBasinGlobalOpt::m_sigma[NUM_FUNC] = +{ + 1.0, 2.0, 1.5, 1.5, 1.0, 1.0, + 1.5, 1.5, 2.0, 2.0 }; -const double F19RotatedHybridComposition2NarrowBasinGlobalOpt::m_lambda[NUM_FUNC] = { - 2.0*5.0/32.0, 5.0/32.0, 2.0*1, 1.0, 2.0*5.0/100.0, - 5.0/100.0, 2.0*10.0, 10.0, 2.0*5.0/60.0, 5.0/60.0 +const double F19RotatedHybridComposition2NarrowBasinGlobalOpt::m_lambda[NUM_FUNC] = +{ + 2.0*5.0/32.0, 5.0/32.0, 2.0*1, 1.0, 2.0*5.0/100.0, + 5.0/100.0, 2.0*10.0, 10.0, 2.0*5.0/60.0, 5.0/60.0 }; -const double F19RotatedHybridComposition2NarrowBasinGlobalOpt::m_func_biases[NUM_FUNC] = { - 0.0, 100.0, 200.0, 300.0, 400.0, - 500.0, 600.0, 700.0, 800.0, 900.0 +const double F19RotatedHybridComposition2NarrowBasinGlobalOpt::m_func_biases[NUM_FUNC] = +{ + 0.0, 100.0, 200.0, 300.0, 400.0, + 500.0, 600.0, 700.0, 800.0, 900.0 }; @@ -49,7 +52,8 @@ const double F19RotatedHybridComposition2NarrowBasinGlobalOpt::m_func_biases[NUM * Constructor. */ F19RotatedHybridComposition2NarrowBasinGlobalOpt::F19RotatedHybridComposition2NarrowBasinGlobalOpt(int dimension, double bias) - : F19RotatedHybridComposition2NarrowBasinGlobalOpt(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) { + : F19RotatedHybridComposition2NarrowBasinGlobalOpt(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) +{ } // F19RotatedHybridComposition2NarrowBasinGlobalOpt @@ -57,62 +61,69 @@ F19RotatedHybridComposition2NarrowBasinGlobalOpt::F19RotatedHybridComposition2Na * Constructor */ F19RotatedHybridComposition2NarrowBasinGlobalOpt::F19RotatedHybridComposition2NarrowBasinGlobalOpt(int dimension, double bias, string file_data, string file_m) - : TestFunc(dimension, bias, FUNCTION_NAME) { - - // Note: dimension starts from 0 - m_o = new double*[NUM_FUNC]; - m_M = new double**[NUM_FUNC]; - - m_testPoint = new double[m_dimension]; - m_testPointM = new double[m_dimension]; - m_fmax = new double[NUM_FUNC]; - - m_w = new double[NUM_FUNC]; - m_z = new double*[NUM_FUNC]; - m_zM = new double*[NUM_FUNC]; - - for (int i=0; inum_func = NUM_FUNC; - theJob->num_dim = m_dimension; - theJob->C = 2000.0; - for (int i=0; isigma[i] = m_sigma[i]; - theJob->biases[i] = m_func_biases[i]; - theJob->lambda[i] = m_lambda[i]; - } - theJob->o = m_o; - theJob->M = m_M; - theJob->w = m_w; - theJob->z = m_z; - theJob->zM = m_zM; - // Calculate/estimate the fmax for all the functions involved - for (int i=0; inum_func = NUM_FUNC; + theJob->num_dim = m_dimension; + theJob->C = 2000.0; + for (int i=0; isigma[i] = m_sigma[i]; + theJob->biases[i] = m_func_biases[i]; + theJob->lambda[i] = m_lambda[i]; + } + theJob->o = m_o; + theJob->M = m_M; + theJob->w = m_w; + theJob->z = m_z; + theJob->zM = m_zM; + // Calculate/estimate the fmax for all the functions involved + for (int i=0; ibasic_func(i, m_testPointM, m_dimension)); } - Benchmark::rotate(m_testPointM, m_testPoint, m_M[i], m_dimension); - m_fmax[i] = fabs(theJob->basic_func(i, m_testPointM, m_dimension)); - } - theJob->fmax = m_fmax; + theJob->fmax = m_fmax; } // F19RotatedHybridComposition2NarrowBasinGlobalOpt @@ -120,85 +131,93 @@ F19RotatedHybridComposition2NarrowBasinGlobalOpt::F19RotatedHybridComposition2Na /** * Destructor */ -F19RotatedHybridComposition2NarrowBasinGlobalOpt::~F19RotatedHybridComposition2NarrowBasinGlobalOpt() { - - for (int i=0; i #include -class F19RotatedHybridComposition2NarrowBasinGlobalOpt : public TestFunc { +class F19RotatedHybridComposition2NarrowBasinGlobalOpt : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; - - // Number of functions - static const int NUM_FUNC = 10; - - // Shifted global optimum - double ** m_o; - double *** m_M; - static const double m_sigma[NUM_FUNC]; - static const double m_lambda[NUM_FUNC]; - static const double m_func_biases[NUM_FUNC]; - double * m_testPoint; - double * m_testPointM; - double * m_fmax; - - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_w; - double ** m_z; - double ** m_zM; - - class MyHCJob : public HCJob { - public: - MyHCJob(int numFunc); - double basic_func(int func_no, double* x, int length); - }; - - MyHCJob * theJob; - - string getFileMxName(string prefix, int dimension, string suffix); + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; + static const string DEFAULT_FILE_MX_PREFIX; + static const string DEFAULT_FILE_MX_SUFFIX; + + // Number of functions + static const int NUM_FUNC = 10; + + // Shifted global optimum + double ** m_o; + double *** m_M; + static const double m_sigma[NUM_FUNC]; + static const double m_lambda[NUM_FUNC]; + static const double m_func_biases[NUM_FUNC]; + double * m_testPoint; + double * m_testPointM; + double * m_fmax; + + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_w; + double ** m_z; + double ** m_zM; + + class MyHCJob : public HCJob + { + public: + MyHCJob(int numFunc); + double basic_func(int func_no, double* x, int length); + }; + + MyHCJob * theJob; + + string getFileMxName(string prefix, int dimension, string suffix); public: - F19RotatedHybridComposition2NarrowBasinGlobalOpt(int dimension, double bias); - F19RotatedHybridComposition2NarrowBasinGlobalOpt(int dimension, double bias, string file_data, string file_m); - ~F19RotatedHybridComposition2NarrowBasinGlobalOpt(); + F19RotatedHybridComposition2NarrowBasinGlobalOpt(int dimension, double bias); + F19RotatedHybridComposition2NarrowBasinGlobalOpt(int dimension, double bias, string file_data, string file_m); + ~F19RotatedHybridComposition2NarrowBasinGlobalOpt(); - double f (double * x); + double f (double * x); }; // F19RotatedHybridComposition2NarrowBasinGlobalOpt diff --git a/src/problems/singleObjective/cec2005Competition/F20RotatedHybridComposition2GlobalOptBound.cpp b/src/problems/singleObjective/cec2005Competition/F20RotatedHybridComposition2GlobalOptBound.cpp index eb34695..6df1d68 100644 --- a/src/problems/singleObjective/cec2005Competition/F20RotatedHybridComposition2GlobalOptBound.cpp +++ b/src/problems/singleObjective/cec2005Competition/F20RotatedHybridComposition2GlobalOptBound.cpp @@ -29,19 +29,22 @@ const string F20RotatedHybridComposition2GlobalOptBound::DEFAULT_FILE_DATA = ".. const string F20RotatedHybridComposition2GlobalOptBound::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func2_M_D"; const string F20RotatedHybridComposition2GlobalOptBound::DEFAULT_FILE_MX_SUFFIX = ".txt"; -const double F20RotatedHybridComposition2GlobalOptBound::m_sigma[NUM_FUNC] = { - 1.0, 2.0, 1.5, 1.5, 1.0, 1.0, - 1.5, 1.5, 2.0, 2.0 +const double F20RotatedHybridComposition2GlobalOptBound::m_sigma[NUM_FUNC] = +{ + 1.0, 2.0, 1.5, 1.5, 1.0, 1.0, + 1.5, 1.5, 2.0, 2.0 }; -const double F20RotatedHybridComposition2GlobalOptBound::m_lambda[NUM_FUNC] = { - 2.0*5.0/32.0, 5.0/32.0, 2.0*1, 1.0, 2.0*5.0/100.0, - 5.0/100.0, 2.0*10.0, 10.0, 2.0*5.0/60.0, 5.0/60.0 +const double F20RotatedHybridComposition2GlobalOptBound::m_lambda[NUM_FUNC] = +{ + 2.0*5.0/32.0, 5.0/32.0, 2.0*1, 1.0, 2.0*5.0/100.0, + 5.0/100.0, 2.0*10.0, 10.0, 2.0*5.0/60.0, 5.0/60.0 }; -const double F20RotatedHybridComposition2GlobalOptBound::m_func_biases[NUM_FUNC] = { - 0.0, 100.0, 200.0, 300.0, 400.0, - 500.0, 600.0, 700.0, 800.0, 900.0 +const double F20RotatedHybridComposition2GlobalOptBound::m_func_biases[NUM_FUNC] = +{ + 0.0, 100.0, 200.0, 300.0, 400.0, + 500.0, 600.0, 700.0, 800.0, 900.0 }; @@ -49,7 +52,8 @@ const double F20RotatedHybridComposition2GlobalOptBound::m_func_biases[NUM_FUNC] * Constructor. */ F20RotatedHybridComposition2GlobalOptBound::F20RotatedHybridComposition2GlobalOptBound(int dimension, double bias) - : F20RotatedHybridComposition2GlobalOptBound(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) { + : F20RotatedHybridComposition2GlobalOptBound(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) +{ } // F20RotatedHybridComposition2GlobalOptBound @@ -57,65 +61,73 @@ F20RotatedHybridComposition2GlobalOptBound::F20RotatedHybridComposition2GlobalOp * Constructor */ F20RotatedHybridComposition2GlobalOptBound::F20RotatedHybridComposition2GlobalOptBound(int dimension, double bias, string file_data, string file_m) - : TestFunc(dimension, bias, FUNCTION_NAME) { - - // Note: dimension starts from 0 - m_o = new double*[NUM_FUNC]; - m_M = new double**[NUM_FUNC]; - - m_testPoint = new double[m_dimension]; - m_testPointM = new double[m_dimension]; - m_fmax = new double[NUM_FUNC]; - - m_w = new double[NUM_FUNC]; - m_z = new double*[NUM_FUNC]; - m_zM = new double*[NUM_FUNC]; - - for (int i=0; inum_func = NUM_FUNC; - theJob->num_dim = m_dimension; - theJob->C = 2000.0; - for (int i=0; isigma[i] = m_sigma[i]; - theJob->biases[i] = m_func_biases[i]; - theJob->lambda[i] = m_lambda[i]; - } - theJob->o = m_o; - theJob->M = m_M; - theJob->w = m_w; - theJob->z = m_z; - theJob->zM = m_zM; - // Calculate/estimate the fmax for all the functions involved - for (int i=0; inum_func = NUM_FUNC; + theJob->num_dim = m_dimension; + theJob->C = 2000.0; + for (int i=0; isigma[i] = m_sigma[i]; + theJob->biases[i] = m_func_biases[i]; + theJob->lambda[i] = m_lambda[i]; } - Benchmark::rotate(m_testPointM, m_testPoint, m_M[i], m_dimension); - m_fmax[i] = fabs(theJob->basic_func(i, m_testPointM, m_dimension)); - } - theJob->fmax = m_fmax; + theJob->o = m_o; + theJob->M = m_M; + theJob->w = m_w; + theJob->z = m_z; + theJob->zM = m_zM; + // Calculate/estimate the fmax for all the functions involved + for (int i=0; ibasic_func(i, m_testPointM, m_dimension)); + } + theJob->fmax = m_fmax; } // F20RotatedHybridComposition2GlobalOptBound @@ -123,85 +135,93 @@ F20RotatedHybridComposition2GlobalOptBound::F20RotatedHybridComposition2GlobalOp /** * Destructor */ -F20RotatedHybridComposition2GlobalOptBound::~F20RotatedHybridComposition2GlobalOptBound() { - - for (int i=0; i #include -class F20RotatedHybridComposition2GlobalOptBound : public TestFunc { +class F20RotatedHybridComposition2GlobalOptBound : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; - - // Number of functions - static const int NUM_FUNC = 10; - - // Shifted global optimum - double ** m_o; - double *** m_M; - static const double m_sigma[NUM_FUNC]; - static const double m_lambda[NUM_FUNC]; - static const double m_func_biases[NUM_FUNC]; - double * m_testPoint; - double * m_testPointM; - double * m_fmax; - - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_w; - double ** m_z; - double ** m_zM; - - class MyHCJob : public HCJob { - public: - MyHCJob(int numFunc); - double basic_func(int func_no, double* x, int length); - }; - - MyHCJob * theJob; - - string getFileMxName(string prefix, int dimension, string suffix); + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; + static const string DEFAULT_FILE_MX_PREFIX; + static const string DEFAULT_FILE_MX_SUFFIX; + + // Number of functions + static const int NUM_FUNC = 10; + + // Shifted global optimum + double ** m_o; + double *** m_M; + static const double m_sigma[NUM_FUNC]; + static const double m_lambda[NUM_FUNC]; + static const double m_func_biases[NUM_FUNC]; + double * m_testPoint; + double * m_testPointM; + double * m_fmax; + + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_w; + double ** m_z; + double ** m_zM; + + class MyHCJob : public HCJob + { + public: + MyHCJob(int numFunc); + double basic_func(int func_no, double* x, int length); + }; + + MyHCJob * theJob; + + string getFileMxName(string prefix, int dimension, string suffix); public: - F20RotatedHybridComposition2GlobalOptBound(int dimension, double bias); - F20RotatedHybridComposition2GlobalOptBound(int dimension, double bias, string file_data, string file_m); - ~F20RotatedHybridComposition2GlobalOptBound(); + F20RotatedHybridComposition2GlobalOptBound(int dimension, double bias); + F20RotatedHybridComposition2GlobalOptBound(int dimension, double bias, string file_data, string file_m); + ~F20RotatedHybridComposition2GlobalOptBound(); - double f (double * x); + double f (double * x); }; // F20RotatedHybridComposition2GlobalOptBound diff --git a/src/problems/singleObjective/cec2005Competition/F21RotatedHybridComposition3.cpp b/src/problems/singleObjective/cec2005Competition/F21RotatedHybridComposition3.cpp index 1570ec5..513c836 100644 --- a/src/problems/singleObjective/cec2005Competition/F21RotatedHybridComposition3.cpp +++ b/src/problems/singleObjective/cec2005Competition/F21RotatedHybridComposition3.cpp @@ -29,19 +29,22 @@ const string F21RotatedHybridComposition3::DEFAULT_FILE_DATA = "../../data/cec20 const string F21RotatedHybridComposition3::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func3_M_D"; const string F21RotatedHybridComposition3::DEFAULT_FILE_MX_SUFFIX = ".txt"; -const double F21RotatedHybridComposition3::m_sigma[NUM_FUNC] = { - 1.0, 1.0, 1.0, 1.0, 1.0, - 2.0, 2.0, 2.0, 2.0, 2.0 +const double F21RotatedHybridComposition3::m_sigma[NUM_FUNC] = +{ + 1.0, 1.0, 1.0, 1.0, 1.0, + 2.0, 2.0, 2.0, 2.0, 2.0 }; -const double F21RotatedHybridComposition3::m_lambda[NUM_FUNC] = { +const double F21RotatedHybridComposition3::m_lambda[NUM_FUNC] = +{ 5.0*5.0/100.0, 5.0/100.0, 5.0*1.0, 1.0, 5.0*1.0, 1.0, 5.0*10.0, 10.0, 5.0*5.0/200.0, 5.0/200.0 }; -const double F21RotatedHybridComposition3::m_func_biases[NUM_FUNC] = { - 0.0, 100.0, 200.0, 300.0, 400.0, - 500.0, 600.0, 700.0, 800.0, 900.0 +const double F21RotatedHybridComposition3::m_func_biases[NUM_FUNC] = +{ + 0.0, 100.0, 200.0, 300.0, 400.0, + 500.0, 600.0, 700.0, 800.0, 900.0 }; @@ -49,7 +52,8 @@ const double F21RotatedHybridComposition3::m_func_biases[NUM_FUNC] = { * Constructor. */ F21RotatedHybridComposition3::F21RotatedHybridComposition3(int dimension, double bias) - : F21RotatedHybridComposition3(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) { + : F21RotatedHybridComposition3(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) +{ } // F21RotatedHybridComposition3 @@ -57,59 +61,65 @@ F21RotatedHybridComposition3::F21RotatedHybridComposition3(int dimension, double * Constructor */ F21RotatedHybridComposition3::F21RotatedHybridComposition3(int dimension, double bias, string file_data, string file_m) - : TestFunc(dimension, bias, FUNCTION_NAME) { - - // Note: dimension starts from 0 - m_o = new double*[NUM_FUNC]; - m_M = new double**[NUM_FUNC]; - - m_testPoint = new double[m_dimension]; - m_testPointM = new double[m_dimension]; - m_fmax = new double[NUM_FUNC]; - - m_w = new double[NUM_FUNC]; - m_z = new double*[NUM_FUNC]; - m_zM = new double*[NUM_FUNC]; - - for (int i=0; inum_func = NUM_FUNC; - theJob->num_dim = m_dimension; - theJob->C = 2000.0; - for (int i=0; isigma[i] = m_sigma[i]; - theJob->biases[i] = m_func_biases[i]; - theJob->lambda[i] = m_lambda[i]; - } - theJob->o = m_o; - theJob->M = m_M; - theJob->w = m_w; - theJob->z = m_z; - theJob->zM = m_zM; - // Calculate/estimate the fmax for all the functions involved - for (int i=0; inum_func = NUM_FUNC; + theJob->num_dim = m_dimension; + theJob->C = 2000.0; + for (int i=0; isigma[i] = m_sigma[i]; + theJob->biases[i] = m_func_biases[i]; + theJob->lambda[i] = m_lambda[i]; + } + theJob->o = m_o; + theJob->M = m_M; + theJob->w = m_w; + theJob->z = m_z; + theJob->zM = m_zM; + // Calculate/estimate the fmax for all the functions involved + for (int i=0; ibasic_func(i, m_testPointM, m_dimension)); } - Benchmark::rotate(m_testPointM, m_testPoint, m_M[i], m_dimension); - m_fmax[i] = fabs(theJob->basic_func(i, m_testPointM, m_dimension)); - } - theJob->fmax = m_fmax; + theJob->fmax = m_fmax; } // F21RotatedHybridComposition3 @@ -117,85 +127,93 @@ F21RotatedHybridComposition3::F21RotatedHybridComposition3(int dimension, double /** * Destructor */ -F21RotatedHybridComposition3::~F21RotatedHybridComposition3() { - - for (int i=0; i #include -class F21RotatedHybridComposition3 : public TestFunc { +class F21RotatedHybridComposition3 : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; - - // Number of functions - static const int NUM_FUNC = 10; - - // Shifted global optimum - double ** m_o; - double *** m_M; - static const double m_sigma[NUM_FUNC]; - static const double m_lambda[NUM_FUNC]; - static const double m_func_biases[NUM_FUNC]; - double * m_testPoint; - double * m_testPointM; - double * m_fmax; - - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_w; - double ** m_z; - double ** m_zM; - - class MyHCJob : public HCJob { - public: - MyHCJob(int numFunc); - double basic_func(int func_no, double* x, int length); - }; - - MyHCJob * theJob; - - string getFileMxName(string prefix, int dimension, string suffix); + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; + static const string DEFAULT_FILE_MX_PREFIX; + static const string DEFAULT_FILE_MX_SUFFIX; + + // Number of functions + static const int NUM_FUNC = 10; + + // Shifted global optimum + double ** m_o; + double *** m_M; + static const double m_sigma[NUM_FUNC]; + static const double m_lambda[NUM_FUNC]; + static const double m_func_biases[NUM_FUNC]; + double * m_testPoint; + double * m_testPointM; + double * m_fmax; + + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_w; + double ** m_z; + double ** m_zM; + + class MyHCJob : public HCJob + { + public: + MyHCJob(int numFunc); + double basic_func(int func_no, double* x, int length); + }; + + MyHCJob * theJob; + + string getFileMxName(string prefix, int dimension, string suffix); public: - F21RotatedHybridComposition3(int dimension, double bias); - F21RotatedHybridComposition3(int dimension, double bias, string file_data, string file_m); - ~F21RotatedHybridComposition3(); + F21RotatedHybridComposition3(int dimension, double bias); + F21RotatedHybridComposition3(int dimension, double bias, string file_data, string file_m); + ~F21RotatedHybridComposition3(); - double f (double * x); + double f (double * x); }; // F21RotatedHybridComposition3 diff --git a/src/problems/singleObjective/cec2005Competition/F22RotatedHybridComposition3HighCondNumMatrix.cpp b/src/problems/singleObjective/cec2005Competition/F22RotatedHybridComposition3HighCondNumMatrix.cpp index aeec872..4dd54e6 100644 --- a/src/problems/singleObjective/cec2005Competition/F22RotatedHybridComposition3HighCondNumMatrix.cpp +++ b/src/problems/singleObjective/cec2005Competition/F22RotatedHybridComposition3HighCondNumMatrix.cpp @@ -29,19 +29,22 @@ const string F22RotatedHybridComposition3HighCondNumMatrix::DEFAULT_FILE_DATA = const string F22RotatedHybridComposition3HighCondNumMatrix::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func3_HM_D"; const string F22RotatedHybridComposition3HighCondNumMatrix::DEFAULT_FILE_MX_SUFFIX = ".txt"; -const double F22RotatedHybridComposition3HighCondNumMatrix::m_sigma[NUM_FUNC] = { - 1.0, 1.0, 1.0, 1.0, 1.0, - 2.0, 2.0, 2.0, 2.0, 2.0 +const double F22RotatedHybridComposition3HighCondNumMatrix::m_sigma[NUM_FUNC] = +{ + 1.0, 1.0, 1.0, 1.0, 1.0, + 2.0, 2.0, 2.0, 2.0, 2.0 }; -const double F22RotatedHybridComposition3HighCondNumMatrix::m_lambda[NUM_FUNC] = { +const double F22RotatedHybridComposition3HighCondNumMatrix::m_lambda[NUM_FUNC] = +{ 5.0*5.0/100.0, 5.0/100.0, 5.0*1.0, 1.0, 5.0*1.0, 1.0, 5.0*10.0, 10.0, 5.0*5.0/200.0, 5.0/200.0 }; -const double F22RotatedHybridComposition3HighCondNumMatrix::m_func_biases[NUM_FUNC] = { - 0.0, 100.0, 200.0, 300.0, 400.0, - 500.0, 600.0, 700.0, 800.0, 900.0 +const double F22RotatedHybridComposition3HighCondNumMatrix::m_func_biases[NUM_FUNC] = +{ + 0.0, 100.0, 200.0, 300.0, 400.0, + 500.0, 600.0, 700.0, 800.0, 900.0 }; @@ -49,7 +52,8 @@ const double F22RotatedHybridComposition3HighCondNumMatrix::m_func_biases[NUM_FU * Constructor. */ F22RotatedHybridComposition3HighCondNumMatrix::F22RotatedHybridComposition3HighCondNumMatrix(int dimension, double bias) - : F22RotatedHybridComposition3HighCondNumMatrix(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) { + : F22RotatedHybridComposition3HighCondNumMatrix(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) +{ } // F22RotatedHybridComposition3HighCondNumMatrix @@ -57,59 +61,65 @@ F22RotatedHybridComposition3HighCondNumMatrix::F22RotatedHybridComposition3HighC * Constructor */ F22RotatedHybridComposition3HighCondNumMatrix::F22RotatedHybridComposition3HighCondNumMatrix(int dimension, double bias, string file_data, string file_m) - : TestFunc(dimension, bias, FUNCTION_NAME) { - - // Note: dimension starts from 0 - m_o = new double*[NUM_FUNC]; - m_M = new double**[NUM_FUNC]; - - m_testPoint = new double[m_dimension]; - m_testPointM = new double[m_dimension]; - m_fmax = new double[NUM_FUNC]; - - m_w = new double[NUM_FUNC]; - m_z = new double*[NUM_FUNC]; - m_zM = new double*[NUM_FUNC]; - - for (int i=0; inum_func = NUM_FUNC; - theJob->num_dim = m_dimension; - theJob->C = 2000.0; - for (int i=0; isigma[i] = m_sigma[i]; - theJob->biases[i] = m_func_biases[i]; - theJob->lambda[i] = m_lambda[i]; - } - theJob->o = m_o; - theJob->M = m_M; - theJob->w = m_w; - theJob->z = m_z; - theJob->zM = m_zM; - // Calculate/estimate the fmax for all the functions involved - for (int i=0; inum_func = NUM_FUNC; + theJob->num_dim = m_dimension; + theJob->C = 2000.0; + for (int i=0; isigma[i] = m_sigma[i]; + theJob->biases[i] = m_func_biases[i]; + theJob->lambda[i] = m_lambda[i]; + } + theJob->o = m_o; + theJob->M = m_M; + theJob->w = m_w; + theJob->z = m_z; + theJob->zM = m_zM; + // Calculate/estimate the fmax for all the functions involved + for (int i=0; ibasic_func(i, m_testPointM, m_dimension)); } - Benchmark::rotate(m_testPointM, m_testPoint, m_M[i], m_dimension); - m_fmax[i] = fabs(theJob->basic_func(i, m_testPointM, m_dimension)); - } - theJob->fmax = m_fmax; + theJob->fmax = m_fmax; } // F22RotatedHybridComposition3HighCondNumMatrix @@ -117,85 +127,93 @@ F22RotatedHybridComposition3HighCondNumMatrix::F22RotatedHybridComposition3HighC /** * Destructor */ -F22RotatedHybridComposition3HighCondNumMatrix::~F22RotatedHybridComposition3HighCondNumMatrix() { - - for (int i=0; i #include -class F22RotatedHybridComposition3HighCondNumMatrix : public TestFunc { +class F22RotatedHybridComposition3HighCondNumMatrix : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; - - // Number of functions - static const int NUM_FUNC = 10; - - // Shifted global optimum - double ** m_o; - double *** m_M; - static const double m_sigma[NUM_FUNC]; - static const double m_lambda[NUM_FUNC]; - static const double m_func_biases[NUM_FUNC]; - double * m_testPoint; - double * m_testPointM; - double * m_fmax; - - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_w; - double ** m_z; - double ** m_zM; - - class MyHCJob : public HCJob { - public: - MyHCJob(int numFunc); - double basic_func(int func_no, double* x, int length); - }; - - MyHCJob * theJob; - - string getFileMxName(string prefix, int dimension, string suffix); + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; + static const string DEFAULT_FILE_MX_PREFIX; + static const string DEFAULT_FILE_MX_SUFFIX; + + // Number of functions + static const int NUM_FUNC = 10; + + // Shifted global optimum + double ** m_o; + double *** m_M; + static const double m_sigma[NUM_FUNC]; + static const double m_lambda[NUM_FUNC]; + static const double m_func_biases[NUM_FUNC]; + double * m_testPoint; + double * m_testPointM; + double * m_fmax; + + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_w; + double ** m_z; + double ** m_zM; + + class MyHCJob : public HCJob + { + public: + MyHCJob(int numFunc); + double basic_func(int func_no, double* x, int length); + }; + + MyHCJob * theJob; + + string getFileMxName(string prefix, int dimension, string suffix); public: - F22RotatedHybridComposition3HighCondNumMatrix(int dimension, double bias); - F22RotatedHybridComposition3HighCondNumMatrix(int dimension, double bias, string file_data, string file_m); - ~F22RotatedHybridComposition3HighCondNumMatrix(); + F22RotatedHybridComposition3HighCondNumMatrix(int dimension, double bias); + F22RotatedHybridComposition3HighCondNumMatrix(int dimension, double bias, string file_data, string file_m); + ~F22RotatedHybridComposition3HighCondNumMatrix(); - double f (double * x); + double f (double * x); }; // F22RotatedHybridComposition3HighCondNumMatrix diff --git a/src/problems/singleObjective/cec2005Competition/F23NoncontinuousRotatedHybridComposition3.cpp b/src/problems/singleObjective/cec2005Competition/F23NoncontinuousRotatedHybridComposition3.cpp index fbbbcc4..bc9bffb 100644 --- a/src/problems/singleObjective/cec2005Competition/F23NoncontinuousRotatedHybridComposition3.cpp +++ b/src/problems/singleObjective/cec2005Competition/F23NoncontinuousRotatedHybridComposition3.cpp @@ -29,19 +29,22 @@ const string F23NoncontinuousRotatedHybridComposition3::DEFAULT_FILE_DATA = "../ const string F23NoncontinuousRotatedHybridComposition3::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func3_M_D"; const string F23NoncontinuousRotatedHybridComposition3::DEFAULT_FILE_MX_SUFFIX = ".txt"; -const double F23NoncontinuousRotatedHybridComposition3::m_sigma[NUM_FUNC] = { - 1.0, 1.0, 1.0, 1.0, 1.0, - 2.0, 2.0, 2.0, 2.0, 2.0 +const double F23NoncontinuousRotatedHybridComposition3::m_sigma[NUM_FUNC] = +{ + 1.0, 1.0, 1.0, 1.0, 1.0, + 2.0, 2.0, 2.0, 2.0, 2.0 }; -const double F23NoncontinuousRotatedHybridComposition3::m_lambda[NUM_FUNC] = { +const double F23NoncontinuousRotatedHybridComposition3::m_lambda[NUM_FUNC] = +{ 5.0*5.0/100.0, 5.0/100.0, 5.0*1.0, 1.0, 5.0*1.0, 1.0, 5.0*10.0, 10.0, 5.0*5.0/200.0, 5.0/200.0 }; -const double F23NoncontinuousRotatedHybridComposition3::m_func_biases[NUM_FUNC] = { - 0.0, 100.0, 200.0, 300.0, 400.0, - 500.0, 600.0, 700.0, 800.0, 900.0 +const double F23NoncontinuousRotatedHybridComposition3::m_func_biases[NUM_FUNC] = +{ + 0.0, 100.0, 200.0, 300.0, 400.0, + 500.0, 600.0, 700.0, 800.0, 900.0 }; @@ -49,7 +52,8 @@ const double F23NoncontinuousRotatedHybridComposition3::m_func_biases[NUM_FUNC] * Constructor. */ F23NoncontinuousRotatedHybridComposition3::F23NoncontinuousRotatedHybridComposition3(int dimension, double bias) - : F23NoncontinuousRotatedHybridComposition3(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) { + : F23NoncontinuousRotatedHybridComposition3(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) +{ } // F23NoncontinuousRotatedHybridComposition3 @@ -57,59 +61,65 @@ F23NoncontinuousRotatedHybridComposition3::F23NoncontinuousRotatedHybridComposit * Constructor */ F23NoncontinuousRotatedHybridComposition3::F23NoncontinuousRotatedHybridComposition3(int dimension, double bias, string file_data, string file_m) - : TestFunc(dimension, bias, FUNCTION_NAME) { - - // Note: dimension starts from 0 - m_o = new double*[NUM_FUNC]; - m_M = new double**[NUM_FUNC]; - - m_testPoint = new double[m_dimension]; - m_testPointM = new double[m_dimension]; - m_fmax = new double[NUM_FUNC]; - - m_w = new double[NUM_FUNC]; - m_z = new double*[NUM_FUNC]; - m_zM = new double*[NUM_FUNC]; - - for (int i=0; inum_func = NUM_FUNC; - theJob->num_dim = m_dimension; - theJob->C = 2000.0; - for (int i=0; isigma[i] = m_sigma[i]; - theJob->biases[i] = m_func_biases[i]; - theJob->lambda[i] = m_lambda[i]; - } - theJob->o = m_o; - theJob->M = m_M; - theJob->w = m_w; - theJob->z = m_z; - theJob->zM = m_zM; - // Calculate/estimate the fmax for all the functions involved - for (int i=0; inum_func = NUM_FUNC; + theJob->num_dim = m_dimension; + theJob->C = 2000.0; + for (int i=0; isigma[i] = m_sigma[i]; + theJob->biases[i] = m_func_biases[i]; + theJob->lambda[i] = m_lambda[i]; + } + theJob->o = m_o; + theJob->M = m_M; + theJob->w = m_w; + theJob->z = m_z; + theJob->zM = m_zM; + // Calculate/estimate the fmax for all the functions involved + for (int i=0; ibasic_func(i, m_testPointM, m_dimension)); } - Benchmark::rotate(m_testPointM, m_testPoint, m_M[i], m_dimension); - m_fmax[i] = fabs(theJob->basic_func(i, m_testPointM, m_dimension)); - } - theJob->fmax = m_fmax; + theJob->fmax = m_fmax; } // F23NoncontinuousRotatedHybridComposition3 @@ -117,89 +127,98 @@ F23NoncontinuousRotatedHybridComposition3::F23NoncontinuousRotatedHybridComposit /** * Destructor */ -F23NoncontinuousRotatedHybridComposition3::~F23NoncontinuousRotatedHybridComposition3() { - - for (int i=0; i #include -class F23NoncontinuousRotatedHybridComposition3 : public TestFunc { +class F23NoncontinuousRotatedHybridComposition3 : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; - - // Number of functions - static const int NUM_FUNC = 10; - - // Shifted global optimum - double ** m_o; - double *** m_M; - static const double m_sigma[NUM_FUNC]; - static const double m_lambda[NUM_FUNC]; - static const double m_func_biases[NUM_FUNC]; - double * m_testPoint; - double * m_testPointM; - double * m_fmax; - - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_w; - double ** m_z; - double ** m_zM; - - class MyHCJob : public HCJob { - public: - MyHCJob(int numFunc); - double basic_func(int func_no, double* x, int length); - }; - - MyHCJob * theJob; - - string getFileMxName(string prefix, int dimension, string suffix); + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; + static const string DEFAULT_FILE_MX_PREFIX; + static const string DEFAULT_FILE_MX_SUFFIX; + + // Number of functions + static const int NUM_FUNC = 10; + + // Shifted global optimum + double ** m_o; + double *** m_M; + static const double m_sigma[NUM_FUNC]; + static const double m_lambda[NUM_FUNC]; + static const double m_func_biases[NUM_FUNC]; + double * m_testPoint; + double * m_testPointM; + double * m_fmax; + + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_w; + double ** m_z; + double ** m_zM; + + class MyHCJob : public HCJob + { + public: + MyHCJob(int numFunc); + double basic_func(int func_no, double* x, int length); + }; + + MyHCJob * theJob; + + string getFileMxName(string prefix, int dimension, string suffix); public: - F23NoncontinuousRotatedHybridComposition3(int dimension, double bias); - F23NoncontinuousRotatedHybridComposition3(int dimension, double bias, string file_data, string file_m); - ~F23NoncontinuousRotatedHybridComposition3(); + F23NoncontinuousRotatedHybridComposition3(int dimension, double bias); + F23NoncontinuousRotatedHybridComposition3(int dimension, double bias, string file_data, string file_m); + ~F23NoncontinuousRotatedHybridComposition3(); - double f (double * x); + double f (double * x); }; // F23NoncontinuousRotatedHybridComposition3 diff --git a/src/problems/singleObjective/cec2005Competition/F24RotatedHybridComposition4.cpp b/src/problems/singleObjective/cec2005Competition/F24RotatedHybridComposition4.cpp index 657139e..17db3ed 100644 --- a/src/problems/singleObjective/cec2005Competition/F24RotatedHybridComposition4.cpp +++ b/src/problems/singleObjective/cec2005Competition/F24RotatedHybridComposition4.cpp @@ -29,19 +29,22 @@ const string F24RotatedHybridComposition4::DEFAULT_FILE_DATA = "../../data/cec20 const string F24RotatedHybridComposition4::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func4_M_D"; const string F24RotatedHybridComposition4::DEFAULT_FILE_MX_SUFFIX = ".txt"; -const double F24RotatedHybridComposition4::m_sigma[NUM_FUNC] = { - 2.0, 2.0, 2.0, 2.0, 2.0, - 2.0, 2.0, 2.0, 2.0, 2.0 +const double F24RotatedHybridComposition4::m_sigma[NUM_FUNC] = +{ + 2.0, 2.0, 2.0, 2.0, 2.0, + 2.0, 2.0, 2.0, 2.0, 2.0 }; -const double F24RotatedHybridComposition4::m_lambda[NUM_FUNC] = { +const double F24RotatedHybridComposition4::m_lambda[NUM_FUNC] = +{ 10.0, 5.0/20.0, 1.0, 5.0/32.0, 1.0, 5.0/100.0, 5.0/50.0, 1.0, 5.0/100.0, 5.0/100.0 }; -const double F24RotatedHybridComposition4::m_func_biases[NUM_FUNC] = { - 0.0, 100.0, 200.0, 300.0, 400.0, - 500.0, 600.0, 700.0, 800.0, 900.0 +const double F24RotatedHybridComposition4::m_func_biases[NUM_FUNC] = +{ + 0.0, 100.0, 200.0, 300.0, 400.0, + 500.0, 600.0, 700.0, 800.0, 900.0 }; @@ -49,7 +52,8 @@ const double F24RotatedHybridComposition4::m_func_biases[NUM_FUNC] = { * Constructor. */ F24RotatedHybridComposition4::F24RotatedHybridComposition4(int dimension, double bias) - : F24RotatedHybridComposition4(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) { + : F24RotatedHybridComposition4(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) +{ } // F24RotatedHybridComposition4 @@ -57,59 +61,65 @@ F24RotatedHybridComposition4::F24RotatedHybridComposition4(int dimension, double * Constructor */ F24RotatedHybridComposition4::F24RotatedHybridComposition4(int dimension, double bias, string file_data, string file_m) - : TestFunc(dimension, bias, FUNCTION_NAME) { - - // Note: dimension starts from 0 - m_o = new double*[NUM_FUNC]; - m_M = new double**[NUM_FUNC]; - - m_testPoint = new double[m_dimension]; - m_testPointM = new double[m_dimension]; - m_fmax = new double[NUM_FUNC]; - - m_w = new double[NUM_FUNC]; - m_z = new double*[NUM_FUNC]; - m_zM = new double*[NUM_FUNC]; - - for (int i=0; inum_func = NUM_FUNC; - theJob->num_dim = m_dimension; - theJob->C = 2000.0; - for (int i=0; isigma[i] = m_sigma[i]; - theJob->biases[i] = m_func_biases[i]; - theJob->lambda[i] = m_lambda[i]; - } - theJob->o = m_o; - theJob->M = m_M; - theJob->w = m_w; - theJob->z = m_z; - theJob->zM = m_zM; - // Calculate/estimate the fmax for all the functions involved - for (int i=0; inum_func = NUM_FUNC; + theJob->num_dim = m_dimension; + theJob->C = 2000.0; + for (int i=0; isigma[i] = m_sigma[i]; + theJob->biases[i] = m_func_biases[i]; + theJob->lambda[i] = m_lambda[i]; + } + theJob->o = m_o; + theJob->M = m_M; + theJob->w = m_w; + theJob->z = m_z; + theJob->zM = m_zM; + // Calculate/estimate the fmax for all the functions involved + for (int i=0; ibasic_func(i, m_testPointM, m_dimension)); } - Benchmark::rotate(m_testPointM, m_testPoint, m_M[i], m_dimension); - m_fmax[i] = fabs(theJob->basic_func(i, m_testPointM, m_dimension)); - } - theJob->fmax = m_fmax; + theJob->fmax = m_fmax; } // F24RotatedHybridComposition4 @@ -117,95 +127,103 @@ F24RotatedHybridComposition4::F24RotatedHybridComposition4(int dimension, double /** * Destructor */ -F24RotatedHybridComposition4::~F24RotatedHybridComposition4() { - - for (int i=0; i #include -class F24RotatedHybridComposition4 : public TestFunc { +class F24RotatedHybridComposition4 : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; - - // Number of functions - static const int NUM_FUNC = 10; - - // Shifted global optimum - double ** m_o; - double *** m_M; - static const double m_sigma[NUM_FUNC]; - static const double m_lambda[NUM_FUNC]; - static const double m_func_biases[NUM_FUNC]; - double * m_testPoint; - double * m_testPointM; - double * m_fmax; - - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_w; - double ** m_z; - double ** m_zM; - - class MyHCJob : public HCJob { - public: - MyHCJob(int numFunc); - double basic_func(int func_no, double* x, int length); - }; - - MyHCJob * theJob; - - string getFileMxName(string prefix, int dimension, string suffix); + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; + static const string DEFAULT_FILE_MX_PREFIX; + static const string DEFAULT_FILE_MX_SUFFIX; + + // Number of functions + static const int NUM_FUNC = 10; + + // Shifted global optimum + double ** m_o; + double *** m_M; + static const double m_sigma[NUM_FUNC]; + static const double m_lambda[NUM_FUNC]; + static const double m_func_biases[NUM_FUNC]; + double * m_testPoint; + double * m_testPointM; + double * m_fmax; + + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_w; + double ** m_z; + double ** m_zM; + + class MyHCJob : public HCJob + { + public: + MyHCJob(int numFunc); + double basic_func(int func_no, double* x, int length); + }; + + MyHCJob * theJob; + + string getFileMxName(string prefix, int dimension, string suffix); public: - F24RotatedHybridComposition4(int dimension, double bias); - F24RotatedHybridComposition4(int dimension, double bias, string file_data, string file_m); - ~F24RotatedHybridComposition4(); + F24RotatedHybridComposition4(int dimension, double bias); + F24RotatedHybridComposition4(int dimension, double bias, string file_data, string file_m); + ~F24RotatedHybridComposition4(); - double f (double * x); + double f (double * x); }; // F24RotatedHybridComposition4 diff --git a/src/problems/singleObjective/cec2005Competition/F25RotatedHybridComposition4Bound.cpp b/src/problems/singleObjective/cec2005Competition/F25RotatedHybridComposition4Bound.cpp index 9e25487..9c4dc11 100644 --- a/src/problems/singleObjective/cec2005Competition/F25RotatedHybridComposition4Bound.cpp +++ b/src/problems/singleObjective/cec2005Competition/F25RotatedHybridComposition4Bound.cpp @@ -29,19 +29,22 @@ const string F25RotatedHybridComposition4Bound::DEFAULT_FILE_DATA = "../../data/ const string F25RotatedHybridComposition4Bound::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func4_M_D"; const string F25RotatedHybridComposition4Bound::DEFAULT_FILE_MX_SUFFIX = ".txt"; -const double F25RotatedHybridComposition4Bound::m_sigma[NUM_FUNC] = { - 2.0, 2.0, 2.0, 2.0, 2.0, - 2.0, 2.0, 2.0, 2.0, 2.0 +const double F25RotatedHybridComposition4Bound::m_sigma[NUM_FUNC] = +{ + 2.0, 2.0, 2.0, 2.0, 2.0, + 2.0, 2.0, 2.0, 2.0, 2.0 }; -const double F25RotatedHybridComposition4Bound::m_lambda[NUM_FUNC] = { +const double F25RotatedHybridComposition4Bound::m_lambda[NUM_FUNC] = +{ 10.0, 5.0/20.0, 1.0, 5.0/32.0, 1.0, 5.0/100.0, 5.0/50.0, 1.0, 5.0/100.0, 5.0/100.0 }; -const double F25RotatedHybridComposition4Bound::m_func_biases[NUM_FUNC] = { - 0.0, 100.0, 200.0, 300.0, 400.0, - 500.0, 600.0, 700.0, 800.0, 900.0 +const double F25RotatedHybridComposition4Bound::m_func_biases[NUM_FUNC] = +{ + 0.0, 100.0, 200.0, 300.0, 400.0, + 500.0, 600.0, 700.0, 800.0, 900.0 }; @@ -49,7 +52,8 @@ const double F25RotatedHybridComposition4Bound::m_func_biases[NUM_FUNC] = { * Constructor. */ F25RotatedHybridComposition4Bound::F25RotatedHybridComposition4Bound(int dimension, double bias) - : F25RotatedHybridComposition4Bound(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) { + : F25RotatedHybridComposition4Bound(dimension, bias, DEFAULT_FILE_DATA, getFileMxName(DEFAULT_FILE_MX_PREFIX, dimension, DEFAULT_FILE_MX_SUFFIX)) +{ } // F25RotatedHybridComposition4Bound @@ -57,59 +61,65 @@ F25RotatedHybridComposition4Bound::F25RotatedHybridComposition4Bound(int dimensi * Constructor */ F25RotatedHybridComposition4Bound::F25RotatedHybridComposition4Bound(int dimension, double bias, string file_data, string file_m) - : TestFunc(dimension, bias, FUNCTION_NAME) { - - // Note: dimension starts from 0 - m_o = new double*[NUM_FUNC]; - m_M = new double**[NUM_FUNC]; - - m_testPoint = new double[m_dimension]; - m_testPointM = new double[m_dimension]; - m_fmax = new double[NUM_FUNC]; - - m_w = new double[NUM_FUNC]; - m_z = new double*[NUM_FUNC]; - m_zM = new double*[NUM_FUNC]; - - for (int i=0; inum_func = NUM_FUNC; - theJob->num_dim = m_dimension; - theJob->C = 2000.0; - for (int i=0; isigma[i] = m_sigma[i]; - theJob->biases[i] = m_func_biases[i]; - theJob->lambda[i] = m_lambda[i]; - } - theJob->o = m_o; - theJob->M = m_M; - theJob->w = m_w; - theJob->z = m_z; - theJob->zM = m_zM; - // Calculate/estimate the fmax for all the functions involved - for (int i=0; inum_func = NUM_FUNC; + theJob->num_dim = m_dimension; + theJob->C = 2000.0; + for (int i=0; isigma[i] = m_sigma[i]; + theJob->biases[i] = m_func_biases[i]; + theJob->lambda[i] = m_lambda[i]; + } + theJob->o = m_o; + theJob->M = m_M; + theJob->w = m_w; + theJob->z = m_z; + theJob->zM = m_zM; + // Calculate/estimate the fmax for all the functions involved + for (int i=0; ibasic_func(i, m_testPointM, m_dimension)); } - Benchmark::rotate(m_testPointM, m_testPoint, m_M[i], m_dimension); - m_fmax[i] = fabs(theJob->basic_func(i, m_testPointM, m_dimension)); - } - theJob->fmax = m_fmax; + theJob->fmax = m_fmax; } // F25RotatedHybridComposition4Bound @@ -117,95 +127,103 @@ F25RotatedHybridComposition4Bound::F25RotatedHybridComposition4Bound(int dimensi /** * Destructor */ -F25RotatedHybridComposition4Bound::~F25RotatedHybridComposition4Bound() { - - for (int i=0; i #include -class F25RotatedHybridComposition4Bound : public TestFunc { +class F25RotatedHybridComposition4Bound : public TestFunc +{ private: - // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; - - // Number of functions - static const int NUM_FUNC = 10; - - // Shifted global optimum - double ** m_o; - double *** m_M; - static const double m_sigma[NUM_FUNC]; - static const double m_lambda[NUM_FUNC]; - static const double m_func_biases[NUM_FUNC]; - double * m_testPoint; - double * m_testPointM; - double * m_fmax; - - // In order to avoid excessive memory allocation, - // a fixed memory buffer is allocated for each function object. - double * m_w; - double ** m_z; - double ** m_zM; - - class MyHCJob : public HCJob { - public: - MyHCJob(int numFunc); - double basic_func(int func_no, double* x, int length); - }; - - MyHCJob * theJob; - - string getFileMxName(string prefix, int dimension, string suffix); + // Fixed (class) parameters + static const string FUNCTION_NAME; + static const string DEFAULT_FILE_DATA; + static const string DEFAULT_FILE_MX_PREFIX; + static const string DEFAULT_FILE_MX_SUFFIX; + + // Number of functions + static const int NUM_FUNC = 10; + + // Shifted global optimum + double ** m_o; + double *** m_M; + static const double m_sigma[NUM_FUNC]; + static const double m_lambda[NUM_FUNC]; + static const double m_func_biases[NUM_FUNC]; + double * m_testPoint; + double * m_testPointM; + double * m_fmax; + + // In order to avoid excessive memory allocation, + // a fixed memory buffer is allocated for each function object. + double * m_w; + double ** m_z; + double ** m_zM; + + class MyHCJob : public HCJob + { + public: + MyHCJob(int numFunc); + double basic_func(int func_no, double* x, int length); + }; + + MyHCJob * theJob; + + string getFileMxName(string prefix, int dimension, string suffix); public: - F25RotatedHybridComposition4Bound(int dimension, double bias); - F25RotatedHybridComposition4Bound(int dimension, double bias, string file_data, string file_m); - ~F25RotatedHybridComposition4Bound(); + F25RotatedHybridComposition4Bound(int dimension, double bias); + F25RotatedHybridComposition4Bound(int dimension, double bias, string file_data, string file_m); + ~F25RotatedHybridComposition4Bound(); - double f (double * x); + double f (double * x); }; // F25RotatedHybridComposition4Bound diff --git a/src/problems/singleObjective/cec2005Competition/HCJob.cpp b/src/problems/singleObjective/cec2005Competition/HCJob.cpp index c2f3927..5045573 100644 --- a/src/problems/singleObjective/cec2005Competition/HCJob.cpp +++ b/src/problems/singleObjective/cec2005Competition/HCJob.cpp @@ -25,17 +25,19 @@ /** * Constructor. */ -HCJob::HCJob(int numFunc) { - sigma = new double[numFunc]; - biases = new double[numFunc]; - lambda = new double[numFunc]; +HCJob::HCJob(int numFunc) +{ + sigma = new double[numFunc]; + biases = new double[numFunc]; + lambda = new double[numFunc]; } // HCJob /** * Destructor */ -HCJob::~HCJob() { - delete [] sigma; - delete [] biases; - delete [] lambda; +HCJob::~HCJob() +{ + delete [] sigma; + delete [] biases; + delete [] lambda; } diff --git a/src/problems/singleObjective/cec2005Competition/HCJob.h b/src/problems/singleObjective/cec2005Competition/HCJob.h index 8442e1c..7029327 100644 --- a/src/problems/singleObjective/cec2005Competition/HCJob.h +++ b/src/problems/singleObjective/cec2005Competition/HCJob.h @@ -22,37 +22,38 @@ #ifndef __H_C_JOB__ #define __H_C_JOB__ -class HCJob { +class HCJob +{ public: - // Number of basic functions - int num_func; - // Number of dimensions - int num_dim; - - // Predefined constant - double C; - // Coverage range for each basic function - double* sigma; - // Biases for each basic function - double* biases; - // Stretch / compress each basic function - double* lambda; - // Estimated fmax - double* fmax; - // Shift global optimum for each basic function - double** o; - // Linear transformation matrix for each basic function - double*** M; - - // Working areas to avoid memory allocation operations - double* w; - double** z; - double** zM; - HCJob(int numFunc); - virtual ~HCJob(); - virtual double basic_func(int func_no, double* x, int length) = 0; + // Number of basic functions + int num_func; + // Number of dimensions + int num_dim; + + // Predefined constant + double C; + // Coverage range for each basic function + double* sigma; + // Biases for each basic function + double* biases; + // Stretch / compress each basic function + double* lambda; + // Estimated fmax + double* fmax; + // Shift global optimum for each basic function + double** o; + // Linear transformation matrix for each basic function + double*** M; + + // Working areas to avoid memory allocation operations + double* w; + double** z; + double** zM; + HCJob(int numFunc); + virtual ~HCJob(); + virtual double basic_func(int func_no, double* x, int length) = 0; }; // HCJob diff --git a/src/problems/singleObjective/cec2005Competition/TestFunc.cpp b/src/problems/singleObjective/cec2005Competition/TestFunc.cpp index e6c4a60..b3cbed0 100644 --- a/src/problems/singleObjective/cec2005Competition/TestFunc.cpp +++ b/src/problems/singleObjective/cec2005Competition/TestFunc.cpp @@ -25,32 +25,38 @@ /** * Constructor. */ -TestFunc::TestFunc(int dimension, double bias) : TestFunc(dimension, bias, "undefined") { +TestFunc::TestFunc(int dimension, double bias) : TestFunc(dimension, bias, "undefined") +{ } // TestFunc /** * Constructor */ -TestFunc::TestFunc(int dimension, double bias, string func_name) { - m_dimension = dimension; - m_bias = bias; - m_func_name = func_name; +TestFunc::TestFunc(int dimension, double bias, string func_name) +{ + m_dimension = dimension; + m_bias = bias; + m_func_name = func_name; } // TestFunc /** * Destructor */ -TestFunc::~TestFunc() { +TestFunc::~TestFunc() +{ } // ~TestFunc -int TestFunc::dimension() { - return (m_dimension); +int TestFunc::dimension() +{ + return (m_dimension); } // dimension -double TestFunc::bias() { - return (m_bias); +double TestFunc::bias() +{ + return (m_bias); } // bias -string TestFunc::name() { - return (m_func_name); +string TestFunc::name() +{ + return (m_func_name); } // name diff --git a/src/problems/singleObjective/cec2005Competition/TestFunc.h b/src/problems/singleObjective/cec2005Competition/TestFunc.h index aa9f4f2..177a5bf 100644 --- a/src/problems/singleObjective/cec2005Competition/TestFunc.h +++ b/src/problems/singleObjective/cec2005Competition/TestFunc.h @@ -26,21 +26,22 @@ using namespace std; -class TestFunc { +class TestFunc +{ protected: - int m_dimension; - double m_bias; - string m_func_name; + int m_dimension; + double m_bias; + string m_func_name; public: - TestFunc(int dimension, double bias); - TestFunc(int dimension, double bias, string func_name); - virtual ~TestFunc(); - virtual double f(double * x) = 0; - int dimension(); - double bias(); - string name(); + TestFunc(int dimension, double bias); + TestFunc(int dimension, double bias, string func_name); + virtual ~TestFunc(); + virtual double f(double * x) = 0; + int dimension(); + double bias(); + string name(); }; // TestFunc diff --git a/src/qualityIndicator/Epsilon.cpp b/src/qualityIndicator/Epsilon.cpp index 584306a..2b7b99a 100644 --- a/src/qualityIndicator/Epsilon.cpp +++ b/src/qualityIndicator/Epsilon.cpp @@ -26,16 +26,18 @@ * Constructor * Creates a new instance of a Epsilon object */ -Epsilon::Epsilon() { - utils_ = new MetricsUtil(); +Epsilon::Epsilon() +{ + utils_ = new MetricsUtil(); } // Epsilon /** * Destructor */ -Epsilon::~Epsilon() { - delete utils_; +Epsilon::~Epsilon() +{ + delete utils_; } // ~Epsilon @@ -46,85 +48,94 @@ Epsilon::~Epsilon() { * @return the value of the epsilon indicator */ double Epsilon::epsilon(vector > b, vector > a, - int dim) { - - int i, j, k; - double eps, eps_j = 0.0, eps_k=0.0, eps_temp; - - dim_ = dim; - set_params() ; - - if (method_ == 0) - eps = -std::numeric_limits::max(); - else - eps= 0; - - for (i = 0; i < a.size(); i++) { - for (j = 0; j < b.size(); j++) { - for (k = 0; k < dim_; k++) { - switch (method_) { - case 0: - if (obj_[k] == 0) - eps_temp = b[j][k] - a[i][k]; - //eps_temp = b[j * dim_ + k] - a[i * dim_ + k]; - else - eps_temp = a[i][k] - b[j][k]; - //eps_temp = a[i * dim_ + k] - b[j * dim_ + k]; - break; - default: - if ( (a[i][k] < 0 && b[j][k] > 0) || - (a[i][k] > 0 && b[j][k] < 0) || - (a[i][k] == 0 || b[j][k] == 0)) { - //if ( (a[i * dim_ + k] < 0 && b[j * dim_ + k] > 0) || - // (a[i * dim_ + k] > 0 && b[j * dim_ + k] < 0) || - // (a[i * dim_ + k] == 0 || b[j * dim_ + k] == 0)) { - cout << "error in data file" << endl; - exit(-1); + int dim) +{ + + int i, j, k; + double eps, eps_j = 0.0, eps_k=0.0, eps_temp; + + dim_ = dim; + set_params() ; + + if (method_ == 0) + eps = -std::numeric_limits::max(); + else + eps= 0; + + for (i = 0; i < a.size(); i++) + { + for (j = 0; j < b.size(); j++) + { + for (k = 0; k < dim_; k++) + { + switch (method_) + { + case 0: + if (obj_[k] == 0) + eps_temp = b[j][k] - a[i][k]; + //eps_temp = b[j * dim_ + k] - a[i * dim_ + k]; + else + eps_temp = a[i][k] - b[j][k]; + //eps_temp = a[i * dim_ + k] - b[j * dim_ + k]; + break; + default: + if ( (a[i][k] < 0 && b[j][k] > 0) || + (a[i][k] > 0 && b[j][k] < 0) || + (a[i][k] == 0 || b[j][k] == 0)) + { + //if ( (a[i * dim_ + k] < 0 && b[j * dim_ + k] > 0) || + // (a[i * dim_ + k] > 0 && b[j * dim_ + k] < 0) || + // (a[i * dim_ + k] == 0 || b[j * dim_ + k] == 0)) { + cout << "error in data file" << endl; + exit(-1); + } + if (obj_[k] == 0) + eps_temp = b[j][k] / a[i][k]; + //eps_temp = b[j * dim_ + k] / a[i * dim_ + k]; + else + eps_temp = a[i][k] / b[j][k]; + //eps_temp = a[i * dim_ + k] / b[j * dim_ + k]; + break; + } + if (k == 0) + eps_k = eps_temp; + else if (eps_k < eps_temp) + eps_k = eps_temp; } - if (obj_[k] == 0) - eps_temp = b[j][k] / a[i][k]; - //eps_temp = b[j * dim_ + k] / a[i * dim_ + k]; - else - eps_temp = a[i][k] / b[j][k]; - //eps_temp = a[i * dim_ + k] / b[j * dim_ + k]; - break; + if (j == 0) + eps_j = eps_k; + else if (eps_j > eps_k) + eps_j = eps_k; } - if (k == 0) - eps_k = eps_temp; - else if (eps_k < eps_temp) - eps_k = eps_temp; - } - if (j == 0) - eps_j = eps_k; - else if (eps_j > eps_k) - eps_j = eps_k; + if (i == 0) + eps = eps_j; + else if (eps < eps_j) + eps = eps_j; } - if (i == 0) - eps = eps_j; - else if (eps < eps_j) - eps = eps_j; - } - free_params(); - return eps; + free_params(); + return eps; } // epsilon /** * Established the params by default */ -void Epsilon::set_params() { - int i; - obj_ = new int[dim_]; - for (i = 0; i < dim_; i++) { - obj_[i] = 0; - } - method_ = 0; +void Epsilon::set_params() +{ + int i; + obj_ = new int[dim_]; + for (i = 0; i < dim_; i++) + { + obj_[i] = 0; + } + method_ = 0; } // set_params /** * Free the reserved memory for the params */ -void Epsilon::free_params() { - delete [] obj_; +void Epsilon::free_params() +{ + delete [] obj_; } // set_params diff --git a/src/qualityIndicator/Epsilon.h b/src/qualityIndicator/Epsilon.h index 63ede22..b54a673 100644 --- a/src/qualityIndicator/Epsilon.h +++ b/src/qualityIndicator/Epsilon.h @@ -34,26 +34,27 @@ * $java jmetal.qualityIndicator.Epsilon */ -class Epsilon { +class Epsilon +{ private: - int dim_; // stores the number of objectives - int * obj_; // obj_[i]=0 means objective i is to be minimized. This code always supposes - //the minimization of all the objectives - int method_; // method_ = 0 means apply additive epsilon and method_ = 1 means multiplicative - // epsilon. This code always apply additive epsilon + int dim_; // stores the number of objectives + int * obj_; // obj_[i]=0 means objective i is to be minimized. This code always supposes + //the minimization of all the objectives + int method_; // method_ = 0 means apply additive epsilon and method_ = 1 means multiplicative + // epsilon. This code always apply additive epsilon - void set_params(); - void free_params(); + void set_params(); + void free_params(); public: - MetricsUtil * utils_; // stores a reference to qualityIndicatorUtils + MetricsUtil * utils_; // stores a reference to qualityIndicatorUtils - Epsilon(); - ~Epsilon(); - double epsilon(vector > b, vector< vector > a, int dim); + Epsilon(); + ~Epsilon(); + double epsilon(vector > b, vector< vector > a, int dim); }; // Epsilon diff --git a/src/qualityIndicator/Fitness.cpp b/src/qualityIndicator/Fitness.cpp index fece2f8..6167c6b 100644 --- a/src/qualityIndicator/Fitness.cpp +++ b/src/qualityIndicator/Fitness.cpp @@ -26,16 +26,18 @@ * Constructor * Creates a new instance of a Fitness object */ -Fitness::Fitness() { - utils_ = new MetricsUtil(); +Fitness::Fitness() +{ + utils_ = new MetricsUtil(); } // Fitness /** * Destructor */ -Fitness::~Fitness() { - delete utils_; +Fitness::~Fitness() +{ + delete utils_; } // ~Fitness @@ -45,18 +47,22 @@ Fitness::~Fitness() { * @param a. Solution front * @return the value of the epsilon indicator */ -void Fitness::fitness(vector > a, string file) { - std::fstream out(file.c_str(), std::ios::out | std::ios::app); - for (int i=0; i > a, string file) +{ + std::fstream out(file.c_str(), std::ios::out | std::ios::app); + for (int i=0; i > a, string file); + Fitness(); + ~Fitness(); + void fitness(vector > a, string file); }; // Fitness diff --git a/src/qualityIndicator/GenerationalDistance.cpp b/src/qualityIndicator/GenerationalDistance.cpp index 86ed277..6bc5f89 100644 --- a/src/qualityIndicator/GenerationalDistance.cpp +++ b/src/qualityIndicator/GenerationalDistance.cpp @@ -31,16 +31,18 @@ const double GenerationalDistance::pow_ = 2.0; * Constructor. * Creates a new instance of the generational distance metric. */ -GenerationalDistance::GenerationalDistance() { - utils_ = new MetricsUtil(); +GenerationalDistance::GenerationalDistance() +{ + utils_ = new MetricsUtil(); } // GenerationalDistance /** * Destructor */ -GenerationalDistance::~GenerationalDistance() { - delete utils_; +GenerationalDistance::~GenerationalDistance() +{ + delete utils_; } // ~GenerationalDistance @@ -50,55 +52,56 @@ GenerationalDistance::~GenerationalDistance() { * @param trueParetoFront The true pareto front */ double GenerationalDistance::generationalDistance(vector< vector > front, - vector< vector > trueParetoFront, int numberOfObjectives) { - - /** - * Stores the maximum values of true pareto front. - */ - vector maximumValue; - - /** - * Stores the minimum values of the true pareto front. - */ - vector minimumValue; - - /** - * Stores the normalized front. - */ - vector< vector > normalizedFront; - - /** - * Stores the normalized true Pareto front. - */ - vector< vector > normalizedParetoFront ; - - // STEP 1. Obtain the maximum and minimum values of the Pareto front - maximumValue = utils_->getMaximumValues(trueParetoFront, numberOfObjectives); - minimumValue = utils_->getMinimumValues(trueParetoFront, numberOfObjectives); - - // STEP 2. Get the normalized front and true Pareto fronts - normalizedFront = utils_->getNormalizedFront(front, - maximumValue, - minimumValue); - normalizedParetoFront = utils_->getNormalizedFront(trueParetoFront, - maximumValue, - minimumValue); - - // STEP 3. Sum the distances between each point of the front and the - // nearest point in the true Pareto front - double sum = 0.0; - for (int i = 0; i < front.size(); i++) - sum += pow(utils_->distanceToClosedPoint(normalizedFront[i], - normalizedParetoFront), - pow_); - - - // STEP 4. Obtain the sqrt of the sum - sum = pow(sum,1.0/pow_); - - // STEP 5. Divide the sum by the maximum number of points of the front - double generationalDistance = sum / normalizedFront.size(); - - return generationalDistance; + vector< vector > trueParetoFront, int numberOfObjectives) +{ + + /** + * Stores the maximum values of true pareto front. + */ + vector maximumValue; + + /** + * Stores the minimum values of the true pareto front. + */ + vector minimumValue; + + /** + * Stores the normalized front. + */ + vector< vector > normalizedFront; + + /** + * Stores the normalized true Pareto front. + */ + vector< vector > normalizedParetoFront ; + + // STEP 1. Obtain the maximum and minimum values of the Pareto front + maximumValue = utils_->getMaximumValues(trueParetoFront, numberOfObjectives); + minimumValue = utils_->getMinimumValues(trueParetoFront, numberOfObjectives); + + // STEP 2. Get the normalized front and true Pareto fronts + normalizedFront = utils_->getNormalizedFront(front, + maximumValue, + minimumValue); + normalizedParetoFront = utils_->getNormalizedFront(trueParetoFront, + maximumValue, + minimumValue); + + // STEP 3. Sum the distances between each point of the front and the + // nearest point in the true Pareto front + double sum = 0.0; + for (int i = 0; i < front.size(); i++) + sum += pow(utils_->distanceToClosedPoint(normalizedFront[i], + normalizedParetoFront), + pow_); + + + // STEP 4. Obtain the sqrt of the sum + sum = pow(sum,1.0/pow_); + + // STEP 5. Divide the sum by the maximum number of points of the front + double generationalDistance = sum / normalizedFront.size(); + + return generationalDistance; } // generationalDistance diff --git a/src/qualityIndicator/GenerationalDistance.h b/src/qualityIndicator/GenerationalDistance.h index 91be1b0..00d1508 100644 --- a/src/qualityIndicator/GenerationalDistance.h +++ b/src/qualityIndicator/GenerationalDistance.h @@ -36,19 +36,20 @@ * Inst. Technol. (1998) */ -class GenerationalDistance { +class GenerationalDistance +{ private: - static const double pow_; + static const double pow_; public: - MetricsUtil * utils_; + MetricsUtil * utils_; - GenerationalDistance(); - ~GenerationalDistance(); - double generationalDistance(vector< vector > front, - vector< vector > trueParetoFront, int numberOfObjectives); + GenerationalDistance(); + ~GenerationalDistance(); + double generationalDistance(vector< vector > front, + vector< vector > trueParetoFront, int numberOfObjectives); }; diff --git a/src/qualityIndicator/Hypervolume.cpp b/src/qualityIndicator/Hypervolume.cpp index 42e3bc0..41dc0b0 100644 --- a/src/qualityIndicator/Hypervolume.cpp +++ b/src/qualityIndicator/Hypervolume.cpp @@ -25,16 +25,18 @@ * Constructor * Creates a new instance of Hypervolume */ -Hypervolume::Hypervolume() { - utils_ = new MetricsUtil(); +Hypervolume::Hypervolume() +{ + utils_ = new MetricsUtil(); } // Hypervolume /** * Destructor */ -Hypervolume::~Hypervolume() { - delete utils_; +Hypervolume::~Hypervolume() +{ + delete utils_; } // ~Hypervolume @@ -42,27 +44,31 @@ Hypervolume::~Hypervolume() { * returns true if 'point1' dominates 'points2' with respect to the * to the first 'noObjectives' objectives */ -bool Hypervolume::dominates(double* point1, double* point2, int noObjectives) { +bool Hypervolume::dominates(double* point1, double* point2, int noObjectives) +{ - int i; - bool betterInAnyObjective = false; + int i; + bool betterInAnyObjective = false; - for (i = 0; i < noObjectives && point1[i] >= point2[i]; i++) { - if (point1[i] > point2[i]) { - betterInAnyObjective = true; - } // if - } // for + for (i = 0; i < noObjectives && point1[i] >= point2[i]; i++) + { + if (point1[i] > point2[i]) + { + betterInAnyObjective = true; + } // if + } // for - return ((i >= noObjectives) && betterInAnyObjective); + return ((i >= noObjectives) && betterInAnyObjective); } // dominates -void Hypervolume::swap(double** front, int i, int j) { +void Hypervolume::swap(double** front, int i, int j) +{ - double* temp = front[i]; - front[i] = front[j]; - front[j] = temp; + double* temp = front[i]; + front[i] = front[j]; + front[j] = temp; } // swap @@ -74,36 +80,44 @@ void Hypervolume::swap(double** front, int i, int j) { * the nondominated points; n is returned */ int Hypervolume::filterNondominatedSet(double** front, int noPoints, - int noObjectives) { - - int i, j; - int n; - - n = noPoints; - i = 0; - - while (i < n) { - j = i + 1; - while (j < n) { - if (dominates(front[i], front[j], noObjectives)) { - /* remove point 'j' */ - n--; - swap(front, j, n); - } else if (dominates(front[j], front[i], noObjectives)) { - /* remove point 'i'; ensure that the point copied to index 'i' - is considered in the next outer loop (thus, decrement i) */ - n--; - swap(front, i, n); - i--; - break; - } else { - j++; - } + int noObjectives) +{ + + int i, j; + int n; + + n = noPoints; + i = 0; + + while (i < n) + { + j = i + 1; + while (j < n) + { + if (dominates(front[i], front[j], noObjectives)) + { + /* remove point 'j' */ + n--; + swap(front, j, n); + } + else if (dominates(front[j], front[i], noObjectives)) + { + /* remove point 'i'; ensure that the point copied to index 'i' + is considered in the next outer loop (thus, decrement i) */ + n--; + swap(front, i, n); + i--; + break; + } + else + { + j++; + } + } // while + i++; } // while - i++; - } // while - return n; + return n; } // filterNondominatedSet @@ -113,25 +127,29 @@ int Hypervolume::filterNondominatedSet(double** front, int noPoints, * points referenced in 'front[0..noPoints-1]' */ double Hypervolume::surfaceUnchangedTo(double** front, int noPoints, - int objective) { + int objective) +{ - int i; - double minValue, value; + int i; + double minValue, value; - if (noPoints < 1) { - cout << "run-time error" << endl; - exit(-1); - } + if (noPoints < 1) + { + cout << "run-time error" << endl; + exit(-1); + } - minValue = front[0][objective]; - for (i = 1; i < noPoints; i++) { - value = front[i][objective]; - if (value < minValue) { - minValue = value; + minValue = front[0][objective]; + for (i = 1; i < noPoints; i++) + { + value = front[i][objective]; + if (value < minValue) + { + minValue = value; + } } - } - - return minValue; + + return minValue; } // surfaceUnchangedTo @@ -143,59 +161,68 @@ double Hypervolume::surfaceUnchangedTo(double** front, int noPoints, * 'front[0..n-1]' contains the remaining points; 'n' is returned */ int Hypervolume::reduceNondominatedSet(double** front, int noPoints, - int objective, double threshold) { + int objective, double threshold) +{ - int n; - int i; + int n; + int i; - n = noPoints; - for (i = 0; i < n; i++) { - if (front[i][objective] <= threshold) { - n--; - swap(front, i, n); - } // if - } // for + n = noPoints; + for (i = 0; i < n; i++) + { + if (front[i][objective] <= threshold) + { + n--; + swap(front, i, n); + } // if + } // for - return n; + return n; } // ReduceNondominatedSet double Hypervolume::calculateHypervolume(double** front, int noPoints, - int noObjectives) { - - int n; - double volume, distance; - - volume = 0; - distance = 0; - n = noPoints; - while (n > 0) { - - int noNondominatedPoints; - double tempVolume, tempDistance; + int noObjectives) +{ + + int n; + double volume, distance; + + volume = 0; + distance = 0; + n = noPoints; + while (n > 0) + { + + int noNondominatedPoints; + double tempVolume, tempDistance; + + noNondominatedPoints = filterNondominatedSet(front, n, noObjectives - 1); + tempVolume = 0; + if (noObjectives < 3) + { + if (noNondominatedPoints < 1) + { + cout << "run-time error" << endl; + exit(-1); + } // if + tempVolume = front[0][0]; + } + else + { + tempVolume = calculateHypervolume(front, + noNondominatedPoints, + noObjectives - 1); + } // if + + tempDistance = surfaceUnchangedTo(front, n, noObjectives - 1); + volume += tempVolume * (tempDistance - distance); + distance = tempDistance; + n = reduceNondominatedSet(front, n, noObjectives - 1, distance); + } // while - noNondominatedPoints = filterNondominatedSet(front, n, noObjectives - 1); - tempVolume = 0; - if (noObjectives < 3) { - if (noNondominatedPoints < 1) { - cout << "run-time error" << endl; - exit(-1); - } // if - tempVolume = front[0][0]; - } else { - tempVolume = calculateHypervolume(front, - noNondominatedPoints, - noObjectives - 1); - } // if - - tempDistance = surfaceUnchangedTo(front, n, noObjectives - 1); - volume += tempVolume * (tempDistance - distance); - distance = tempDistance; - n = reduceNondominatedSet(front, n, noObjectives - 1, distance); - } // while - - return volume; + return volume; } // calculateHypervolume @@ -204,35 +231,41 @@ double Hypervolume::calculateHypervolume(double** front, int noPoints, * merge two fronts */ double** Hypervolume::mergeFronts(double** front1, int sizeFront1, - double** front2, int sizeFront2, int noObjectives) { - - int i, j; - int noPoints = sizeFront1 + sizeFront2; - double** frontPtr =0; - - /* allocate memory */ - frontPtr =new double*[noPoints]; - for (int y=0; y< noPoints; ++y) { - frontPtr[y] = new double[noObjectives]; - } - - /* copy points */ - noPoints = 0; - for (i = 0; i < sizeFront1; i++) { - for (j = 0; j < noObjectives; j++) { - frontPtr[noPoints][j] = front1[i][j]; + double** front2, int sizeFront2, int noObjectives) +{ + + int i, j; + int noPoints = sizeFront1 + sizeFront2; + double** frontPtr =0; + + /* allocate memory */ + frontPtr =new double*[noPoints]; + for (int y=0; y< noPoints; ++y) + { + frontPtr[y] = new double[noObjectives]; + } + + /* copy points */ + noPoints = 0; + for (i = 0; i < sizeFront1; i++) + { + for (j = 0; j < noObjectives; j++) + { + frontPtr[noPoints][j] = front1[i][j]; + } + noPoints++; } - noPoints++; - } - for (i = 0; i < sizeFront2; i++) { - for (j = 0; j < noObjectives; j++) { - frontPtr[noPoints][j] = front2[i][j]; + for (i = 0; i < sizeFront2; i++) + { + for (j = 0; j < noObjectives; j++) + { + frontPtr[noPoints][j] = front2[i][j]; + } + noPoints++; } - noPoints++; - } - - return frontPtr; - + + return frontPtr; + } // mergeFronts @@ -244,56 +277,60 @@ double** Hypervolume::mergeFronts(double** front1, int sizeFront1, * @param numberOfObjectives Number of objectives of the pareto front */ double Hypervolume::hypervolume(vector< vector > paretoFront, - vector< vector > paretoTrueFront, int numberOfObjectives) { - - /** - * Stores the maximum values of true pareto front. - */ - vector maximumValues; - - /** - * Stores the minimum values of the true pareto front. - */ - vector minimumValues; - - /** - * Stores the normalized front. - */ - vector< vector > normalizedFront; - - /** - * Stores the inverted front. Needed for minimization problems - */ - vector< vector > invertedFront; - - // STEP 1. Obtain the maximum and minimum values of the Pareto front - maximumValues = utils_->getMaximumValues(paretoTrueFront, numberOfObjectives); - minimumValues = utils_->getMinimumValues(paretoTrueFront, numberOfObjectives); - - // STEP 2. Get the normalized front - normalizedFront = utils_->getNormalizedFront(paretoFront, maximumValues, minimumValues); - - // STEP 3. Inverse the pareto front. This is needed because of the original - //metric by Zitzler is for maximization problems - invertedFront = utils_->invertedFront(normalizedFront); - - /*Makes a copy of invertedFront in pointer of pointer format*/ - double ** invertedFront2 = new double*[invertedFront.size()]; - for (int i = 0; i < invertedFront.size(); i++) { - invertedFront2[i] = new double[invertedFront[i].size()]; - for (int j = 0; j < invertedFront[i].size(); j++) { - invertedFront2[i][j] = invertedFront[i][j]; + vector< vector > paretoTrueFront, int numberOfObjectives) +{ + + /** + * Stores the maximum values of true pareto front. + */ + vector maximumValues; + + /** + * Stores the minimum values of the true pareto front. + */ + vector minimumValues; + + /** + * Stores the normalized front. + */ + vector< vector > normalizedFront; + + /** + * Stores the inverted front. Needed for minimization problems + */ + vector< vector > invertedFront; + + // STEP 1. Obtain the maximum and minimum values of the Pareto front + maximumValues = utils_->getMaximumValues(paretoTrueFront, numberOfObjectives); + minimumValues = utils_->getMinimumValues(paretoTrueFront, numberOfObjectives); + + // STEP 2. Get the normalized front + normalizedFront = utils_->getNormalizedFront(paretoFront, maximumValues, minimumValues); + + // STEP 3. Inverse the pareto front. This is needed because of the original + //metric by Zitzler is for maximization problems + invertedFront = utils_->invertedFront(normalizedFront); + + /*Makes a copy of invertedFront in pointer of pointer format*/ + double ** invertedFront2 = new double*[invertedFront.size()]; + for (int i = 0; i < invertedFront.size(); i++) + { + invertedFront2[i] = new double[invertedFront[i].size()]; + for (int j = 0; j < invertedFront[i].size(); j++) + { + invertedFront2[i][j] = invertedFront[i][j]; + } } - } - - // STEP4. The hypervolume (control is passed to java version of Zitzler code) - double hv=this->calculateHypervolume(invertedFront2,invertedFront.size(),numberOfObjectives); - - for( int y = 0 ; y < invertedFront.size() ; y++ ) { - delete [] invertedFront2[y] ; - } - delete [] invertedFront2; - - return hv; + + // STEP4. The hypervolume (control is passed to java version of Zitzler code) + double hv=this->calculateHypervolume(invertedFront2,invertedFront.size(),numberOfObjectives); + + for( int y = 0 ; y < invertedFront.size() ; y++ ) + { + delete [] invertedFront2[y] ; + } + delete [] invertedFront2; + + return hv; }// hypervolume diff --git a/src/qualityIndicator/Hypervolume.h b/src/qualityIndicator/Hypervolume.h index 2282dd3..6ee0b7e 100644 --- a/src/qualityIndicator/Hypervolume.h +++ b/src/qualityIndicator/Hypervolume.h @@ -38,29 +38,30 @@ using namespace std; * pp. 257-271, 1999. */ -class Hypervolume { +class Hypervolume +{ private: - bool dominates(double * point1, double * point2, int noObjectives); - void swap(double** front, int i, int j); - int filterNondominatedSet(double** front, int noPoints, int noObjectives); - double surfaceUnchangedTo(double ** front, int noPoints, int objective); - int reduceNondominatedSet(double** front, int noPoints, int objective, - double threshold); - double** mergeFronts(double** front1, int sizeFront1, double** front2, - int sizeFront2, int noObjectives); + bool dominates(double * point1, double * point2, int noObjectives); + void swap(double** front, int i, int j); + int filterNondominatedSet(double** front, int noPoints, int noObjectives); + double surfaceUnchangedTo(double ** front, int noPoints, int objective); + int reduceNondominatedSet(double** front, int noPoints, int objective, + double threshold); + double** mergeFronts(double** front1, int sizeFront1, double** front2, + int sizeFront2, int noObjectives); public: - - MetricsUtil * utils_; - Hypervolume(); - ~Hypervolume(); + MetricsUtil * utils_; - double calculateHypervolume(double** front, int noPoints, int noObjectives); - double hypervolume(vector< vector > paretoFront, - vector< vector > paretoTrueFront, int numberOfObjectives); + Hypervolume(); + ~Hypervolume(); + + double calculateHypervolume(double** front, int noPoints, int noObjectives); + double hypervolume(vector< vector > paretoFront, + vector< vector > paretoTrueFront, int numberOfObjectives); }; diff --git a/src/qualityIndicator/InvertedGenerationalDistance.cpp b/src/qualityIndicator/InvertedGenerationalDistance.cpp index 63ccc2f..12a9105 100644 --- a/src/qualityIndicator/InvertedGenerationalDistance.cpp +++ b/src/qualityIndicator/InvertedGenerationalDistance.cpp @@ -31,16 +31,18 @@ const double InvertedGenerationalDistance::pow_ = 2.0; * Constructor. * Creates a new instance of the generational distance metric. */ -InvertedGenerationalDistance::InvertedGenerationalDistance() { - utils_ = new MetricsUtil(); +InvertedGenerationalDistance::InvertedGenerationalDistance() +{ + utils_ = new MetricsUtil(); } // InvertedGenerationalDistance /** * Destructor */ -InvertedGenerationalDistance::~InvertedGenerationalDistance() { - delete utils_; +InvertedGenerationalDistance::~InvertedGenerationalDistance() +{ + delete utils_; } // ~InvertedGenerationalDistance @@ -51,55 +53,56 @@ InvertedGenerationalDistance::~InvertedGenerationalDistance() { */ double InvertedGenerationalDistance::invertedGenerationalDistance( vector< vector > front, vector< vector > trueParetoFront, - int numberOfObjectives) { - - /** - * Stores the maximum values of true pareto front. - */ - vector maximumValue; - - /** - * Stores the minimum values of the true pareto front. - */ - vector minimumValue; - - /** - * Stores the normalized front. - */ - vector< vector > normalizedFront; - - /** - * Stores the normalized true Pareto front. - */ - vector< vector > normalizedParetoFront ; - - // STEP 1. Obtain the maximum and minimum values of the Pareto front - maximumValue = utils_->getMaximumValues(trueParetoFront, numberOfObjectives); - minimumValue = utils_->getMinimumValues(trueParetoFront, numberOfObjectives); - - // STEP 2. Get the normalized front and true Pareto fronts - normalizedFront = utils_->getNormalizedFront(front, - maximumValue, - minimumValue); - normalizedParetoFront = utils_->getNormalizedFront(trueParetoFront, - maximumValue, - minimumValue); - - // STEP 3. Sum the distances between each point of the true Pareto front and - // the nearest point in the true Pareto front - double sum = 0.0; - for (int i = 0; i < normalizedParetoFront.size(); i++) - sum += pow(utils_->distanceToClosedPoint(normalizedParetoFront[i], - normalizedFront), - pow_); - - - // STEP 4. Obtain the sqrt of the sum - sum = pow(sum,1.0/pow_); - - // STEP 5. Divide the sum by the maximum number of points of the front - double generationalDistance = sum / normalizedParetoFront.size(); - - return generationalDistance; + int numberOfObjectives) +{ + + /** + * Stores the maximum values of true pareto front. + */ + vector maximumValue; + + /** + * Stores the minimum values of the true pareto front. + */ + vector minimumValue; + + /** + * Stores the normalized front. + */ + vector< vector > normalizedFront; + + /** + * Stores the normalized true Pareto front. + */ + vector< vector > normalizedParetoFront ; + + // STEP 1. Obtain the maximum and minimum values of the Pareto front + maximumValue = utils_->getMaximumValues(trueParetoFront, numberOfObjectives); + minimumValue = utils_->getMinimumValues(trueParetoFront, numberOfObjectives); + + // STEP 2. Get the normalized front and true Pareto fronts + normalizedFront = utils_->getNormalizedFront(front, + maximumValue, + minimumValue); + normalizedParetoFront = utils_->getNormalizedFront(trueParetoFront, + maximumValue, + minimumValue); + + // STEP 3. Sum the distances between each point of the true Pareto front and + // the nearest point in the true Pareto front + double sum = 0.0; + for (int i = 0; i < normalizedParetoFront.size(); i++) + sum += pow(utils_->distanceToClosedPoint(normalizedParetoFront[i], + normalizedFront), + pow_); + + + // STEP 4. Obtain the sqrt of the sum + sum = pow(sum,1.0/pow_); + + // STEP 5. Divide the sum by the maximum number of points of the front + double generationalDistance = sum / normalizedParetoFront.size(); + + return generationalDistance; } // generationalDistance diff --git a/src/qualityIndicator/InvertedGenerationalDistance.h b/src/qualityIndicator/InvertedGenerationalDistance.h index e78eb77..2bcc7d3 100644 --- a/src/qualityIndicator/InvertedGenerationalDistance.h +++ b/src/qualityIndicator/InvertedGenerationalDistance.h @@ -36,19 +36,20 @@ * Inst. Technol. (1998) */ -class InvertedGenerationalDistance { +class InvertedGenerationalDistance +{ private: - static const double pow_; + static const double pow_; public: - MetricsUtil * utils_; + MetricsUtil * utils_; - InvertedGenerationalDistance(); - ~InvertedGenerationalDistance(); - double invertedGenerationalDistance(vector< vector > front, - vector< vector > trueParetoFront, int numberOfObjectives); + InvertedGenerationalDistance(); + ~InvertedGenerationalDistance(); + double invertedGenerationalDistance(vector< vector > front, + vector< vector > trueParetoFront, int numberOfObjectives); }; diff --git a/src/qualityIndicator/QualityIndicator.cpp b/src/qualityIndicator/QualityIndicator.cpp index f19252f..bf99932 100644 --- a/src/qualityIndicator/QualityIndicator.cpp +++ b/src/qualityIndicator/QualityIndicator.cpp @@ -27,23 +27,25 @@ * @param paretoFrontFile */ QualityIndicator::QualityIndicator(Problem * problem, - string paretoFrontFile) { - problem_ = problem; - dim_ = problem_->getNumberOfObjectives(); - utilities_ = new MetricsUtil(); - trueParetoFront_ = utilities_->readNonDominatedSolutionSet(paretoFrontFile); - Hypervolume * hv = new Hypervolume(); - trueParetoFrontHypervolume_ = hv->hypervolume(trueParetoFront_->writeObjectivesToMatrix(), - trueParetoFront_->writeObjectivesToMatrix(), problem_->getNumberOfObjectives()); - delete hv; + string paretoFrontFile) +{ + problem_ = problem; + dim_ = problem_->getNumberOfObjectives(); + utilities_ = new MetricsUtil(); + trueParetoFront_ = utilities_->readNonDominatedSolutionSet(paretoFrontFile); + Hypervolume * hv = new Hypervolume(); + trueParetoFrontHypervolume_ = hv->hypervolume(trueParetoFront_->writeObjectivesToMatrix(), + trueParetoFront_->writeObjectivesToMatrix(), problem_->getNumberOfObjectives()); + delete hv; } // Constructor /** * Destructor */ -QualityIndicator::~QualityIndicator() { - delete utilities_; +QualityIndicator::~QualityIndicator() +{ + delete utilities_; } // ~QualityIndicator @@ -52,13 +54,14 @@ QualityIndicator::~QualityIndicator() { * @param solutionSet * @return The value of the hypervolume indicator */ -double QualityIndicator::getHypervolume(SolutionSet * solutionSet) { - Hypervolume * hv = new Hypervolume(); - double res = hv->hypervolume(solutionSet->writeObjectivesToMatrix(), - trueParetoFront_->writeObjectivesToMatrix(), - dim_); - delete hv; - return res; +double QualityIndicator::getHypervolume(SolutionSet * solutionSet) +{ + Hypervolume * hv = new Hypervolume(); + double res = hv->hypervolume(solutionSet->writeObjectivesToMatrix(), + trueParetoFront_->writeObjectivesToMatrix(), + dim_); + delete hv; + return res; } // getHypervolume @@ -66,8 +69,9 @@ double QualityIndicator::getHypervolume(SolutionSet * solutionSet) { * Returns the hypervolume of the true Pareto front * @return The hypervolume of the true Pareto front */ -double QualityIndicator::getTrueParetoFrontHypervolume() { - return trueParetoFrontHypervolume_ ; +double QualityIndicator::getTrueParetoFrontHypervolume() +{ + return trueParetoFrontHypervolume_ ; } // getTrueParetoFrontHypervolume @@ -76,14 +80,15 @@ double QualityIndicator::getTrueParetoFrontHypervolume() { * @param solutionSet * @return The value of the hypervolume indicator */ -double QualityIndicator::getIGD(SolutionSet * solutionSet) { - InvertedGenerationalDistance * igd = new InvertedGenerationalDistance(); - double res = igd->invertedGenerationalDistance( - solutionSet->writeObjectivesToMatrix(), - trueParetoFront_->writeObjectivesToMatrix(), - dim_); - delete igd; - return res; +double QualityIndicator::getIGD(SolutionSet * solutionSet) +{ + InvertedGenerationalDistance * igd = new InvertedGenerationalDistance(); + double res = igd->invertedGenerationalDistance( + solutionSet->writeObjectivesToMatrix(), + trueParetoFront_->writeObjectivesToMatrix(), + dim_); + delete igd; + return res; } // getIGD @@ -92,13 +97,14 @@ double QualityIndicator::getIGD(SolutionSet * solutionSet) { * @param solutionSet * @return The value of the hypervolume indicator */ -double QualityIndicator::getGD(SolutionSet * solutionSet) { - GenerationalDistance * gd = new GenerationalDistance(); - double res = gd->generationalDistance(solutionSet->writeObjectivesToMatrix(), - trueParetoFront_->writeObjectivesToMatrix(), - dim_); - delete gd; - return res; +double QualityIndicator::getGD(SolutionSet * solutionSet) +{ + GenerationalDistance * gd = new GenerationalDistance(); + double res = gd->generationalDistance(solutionSet->writeObjectivesToMatrix(), + trueParetoFront_->writeObjectivesToMatrix(), + dim_); + delete gd; + return res; } // getGD @@ -107,13 +113,14 @@ double QualityIndicator::getGD(SolutionSet * solutionSet) { * @param solutionSet * @return The value of the hypervolume indicator */ -double QualityIndicator::getSpread(SolutionSet * solutionSet) { - Spread * s = new Spread(); - double res = s->spread(solutionSet->writeObjectivesToMatrix(), - trueParetoFront_->writeObjectivesToMatrix(), - dim_); - delete s; - return res; +double QualityIndicator::getSpread(SolutionSet * solutionSet) +{ + Spread * s = new Spread(); + double res = s->spread(solutionSet->writeObjectivesToMatrix(), + trueParetoFront_->writeObjectivesToMatrix(), + dim_); + delete s; + return res; } // getSpread @@ -122,11 +129,12 @@ double QualityIndicator::getSpread(SolutionSet * solutionSet) { * @param solutionSet * @return The value of the hypervolume indicator */ -double QualityIndicator::getEpsilon(SolutionSet * solutionSet) { - Epsilon * e = new Epsilon(); - double res = e->epsilon(solutionSet->writeObjectivesToMatrix(), - trueParetoFront_->writeObjectivesToMatrix(), - dim_); - delete e; - return res; +double QualityIndicator::getEpsilon(SolutionSet * solutionSet) +{ + Epsilon * e = new Epsilon(); + double res = e->epsilon(solutionSet->writeObjectivesToMatrix(), + trueParetoFront_->writeObjectivesToMatrix(), + dim_); + delete e; + return res; } // getEpsilon diff --git a/src/qualityIndicator/QualityIndicator.h b/src/qualityIndicator/QualityIndicator.h index aa37fd4..b3c525b 100644 --- a/src/qualityIndicator/QualityIndicator.h +++ b/src/qualityIndicator/QualityIndicator.h @@ -31,24 +31,25 @@ #include #include -class QualityIndicator { +class QualityIndicator +{ private: - SolutionSet * trueParetoFront_; - double trueParetoFrontHypervolume_; - Problem * problem_; - int dim_; - MetricsUtil * utilities_; + SolutionSet * trueParetoFront_; + double trueParetoFrontHypervolume_; + Problem * problem_; + int dim_; + MetricsUtil * utilities_; public: - QualityIndicator(Problem * problem, string paretoFrontFile); - ~QualityIndicator(); - double getHypervolume(SolutionSet * solutionSet); - double getTrueParetoFrontHypervolume(); - double getIGD(SolutionSet * solutionSet); - double getGD(SolutionSet * solutionSet); - double getSpread(SolutionSet * solutionSet); - double getEpsilon(SolutionSet * solutionSet); + QualityIndicator(Problem * problem, string paretoFrontFile); + ~QualityIndicator(); + double getHypervolume(SolutionSet * solutionSet); + double getTrueParetoFrontHypervolume(); + double getIGD(SolutionSet * solutionSet); + double getGD(SolutionSet * solutionSet); + double getSpread(SolutionSet * solutionSet); + double getEpsilon(SolutionSet * solutionSet); }; diff --git a/src/qualityIndicator/Spread.cpp b/src/qualityIndicator/Spread.cpp index 4ccd35f..386b1bc 100644 --- a/src/qualityIndicator/Spread.cpp +++ b/src/qualityIndicator/Spread.cpp @@ -26,33 +26,37 @@ * Constructor * Creates a new instance of a Spread object */ -Spread::Spread() { - utils_ = new MetricsUtil(); +Spread::Spread() +{ + utils_ = new MetricsUtil(); } // Spread /** * Destructor */ -Spread::~Spread() { - delete utils_; +Spread::~Spread() +{ + delete utils_; } // ~Spread -bool Spread::compareFront(vector pointOne, vector pointTwo) { +bool Spread::compareFront(vector pointOne, vector pointTwo) +{ - int value; - bool result = false; + int value; + bool result = false; - LexicoGraphicalComparator * c = new LexicoGraphicalComparator(); - value = c->compare(&pointOne, &pointTwo); - delete c; + LexicoGraphicalComparator * c = new LexicoGraphicalComparator(); + value = c->compare(&pointOne, &pointTwo); + delete c; - if (value == -1) { - result = true; - } + if (value == -1) + { + result = true; + } - return result; + return result; } // compareFront @@ -65,74 +69,78 @@ bool Spread::compareFront(vector pointOne, vector pointTwo) { * @param numberOfObjectives The number of objectives. */ double Spread::spread(vector > front, - vector > trueParetoFront, int numberOfObjectives) { - - /** - * Stores the maximum values of true pareto front. - */ - vector maximumValue ; - - /** - * Stores the minimum values of the true pareto front. - */ - vector minimumValue ; - - /** - * Stores the normalized front. - */ - vector > normalizedFront ; - - /** - * Stores the normalized true Pareto front. - */ - vector > normalizedParetoFront ; - - // STEP 1. Obtain the maximum and minimum values of the Pareto front - maximumValue = utils_->getMaximumValues(trueParetoFront, numberOfObjectives); - minimumValue = utils_->getMinimumValues(trueParetoFront, numberOfObjectives); - - // STEP 2. Get the normalized front and true Pareto fronts - normalizedFront = utils_->getNormalizedFront(front, - maximumValue, - minimumValue); - normalizedParetoFront = utils_->getNormalizedFront(trueParetoFront, - maximumValue, - minimumValue); - - // STEP 3. Sort normalizedFront and normalizedParetoFront; - sort(normalizedFront.begin(), normalizedFront.end(), Spread::compareFront); - sort(normalizedParetoFront.begin(), normalizedParetoFront.end(), Spread::compareFront); - - int numberOfPoints = normalizedFront.size(); - // int numberOfTruePoints = normalizedParetoFront.length; - - // STEP 4. Compute df and dl (See specifications in Deb's description of - // the metric) - double df = utils_->distance(normalizedFront[0],normalizedParetoFront[0]); - double dl = utils_->distance(normalizedFront[normalizedFront.size()-1], - normalizedParetoFront[normalizedParetoFront.size()-1]); - - double mean = 0.0; - double diversitySum = df + dl; - - // STEP 5. Calculate the mean of distances between points i and (i - 1). - // (the poins are in lexicografical order) - for (int i = 0; i < (normalizedFront.size()-1); i++) { - mean += utils_->distance(normalizedFront[i],normalizedFront[i+1]); - } // for - - mean = mean / (double)(numberOfPoints - 1); - - // STEP 6. If there are more than a single point, continue computing the - // metric. In other case, return the worse value (1.0, see metric's - // description). - if (numberOfPoints > 1) { - for (int i = 0; i < (numberOfPoints -1); i++) { - diversitySum += fabs(utils_->distance(normalizedFront[i], - normalizedFront[i+1]) - mean); + vector > trueParetoFront, int numberOfObjectives) +{ + + /** + * Stores the maximum values of true pareto front. + */ + vector maximumValue ; + + /** + * Stores the minimum values of the true pareto front. + */ + vector minimumValue ; + + /** + * Stores the normalized front. + */ + vector > normalizedFront ; + + /** + * Stores the normalized true Pareto front. + */ + vector > normalizedParetoFront ; + + // STEP 1. Obtain the maximum and minimum values of the Pareto front + maximumValue = utils_->getMaximumValues(trueParetoFront, numberOfObjectives); + minimumValue = utils_->getMinimumValues(trueParetoFront, numberOfObjectives); + + // STEP 2. Get the normalized front and true Pareto fronts + normalizedFront = utils_->getNormalizedFront(front, + maximumValue, + minimumValue); + normalizedParetoFront = utils_->getNormalizedFront(trueParetoFront, + maximumValue, + minimumValue); + + // STEP 3. Sort normalizedFront and normalizedParetoFront; + sort(normalizedFront.begin(), normalizedFront.end(), Spread::compareFront); + sort(normalizedParetoFront.begin(), normalizedParetoFront.end(), Spread::compareFront); + + int numberOfPoints = normalizedFront.size(); + // int numberOfTruePoints = normalizedParetoFront.length; + + // STEP 4. Compute df and dl (See specifications in Deb's description of + // the metric) + double df = utils_->distance(normalizedFront[0],normalizedParetoFront[0]); + double dl = utils_->distance(normalizedFront[normalizedFront.size()-1], + normalizedParetoFront[normalizedParetoFront.size()-1]); + + double mean = 0.0; + double diversitySum = df + dl; + + // STEP 5. Calculate the mean of distances between points i and (i - 1). + // (the poins are in lexicografical order) + for (int i = 0; i < (normalizedFront.size()-1); i++) + { + mean += utils_->distance(normalizedFront[i],normalizedFront[i+1]); } // for - return diversitySum / (df + dl + (numberOfPoints-1)*mean); - } - else - return 1.0; + + mean = mean / (double)(numberOfPoints - 1); + + // STEP 6. If there are more than a single point, continue computing the + // metric. In other case, return the worse value (1.0, see metric's + // description). + if (numberOfPoints > 1) + { + for (int i = 0; i < (numberOfPoints -1); i++) + { + diversitySum += fabs(utils_->distance(normalizedFront[i], + normalizedFront[i+1]) - mean); + } // for + return diversitySum / (df + dl + (numberOfPoints-1)*mean); + } + else + return 1.0; } // spread diff --git a/src/qualityIndicator/Spread.h b/src/qualityIndicator/Spread.h index 598e07a..c6c0dfb 100644 --- a/src/qualityIndicator/Spread.h +++ b/src/qualityIndicator/Spread.h @@ -38,19 +38,20 @@ using namespace std; * on Evol. Computation 6 (2002) 182-197 */ -class Spread { +class Spread +{ private: - static bool compareFront(vector pointOne, vector pointTwo); + static bool compareFront(vector pointOne, vector pointTwo); public: - MetricsUtil * utils_; + MetricsUtil * utils_; - Spread(); - ~Spread(); - double spread (vector< vector > front, - vector< vector > trueParetoFront, int numberOfObjectives); + Spread(); + ~Spread(); + double spread (vector< vector > front, + vector< vector > trueParetoFront, int numberOfObjectives); }; // Spread diff --git a/src/qualityIndicator/fastHypervolume/FastHypervolume.cpp b/src/qualityIndicator/fastHypervolume/FastHypervolume.cpp index dd7a556..b0fc266 100644 --- a/src/qualityIndicator/fastHypervolume/FastHypervolume.cpp +++ b/src/qualityIndicator/fastHypervolume/FastHypervolume.cpp @@ -25,74 +25,90 @@ * Constructor * Creates a new instance of FastHypervolume */ -FastHypervolume::FastHypervolume() { - referencePoint_ = NULL; - numberOfObjectives_ = 0; +FastHypervolume::FastHypervolume() +{ + referencePoint_ = NULL; + numberOfObjectives_ = 0; } // FastHypervolume /** * Constructor * Creates a new instance of FastHypervolume */ -FastHypervolume::FastHypervolume(double offset) { - referencePoint_ = NULL; - numberOfObjectives_ = 0; - offset_ = offset; +FastHypervolume::FastHypervolume(double offset) +{ + referencePoint_ = NULL; + numberOfObjectives_ = 0; + offset_ = offset; } // FastHypervolume /** * Destructor */ -FastHypervolume::~FastHypervolume() { +FastHypervolume::~FastHypervolume() +{ } // ~FastHypervolume -double FastHypervolume::computeHypervolume(SolutionSet* solutionSet) { - double hv = 0.0; - if (solutionSet->size() == 0) { - hv = 0.0; - } else { - updateReferencePoint(solutionSet); - if (numberOfObjectives_ == 2) { - Comparator * comparator = - new ObjectiveComparator(numberOfObjectives_ - 1, true); - solutionSet->sort(comparator); - delete comparator; - hv = get2DHV(solutionSet); - } else { - /* - updateReferencePoint(solutionSet); - Front front = new Front(solutionSet.size(), numberOfObjectives_, solutionSet); - hv = new WFGHV(numberOfObjectives_, solutionSet.size(), referencePoint_).getHV(front); - */ - cerr << "Fast Hypervolume only works with two objectives for now." << endl; +double FastHypervolume::computeHypervolume(SolutionSet* solutionSet) +{ + double hv = 0.0; + if (solutionSet->size() == 0) + { + hv = 0.0; + } + else + { + updateReferencePoint(solutionSet); + if (numberOfObjectives_ == 2) + { + Comparator * comparator = + new ObjectiveComparator(numberOfObjectives_ - 1, true); + solutionSet->sort(comparator); + delete comparator; + hv = get2DHV(solutionSet); + } + else + { + /* + updateReferencePoint(solutionSet); + Front front = new Front(solutionSet.size(), numberOfObjectives_, solutionSet); + hv = new WFGHV(numberOfObjectives_, solutionSet.size(), referencePoint_).getHV(front); + */ + cerr << "Fast Hypervolume only works with two objectives for now." << endl; + } } - } - return hv; + return hv; } // computeHypervolume /** * Updates the reference point */ -void FastHypervolume::updateReferencePoint(SolutionSet * solutionSet) { - double * maxObjectives = new double[numberOfObjectives_]; - for (int i = 0; i < numberOfObjectives_; i++) { - maxObjectives[i] = 0; - } - - for (int i = 0; i < solutionSet->size(); i++) { - for (int j = 0; j < numberOfObjectives_; j++) { - if (maxObjectives[j] < solutionSet->get(i)->getObjective(j)) { - maxObjectives[j] = solutionSet->get(i)->getObjective(j); - } +void FastHypervolume::updateReferencePoint(SolutionSet * solutionSet) +{ + double * maxObjectives = new double[numberOfObjectives_]; + for (int i = 0; i < numberOfObjectives_; i++) + { + maxObjectives[i] = 0; } - } - for (int i = 0; i < referencePoint_->getNumberOfObjectives(); i++) { - referencePoint_->setObjective(i, maxObjectives[i] + offset_); - } + for (int i = 0; i < solutionSet->size(); i++) + { + for (int j = 0; j < numberOfObjectives_; j++) + { + if (maxObjectives[j] < solutionSet->get(i)->getObjective(j)) + { + maxObjectives[j] = solutionSet->get(i)->getObjective(j); + } + } + } - delete [] maxObjectives; + for (int i = 0; i < referencePoint_->getNumberOfObjectives(); i++) + { + referencePoint_->setObjective(i, maxObjectives[i] + offset_); + } + + delete [] maxObjectives; } // updateReferencePoint /** @@ -102,55 +118,64 @@ void FastHypervolume::updateReferencePoint(SolutionSet * solutionSet) { * * @return */ -double FastHypervolume::get2DHV(SolutionSet * solutionSet) { - double hv = 0.0; - if (solutionSet->size() > 0) { - hv = fabs((solutionSet->get(0)->getObjective(0) - referencePoint_->getObjective(0)) * - (solutionSet->get(0)->getObjective(1) - referencePoint_->getObjective(1))); - - for (int i = 1; i < solutionSet->size(); i++) { - double tmp = - fabs((solutionSet->get(i)->getObjective(0) - referencePoint_->getObjective(0)) * - (solutionSet->get(i)->getObjective(1) - solutionSet->get(i-1)->getObjective(1))); - hv += tmp; +double FastHypervolume::get2DHV(SolutionSet * solutionSet) +{ + double hv = 0.0; + if (solutionSet->size() > 0) + { + hv = fabs((solutionSet->get(0)->getObjective(0) - referencePoint_->getObjective(0)) * + (solutionSet->get(0)->getObjective(1) - referencePoint_->getObjective(1))); + + for (int i = 1; i < solutionSet->size(); i++) + { + double tmp = + fabs((solutionSet->get(i)->getObjective(0) - referencePoint_->getObjective(0)) * + (solutionSet->get(i)->getObjective(1) - solutionSet->get(i-1)->getObjective(1))); + hv += tmp; + } } - } - return hv; + return hv; } // get2DHV -void FastHypervolume::computeHVContributions(SolutionSet * solutionSet) { - double * contributions = new double[solutionSet->size()]; - double solutionSetHV = 0; - - numberOfObjectives_ = solutionSet->get(0)->getNumberOfObjectives(); - referencePoint_ = new Solution(numberOfObjectives_); - - solutionSetHV = computeHypervolume(solutionSet); - - for (int i = 0; i < solutionSet->size(); i++) { - Solution * currentPoint = solutionSet->get(i); - solutionSet->remove(i); - - if (numberOfObjectives_ == 2) { - //updateReferencePoint(solutionSet); - //solutionSet.sort(new ObjectiveComparator(numberOfObjectives_-1, true)); - contributions[i] = solutionSetHV - get2DHV(solutionSet); - } else { - /* - Front front = new Front(solutionSet.size(), numberOfObjectives_, solutionSet); - double hv = - new WFGHV(numberOfObjectives_, solutionSet.size(), referencePoint_).getHV(front); - contributions[i] = solutionSetHV - hv; - */ - cerr << "Fast Hypervolume only works with two objectives for now." << endl; +void FastHypervolume::computeHVContributions(SolutionSet * solutionSet) +{ + double * contributions = new double[solutionSet->size()]; + double solutionSetHV = 0; + + numberOfObjectives_ = solutionSet->get(0)->getNumberOfObjectives(); + referencePoint_ = new Solution(numberOfObjectives_); + + solutionSetHV = computeHypervolume(solutionSet); + + for (int i = 0; i < solutionSet->size(); i++) + { + Solution * currentPoint = solutionSet->get(i); + solutionSet->remove(i); + + if (numberOfObjectives_ == 2) + { + //updateReferencePoint(solutionSet); + //solutionSet.sort(new ObjectiveComparator(numberOfObjectives_-1, true)); + contributions[i] = solutionSetHV - get2DHV(solutionSet); + } + else + { + /* + Front front = new Front(solutionSet.size(), numberOfObjectives_, solutionSet); + double hv = + new WFGHV(numberOfObjectives_, solutionSet.size(), referencePoint_).getHV(front); + contributions[i] = solutionSetHV - hv; + */ + cerr << "Fast Hypervolume only works with two objectives for now." << endl; + } + solutionSet->add(i, currentPoint); } - solutionSet->add(i, currentPoint); - } - for (int i = 0; i < solutionSet->size(); i++) { - solutionSet->get(i)->setCrowdingDistance(contributions[i]); - } + for (int i = 0; i < solutionSet->size(); i++) + { + solutionSet->get(i)->setCrowdingDistance(contributions[i]); + } - delete [] contributions; - delete referencePoint_; + delete [] contributions; + delete referencePoint_; } // computeHVContributions diff --git a/src/qualityIndicator/fastHypervolume/FastHypervolume.h b/src/qualityIndicator/fastHypervolume/FastHypervolume.h index 450c737..6757c4b 100644 --- a/src/qualityIndicator/fastHypervolume/FastHypervolume.h +++ b/src/qualityIndicator/fastHypervolume/FastHypervolume.h @@ -29,29 +29,30 @@ using namespace std; -class FastHypervolume { +class FastHypervolume +{ private: - Solution * referencePoint_; - int numberOfObjectives_; - double offset_ = 20.0; + Solution * referencePoint_; + int numberOfObjectives_; + double offset_ = 20.0; - void updateReferencePoint(SolutionSet * solutionSet); - double get2DHV(SolutionSet * solutionSet); - double computeHypervolume(SolutionSet * solutionSet); + void updateReferencePoint(SolutionSet * solutionSet); + double get2DHV(SolutionSet * solutionSet); + double computeHypervolume(SolutionSet * solutionSet); - // double computeSolutionHVContribution(SolutionSet * solutionSet, - // int solutionIndex, double solutionSetHV); + // double computeSolutionHVContribution(SolutionSet * solutionSet, + // int solutionIndex, double solutionSetHV); public: - FastHypervolume(); - FastHypervolume(double offset); - ~FastHypervolume(); + FastHypervolume(); + FastHypervolume(double offset); + ~FastHypervolume(); - void computeHVContributions(SolutionSet * solutionSet); + void computeHVContributions(SolutionSet * solutionSet); }; diff --git a/src/qualityIndicator/fastHypervolume/FastHypervolumeArchive.cpp b/src/qualityIndicator/fastHypervolume/FastHypervolumeArchive.cpp index 9736220..e69439b 100644 --- a/src/qualityIndicator/fastHypervolume/FastHypervolumeArchive.cpp +++ b/src/qualityIndicator/fastHypervolume/FastHypervolumeArchive.cpp @@ -33,28 +33,31 @@ * @param numberOfObjectives The number of objectives. */ FastHypervolumeArchive::FastHypervolumeArchive(int maxSize, int numberOfObjectives) -: Archive(maxSize) { - this->maxSize = maxSize; - this->objectives = numberOfObjectives; - this->dominance = new DominanceComparator(); - this->equals = new EqualSolutions(); - this->referencePoint = new Solution(objectives) ; - for (int i = 0; i < objectives; i++) { - referencePoint->setObjective(i, std::numeric_limits::max()); - } - crowdingDistance_ = new CrowdingComparator(); + : Archive(maxSize) +{ + this->maxSize = maxSize; + this->objectives = numberOfObjectives; + this->dominance = new DominanceComparator(); + this->equals = new EqualSolutions(); + this->referencePoint = new Solution(objectives) ; + for (int i = 0; i < objectives; i++) + { + referencePoint->setObjective(i, std::numeric_limits::max()); + } + crowdingDistance_ = new CrowdingComparator(); } // FastHypervolumeArchive /** * Destructor. */ -FastHypervolumeArchive::~FastHypervolumeArchive() { - cout << "DELETING FASTHYPERVOLUMEARCHIVE" << endl; - delete dominance; - delete equals; - delete referencePoint; - delete crowdingDistance_; +FastHypervolumeArchive::~FastHypervolumeArchive() +{ + cout << "DELETING FASTHYPERVOLUMEARCHIVE" << endl; + delete dominance; + delete equals; + delete referencePoint; + delete crowdingDistance_; } // ~FastHypervolumeArchive @@ -69,53 +72,67 @@ FastHypervolumeArchive::~FastHypervolumeArchive() { * @return true if the Solution has been inserted, false * otherwise. */ -bool FastHypervolumeArchive::add(Solution *solution){ - int flag = 0; - int i = 0; - Solution *aux; //Store an solution temporally +bool FastHypervolumeArchive::add(Solution *solution) +{ + int flag = 0; + int i = 0; + Solution *aux; //Store an solution temporally - while (i < solutionsList_.size()){ - aux = solutionsList_[i]; + while (i < solutionsList_.size()) + { + aux = solutionsList_[i]; - flag = dominance->compare(solution,aux); - if (flag == 1) { // The solution to add is dominated - return false; // Discard the new solution - } else if (flag == -1) { // A solution in the archive is dominated - // Remove it from the population - delete aux; - solutionsList_.erase(solutionsList_.begin() + i); - } else { - if (equals->compare(aux,solution)==0) { - // There is an equal solution in the population - return false; // Discard the new solution - } // if - i++; + flag = dominance->compare(solution,aux); + if (flag == 1) // The solution to add is dominated + { + return false; // Discard the new solution + } + else if (flag == -1) // A solution in the archive is dominated + { + // Remove it from the population + delete aux; + solutionsList_.erase(solutionsList_.begin() + i); + } + else + { + if (equals->compare(aux,solution)==0) + { + // There is an equal solution in the population + return false; // Discard the new solution + } // if + i++; + } } - } - // Insert the solution into the archive - bool res = true; - solutionsList_.push_back(solution); - if (size() > maxSize) { // The archive is full - computeHVContribution(); - int indexWorst_ = indexWorst(crowdingDistance_); - if (solution == solutionsList_[indexWorst_]) { - res = false; - } else { - delete solutionsList_[indexWorst_]; + // Insert the solution into the archive + bool res = true; + solutionsList_.push_back(solution); + if (size() > maxSize) // The archive is full + { + computeHVContribution(); + int indexWorst_ = indexWorst(crowdingDistance_); + if (solution == solutionsList_[indexWorst_]) + { + res = false; + } + else + { + delete solutionsList_[indexWorst_]; + } + remove(indexWorst_); } - remove(indexWorst_); - } - return res; + return res; } // add /** * This method forces to compute the contribution of each solution */ -void FastHypervolumeArchive::computeHVContribution() { - if (size() > 2) { // The contribution can be updated - FastHypervolume *fastHV = new FastHypervolume(); - fastHV->computeHVContributions(this); - delete fastHV; - } +void FastHypervolumeArchive::computeHVContribution() +{ + if (size() > 2) // The contribution can be updated + { + FastHypervolume *fastHV = new FastHypervolume(); + fastHV->computeHVContributions(this); + delete fastHV; + } } // computeHVContribution diff --git a/src/qualityIndicator/fastHypervolume/FastHypervolumeArchive.h b/src/qualityIndicator/fastHypervolume/FastHypervolumeArchive.h index cecf16d..b2b98ff 100644 --- a/src/qualityIndicator/fastHypervolume/FastHypervolumeArchive.h +++ b/src/qualityIndicator/fastHypervolume/FastHypervolumeArchive.h @@ -32,66 +32,67 @@ /** * This class implements a bounded archive based on the hypervolume quality indicator */ -class FastHypervolumeArchive : public Archive { +class FastHypervolumeArchive : public Archive +{ private: - /** - * Stores the maximum size of the archive. - */ - int maxSize; + /** + * Stores the maximum size of the archive. + */ + int maxSize; - /** - * stores the number of the objectives. - */ - int objectives; + /** + * stores the number of the objectives. + */ + int objectives; - /** - * Stores a Comparator for dominance checking. - */ - Comparator *dominance; + /** + * Stores a Comparator for dominance checking. + */ + Comparator *dominance; - /** - * Stores a Comparator for equality checking (in the objective - * space). - */ - Comparator *equals; + /** + * Stores a Comparator for equality checking (in the objective + * space). + */ + Comparator *equals; - Comparator *crowdingDistance_; + Comparator *crowdingDistance_; - Solution *referencePoint; + Solution *referencePoint; public: - /** - * Constructor. - * @param maxSize The maximum size of the archive. - * @param numberOfObjectives The number of objectives. - */ - FastHypervolumeArchive(int maxSize, int numberOfObjectives); - - /** - * Destructor. - */ - ~FastHypervolumeArchive(); - - /** - * Adds a Solution to the archive. If the Solution - * is dominated by any member of the archive, then it is discarded. If the - * Solution dominates some members of the archive, these are - * removed. If the archive is full and the Solution has to be - * inserted, the solution contributing the least to the HV of the solution set - * is discarded. - * @param solution The Solution - * @return true if the Solution has been inserted, false - * otherwise. - */ - bool add(Solution *solution); - - /** - * This method forces to compute the contribution of each solution - */ - void computeHVContribution(); + /** + * Constructor. + * @param maxSize The maximum size of the archive. + * @param numberOfObjectives The number of objectives. + */ + FastHypervolumeArchive(int maxSize, int numberOfObjectives); + + /** + * Destructor. + */ + ~FastHypervolumeArchive(); + + /** + * Adds a Solution to the archive. If the Solution + * is dominated by any member of the archive, then it is discarded. If the + * Solution dominates some members of the archive, these are + * removed. If the archive is full and the Solution has to be + * inserted, the solution contributing the least to the HV of the solution set + * is discarded. + * @param solution The Solution + * @return true if the Solution has been inserted, false + * otherwise. + */ + bool add(Solution *solution); + + /** + * This method forces to compute the contribution of each solution + */ + void computeHVContribution(); }; diff --git a/src/qualityIndicator/main/Epsilon_main.cpp b/src/qualityIndicator/main/Epsilon_main.cpp index 6ff8fbc..99264ab 100644 --- a/src/qualityIndicator/main/Epsilon_main.cpp +++ b/src/qualityIndicator/main/Epsilon_main.cpp @@ -31,26 +31,28 @@ using namespace std; * 2) the name of the file containing the true Pareto front * 3) the number of objectives */ -int main(int argc, char ** argv) { - if (argc < 4) { - cerr << "Error using delta. Type: \n Epsilon " << - " " << endl; - exit(-1); - } - - //Create a new instance of the metric - Epsilon * qualityIndicator = new Epsilon(); - //Read the front from the files - vector< vector > solutionFront = - qualityIndicator->utils_->readFront(argv[1]); - vector< vector > trueFront = - qualityIndicator->utils_->readFront(argv[2]); - - //Obtain delta value - double value = qualityIndicator->epsilon(solutionFront, - trueFront, atoi(argv[3])); - - delete qualityIndicator; - - cout << value << endl; +int main(int argc, char ** argv) +{ + if (argc < 4) + { + cerr << "Error using delta. Type: \n Epsilon " << + " " << endl; + exit(-1); + } + + //Create a new instance of the metric + Epsilon * qualityIndicator = new Epsilon(); + //Read the front from the files + vector< vector > solutionFront = + qualityIndicator->utils_->readFront(argv[1]); + vector< vector > trueFront = + qualityIndicator->utils_->readFront(argv[2]); + + //Obtain delta value + double value = qualityIndicator->epsilon(solutionFront, + trueFront, atoi(argv[3])); + + delete qualityIndicator; + + cout << value << endl; } // main diff --git a/src/qualityIndicator/main/GenerationalDistance_main.cpp b/src/qualityIndicator/main/GenerationalDistance_main.cpp index 6707d1b..cb33d19 100644 --- a/src/qualityIndicator/main/GenerationalDistance_main.cpp +++ b/src/qualityIndicator/main/GenerationalDistance_main.cpp @@ -31,26 +31,28 @@ using namespace std; * 2) the name of the file containing the true Pareto front * 3) the number of objectives */ -int main(int argc, char ** argv) { - if (argc < 4) { - cerr << "Error using delta. Type: \n GenerationalDistance " << - " " << endl; - exit(-1); - } - - //Create a new instance of the metric - GenerationalDistance * qualityIndicator = new GenerationalDistance(); - //Read the front from the files - vector< vector > solutionFront = - qualityIndicator->utils_->readFront(argv[1]); - vector< vector > trueFront = - qualityIndicator->utils_->readFront(argv[2]); - - //Obtain delta value - double value = qualityIndicator->generationalDistance(solutionFront, - trueFront, atoi(argv[3])); - - delete qualityIndicator; - - cout << value << endl; +int main(int argc, char ** argv) +{ + if (argc < 4) + { + cerr << "Error using delta. Type: \n GenerationalDistance " << + " " << endl; + exit(-1); + } + + //Create a new instance of the metric + GenerationalDistance * qualityIndicator = new GenerationalDistance(); + //Read the front from the files + vector< vector > solutionFront = + qualityIndicator->utils_->readFront(argv[1]); + vector< vector > trueFront = + qualityIndicator->utils_->readFront(argv[2]); + + //Obtain delta value + double value = qualityIndicator->generationalDistance(solutionFront, + trueFront, atoi(argv[3])); + + delete qualityIndicator; + + cout << value << endl; } // main diff --git a/src/qualityIndicator/main/Hypervolume_main.cpp b/src/qualityIndicator/main/Hypervolume_main.cpp index cb43f60..b5a2059 100644 --- a/src/qualityIndicator/main/Hypervolume_main.cpp +++ b/src/qualityIndicator/main/Hypervolume_main.cpp @@ -31,26 +31,28 @@ using namespace std; * 2) the name of the file containing the true Pareto front * 3) the number of objectives */ -int main(int argc, char ** argv) { - if (argc < 4) { - cerr << "Error using delta. Type: \n Hypervolume " << - " " << endl; - exit(-1); - } - - //Create a new instance of the metric - Hypervolume * qualityIndicator = new Hypervolume(); - //Read the front from the files - vector< vector > solutionFront = - qualityIndicator->utils_->readFront(argv[1]); - vector< vector > trueFront = - qualityIndicator->utils_->readFront(argv[2]); - - //Obtain delta value - double value = qualityIndicator->hypervolume(solutionFront, - trueFront, atoi(argv[3])); - - delete qualityIndicator; - - cout << value << endl; +int main(int argc, char ** argv) +{ + if (argc < 4) + { + cerr << "Error using delta. Type: \n Hypervolume " << + " " << endl; + exit(-1); + } + + //Create a new instance of the metric + Hypervolume * qualityIndicator = new Hypervolume(); + //Read the front from the files + vector< vector > solutionFront = + qualityIndicator->utils_->readFront(argv[1]); + vector< vector > trueFront = + qualityIndicator->utils_->readFront(argv[2]); + + //Obtain delta value + double value = qualityIndicator->hypervolume(solutionFront, + trueFront, atoi(argv[3])); + + delete qualityIndicator; + + cout << value << endl; } // main diff --git a/src/qualityIndicator/main/InvertedGenerationalDistance_main.cpp b/src/qualityIndicator/main/InvertedGenerationalDistance_main.cpp index 489d418..1a70404 100644 --- a/src/qualityIndicator/main/InvertedGenerationalDistance_main.cpp +++ b/src/qualityIndicator/main/InvertedGenerationalDistance_main.cpp @@ -31,27 +31,29 @@ using namespace std; * 2) the name of the file containing the true Pareto front * 3) the number of objectives */ -int main(int argc, char ** argv) { - if (argc < 4) { - cerr << "Error using delta. Type: \n InvertedGenerationalDistance " << - " " << endl; - exit(-1); - } - - //Create a new instance of the metric - InvertedGenerationalDistance * qualityIndicator = - new InvertedGenerationalDistance(); - //Read the front from the files - vector< vector > solutionFront = - qualityIndicator->utils_->readFront(argv[1]); - vector< vector > trueFront = - qualityIndicator->utils_->readFront(argv[2]); - - //Obtain delta value - double value = qualityIndicator->invertedGenerationalDistance( - solutionFront, trueFront, atoi(argv[3])); - - delete qualityIndicator; - - cout << value << endl; +int main(int argc, char ** argv) +{ + if (argc < 4) + { + cerr << "Error using delta. Type: \n InvertedGenerationalDistance " << + " " << endl; + exit(-1); + } + + //Create a new instance of the metric + InvertedGenerationalDistance * qualityIndicator = + new InvertedGenerationalDistance(); + //Read the front from the files + vector< vector > solutionFront = + qualityIndicator->utils_->readFront(argv[1]); + vector< vector > trueFront = + qualityIndicator->utils_->readFront(argv[2]); + + //Obtain delta value + double value = qualityIndicator->invertedGenerationalDistance( + solutionFront, trueFront, atoi(argv[3])); + + delete qualityIndicator; + + cout << value << endl; } // main diff --git a/src/qualityIndicator/main/Spread_main.cpp b/src/qualityIndicator/main/Spread_main.cpp index eb53a0a..e40da82 100644 --- a/src/qualityIndicator/main/Spread_main.cpp +++ b/src/qualityIndicator/main/Spread_main.cpp @@ -31,26 +31,28 @@ using namespace std; * 2) the name of the file containing the true Pareto front * 3) the number of objectives */ -int main(int argc, char ** argv) { - if (argc < 4) { - cerr << "Error using delta. Type: \n Spread " << - " " << endl; - exit(-1); - } - - //Create a new instance of the metric - Spread * qualityIndicator = new Spread(); - //Read the front from the files - vector< vector > solutionFront = - qualityIndicator->utils_->readFront(argv[1]); - vector< vector > trueFront = - qualityIndicator->utils_->readFront(argv[2]); - - //Obtain delta value - double value = qualityIndicator->spread(solutionFront, trueFront, - atoi(argv[3])); - - delete qualityIndicator; - - cout << value << endl; +int main(int argc, char ** argv) +{ + if (argc < 4) + { + cerr << "Error using delta. Type: \n Spread " << + " " << endl; + exit(-1); + } + + //Create a new instance of the metric + Spread * qualityIndicator = new Spread(); + //Read the front from the files + vector< vector > solutionFront = + qualityIndicator->utils_->readFront(argv[1]); + vector< vector > trueFront = + qualityIndicator->utils_->readFront(argv[2]); + + //Obtain delta value + double value = qualityIndicator->spread(solutionFront, trueFront, + atoi(argv[3])); + + delete qualityIndicator; + + cout << value << endl; } // main diff --git a/src/qualityIndicator/util/LexicoGraphicalComparator.cpp b/src/qualityIndicator/util/LexicoGraphicalComparator.cpp index a5279d1..4694e07 100644 --- a/src/qualityIndicator/util/LexicoGraphicalComparator.cpp +++ b/src/qualityIndicator/util/LexicoGraphicalComparator.cpp @@ -28,23 +28,30 @@ * @param o2 An object that reference a double[] * @return -1 if o1 < o1, 1 if o1 > o2 or 0 in other case. */ -int LexicoGraphicalComparator::compare(void * o1, void * o2) { - //Cast to vector o1 and o2. - vector pointOne = * (vector *) o1; - vector pointTwo = * (vector *) o2; +int LexicoGraphicalComparator::compare(void * o1, void * o2) +{ + //Cast to vector o1 and o2. + vector pointOne = * (vector *) o1; + vector pointTwo = * (vector *) o2; - //To determine the first i, that pointOne[i] != pointTwo[i]; - int index = 0; - while ((index < pointOne.size()) && (index < pointTwo.size()) && - pointOne[index] == pointTwo[index]) { - index++; - } - if ((index >= pointOne.size()) || (index >= pointTwo.size() )) { + //To determine the first i, that pointOne[i] != pointTwo[i]; + int index = 0; + while ((index < pointOne.size()) && (index < pointTwo.size()) && + pointOne[index] == pointTwo[index]) + { + index++; + } + if ((index >= pointOne.size()) || (index >= pointTwo.size() )) + { + return 0; + } + else if (pointOne[index] < pointTwo[index]) + { + return -1; + } + else if (pointOne[index] > pointTwo[index]) + { + return 1; + } return 0; - } else if (pointOne[index] < pointTwo[index]) { - return -1; - } else if (pointOne[index] > pointTwo[index]) { - return 1; - } - return 0; } // compare diff --git a/src/qualityIndicator/util/LexicoGraphicalComparator.h b/src/qualityIndicator/util/LexicoGraphicalComparator.h index a1efc13..223cfef 100644 --- a/src/qualityIndicator/util/LexicoGraphicalComparator.h +++ b/src/qualityIndicator/util/LexicoGraphicalComparator.h @@ -24,10 +24,11 @@ #include #include -class LexicoGraphicalComparator : public Comparator { +class LexicoGraphicalComparator : public Comparator +{ public: - int compare(void * o1, void * o2); + int compare(void * o1, void * o2); }; diff --git a/src/qualityIndicator/util/MetricsUtil.cpp b/src/qualityIndicator/util/MetricsUtil.cpp index 841cc5c..7593ec9 100644 --- a/src/qualityIndicator/util/MetricsUtil.cpp +++ b/src/qualityIndicator/util/MetricsUtil.cpp @@ -30,38 +30,43 @@ using namespace std; * @param path The path to the file that contains the pareto front * @return double [][] whit the pareto front **/ -vector< vector > MetricsUtil::readFront(string path) { +vector< vector > MetricsUtil::readFront(string path) +{ - vector< vector > front; + vector< vector > front; - std::ifstream in(path.c_str()); - if( !in ) { - cout << "Error trying to read Pareto Front file: " << path << endl; - exit(-1); - } + std::ifstream in(path.c_str()); + if( !in ) + { + cout << "Error trying to read Pareto Front file: " << path << endl; + exit(-1); + } - string line; - while( getline(in, line ) ) { + string line; + while( getline(in, line ) ) + { - vector list; + vector list; - istringstream iss(line); + istringstream iss(line); - while (iss) { - string token; - iss >> token; - if (token.compare("")!=0) { - //cout << "Substring: " << token << endl; - list.push_back(atof(token.c_str())); - } - } - front.push_back(list); + while (iss) + { + string token; + iss >> token; + if (token.compare("")!=0) + { + //cout << "Substring: " << token << endl; + list.push_back(atof(token.c_str())); + } + } + front.push_back(list); - } + } - in.close(); + in.close(); - return front; + return front; } // readFront @@ -74,23 +79,28 @@ vector< vector > MetricsUtil::readFront(string path) { * for each objective **/ vector MetricsUtil::getMaximumValues(vector< vector > front, - int noObjectives) { + int noObjectives) +{ - vector maximumValue; + vector maximumValue; - for (int i = 0; i < noObjectives; i++) { - maximumValue.push_back(-std::numeric_limits::max()); - } + for (int i = 0; i < noObjectives; i++) + { + maximumValue.push_back(-std::numeric_limits::max()); + } - for (int i =0; i < front.size(); i++ ) { - for (int j = 0; j < front[i].size(); j++) { - if (front[i][j] > maximumValue[j]) { - maximumValue[j] = front[i][j]; - } - } - } + for (int i =0; i < front.size(); i++ ) + { + for (int j = 0; j < front[i].size(); j++) + { + if (front[i][j] > maximumValue[j]) + { + maximumValue[j] = front[i][j]; + } + } + } - return maximumValue; + return maximumValue; } // getMaximumValues @@ -103,23 +113,28 @@ vector MetricsUtil::getMaximumValues(vector< vector > front, * for each objective **/ vector MetricsUtil::getMinimumValues(vector< vector > front, - int noObjectives) { + int noObjectives) +{ - vector minimumValue; + vector minimumValue; - for (int i = 0; i < noObjectives; i++) { - minimumValue.push_back(std::numeric_limits::max()); - } + for (int i = 0; i < noObjectives; i++) + { + minimumValue.push_back(std::numeric_limits::max()); + } - for (int i =0; i < front.size(); i++ ) { - for (int j = 0; j < front[i].size(); j++) { - if (front[i][j] < minimumValue[j]) { - minimumValue[j] = front[i][j]; - } + for (int i =0; i < front.size(); i++ ) + { + for (int j = 0; j < front[i].size(); j++) + { + if (front[i][j] < minimumValue[j]) + { + minimumValue[j] = front[i][j]; + } + } } - } - return minimumValue; + return minimumValue; } // getMinimumValues @@ -131,15 +146,17 @@ vector MetricsUtil::getMinimumValues(vector< vector > front, * @param b A point * @return The euclidean distance between the points **/ -double MetricsUtil::distance(vector a, vector b) { +double MetricsUtil::distance(vector a, vector b) +{ - double distance = 0.0; + double distance = 0.0; - for (int i = 0; i < a.size(); i++) { - distance += pow(a[i]-b[i],2.0); - } + for (int i = 0; i < a.size(); i++) + { + distance += pow(a[i]-b[i],2.0); + } - return sqrt(distance); + return sqrt(distance); } // distance @@ -152,18 +169,21 @@ double MetricsUtil::distance(vector a, vector b) { * @return The minimum distance between the point and the front **/ double MetricsUtil::distanceToClosedPoint(vector point, - vector< vector > front) { - - double minDistance = distance(point,front[0]); - - for (int i = 1; i < front.size(); i++) { - double aux = distance(point,front[i]); - if (aux < minDistance) { - minDistance = aux; + vector< vector > front) +{ + + double minDistance = distance(point,front[0]); + + for (int i = 1; i < front.size(); i++) + { + double aux = distance(point,front[i]); + if (aux < minDistance) + { + minDistance = aux; + } } - } - return minDistance; + return minDistance; } // distanceToClosedPoint @@ -178,18 +198,21 @@ double MetricsUtil::distanceToClosedPoint(vector point, * the front */ double MetricsUtil::distanceToNearestPoint(vector point, - vector< vector > front) { - - double minDistance = std::numeric_limits::max(); - - for (int i = 0; i < front.size(); i++) { - double aux = distance(point,front[i]); - if ((aux < minDistance) && (aux > 0.0)) { - minDistance = aux; + vector< vector > front) +{ + + double minDistance = std::numeric_limits::max(); + + for (int i = 0; i < front.size(); i++) + { + double aux = distance(point,front[i]); + if ((aux < minDistance) && (aux > 0.0)) + { + minDistance = aux; + } } - } - return minDistance; + return minDistance; } // distanceToNearestPoint @@ -204,21 +227,24 @@ double MetricsUtil::distanceToNearestPoint(vector point, * @return the normalized pareto front **/ vector< vector > MetricsUtil::getNormalizedFront(vector< vector > front, - vector maximumValue, vector minimumValue) { - - vector< vector > normalizedFront; - - for (int i = 0; i < front.size();i++) { - vector list; - for (int j = 0; j < front[i].size(); j++) { - //normalizedFront[i][j] = (front[i][j] - minimumValue[j]) / - // (maximumValue[j] - minimumValue[j]); - list.push_back((front[i][j] - minimumValue[j]) / (maximumValue[j] - minimumValue[j])); + vector maximumValue, vector minimumValue) +{ + + vector< vector > normalizedFront; + + for (int i = 0; i < front.size(); i++) + { + vector list; + for (int j = 0; j < front[i].size(); j++) + { + //normalizedFront[i][j] = (front[i][j] - minimumValue[j]) / + // (maximumValue[j] - minimumValue[j]); + list.push_back((front[i][j] - minimumValue[j]) / (maximumValue[j] - minimumValue[j])); + } + normalizedFront.push_back(list); } - normalizedFront.push_back(list); - } - return normalizedFront; + return normalizedFront; } // getNormalizedFront @@ -229,25 +255,33 @@ vector< vector > MetricsUtil::getNormalizedFront(vector< vector * @param front The pareto front to inverse * @return The inverted pareto front **/ -vector< vector > MetricsUtil::invertedFront(vector< vector > front) { - - vector< vector > invertedFront; - - for (int i = 0; i < front.size(); i++) { - vector list; - for (int j = 0; j < front[i].size(); j++) { - if (front[i][j] <= 1.0 && front[i][j]>= 0.0) { - list.push_back(1.0 - front[i][j]); - } else if (front[i][j] > 1.0) { - list.push_back(0.0); - } else if (front[i][j] < 0.0) { - list.push_back(1.0); - } - } - invertedFront.push_back(list); - } - - return invertedFront; +vector< vector > MetricsUtil::invertedFront(vector< vector > front) +{ + + vector< vector > invertedFront; + + for (int i = 0; i < front.size(); i++) + { + vector list; + for (int j = 0; j < front[i].size(); j++) + { + if (front[i][j] <= 1.0 && front[i][j]>= 0.0) + { + list.push_back(1.0 - front[i][j]); + } + else if (front[i][j] > 1.0) + { + list.push_back(0.0); + } + else if (front[i][j] < 0.0) + { + list.push_back(1.0); + } + } + invertedFront.push_back(list); + } + + return invertedFront; } // invertedFront @@ -257,41 +291,47 @@ vector< vector > MetricsUtil::invertedFront(vector< vector > fro * @param path The path of the file containing the data * @return A solution set */ -SolutionSet * MetricsUtil::readNonDominatedSolutionSet(string path) { - - std::ifstream in(path.c_str()); - if( !in ) { - cout << "Error trying to read non dominated solutions file: " - << path << endl; - exit(-1); - } // if - - NonDominatedSolutionList * solutionSet = new NonDominatedSolutionList(); - string line; - - while( getline(in, line ) ) { - - vector list; - istringstream iss(line); - while (iss) { - string token; - iss >> token; - if (token.compare("")!=0) { - //cout << "Substring: " << token << endl; - list.push_back(atof(token.c_str())); - } // if - } // while +SolutionSet * MetricsUtil::readNonDominatedSolutionSet(string path) +{ + + std::ifstream in(path.c_str()); + if( !in ) + { + cout << "Error trying to read non dominated solutions file: " + << path << endl; + exit(-1); + } // if + + NonDominatedSolutionList * solutionSet = new NonDominatedSolutionList(); + string line; + + while( getline(in, line ) ) + { + + vector list; + istringstream iss(line); + while (iss) + { + string token; + iss >> token; + if (token.compare("")!=0) + { + //cout << "Substring: " << token << endl; + list.push_back(atof(token.c_str())); + } // if + } // while + + Solution * solution = new Solution(list.size()); + for (int i=0; isetObjective(i,list[i]); + } //for + solutionSet->add(solution); - Solution * solution = new Solution(list.size()); - for (int i=0; isetObjective(i,list[i]); - } //for - solutionSet->add(solution); - - } // while + } // while - in.close(); - return solutionSet; + in.close(); + return solutionSet; } // readNonDominatedSolutionSet @@ -302,38 +342,44 @@ SolutionSet * MetricsUtil::readNonDominatedSolutionSet(string path) { * @param path The path of the file containing the data * @return A solution set */ -void MetricsUtil::readNonDominatedSolutionSet(string path, NonDominatedSolutionList * solutionSet) { - - std::ifstream in(path.c_str()); - if( !in ) { - cout << "Error trying to read non dominated solutions file: " - << path << endl; - exit(-1); - } // if - - string line; - - while( getline(in, line ) ) { - - vector list; - istringstream iss(line); - while (iss) { - string token; - iss >> token; - if (token.compare("")!=0) { - //cout << "Substring: " << token << endl; - list.push_back(atof(token.c_str())); - } // if - } // while +void MetricsUtil::readNonDominatedSolutionSet(string path, NonDominatedSolutionList * solutionSet) +{ + + std::ifstream in(path.c_str()); + if( !in ) + { + cout << "Error trying to read non dominated solutions file: " + << path << endl; + exit(-1); + } // if + + string line; + + while( getline(in, line ) ) + { + + vector list; + istringstream iss(line); + while (iss) + { + string token; + iss >> token; + if (token.compare("")!=0) + { + //cout << "Substring: " << token << endl; + list.push_back(atof(token.c_str())); + } // if + } // while + + Solution * solution = new Solution(list.size()); + for (int i=0; isetObjective(i,list[i]); + } //for + solutionSet->add(solution); - Solution * solution = new Solution(list.size()); - for (int i=0; isetObjective(i,list[i]); - } //for - solutionSet->add(solution); - - } // while + } // while - in.close(); + in.close(); } // readNonDominatedSolutionSet diff --git a/src/qualityIndicator/util/MetricsUtil.h b/src/qualityIndicator/util/MetricsUtil.h index 239b696..a8b87b5 100644 --- a/src/qualityIndicator/util/MetricsUtil.h +++ b/src/qualityIndicator/util/MetricsUtil.h @@ -39,20 +39,21 @@ using namespace std; * @brief This class provides some utilities to compute quality indicators **/ -class MetricsUtil { +class MetricsUtil +{ public: - vector< vector > readFront(string path); - vector getMaximumValues(vector< vector > front, int noObjectives); - vector getMinimumValues(vector< vector > front, int noObjectives); - double distance(vector a, vector b); - double distanceToClosedPoint(vector point, vector< vector > front); - double distanceToNearestPoint(vector point, vector< vector > front); - vector< vector > getNormalizedFront(vector< vector > front, - vector maximumValue, vector minimumValue); - vector< vector > invertedFront(vector< vector > front); - SolutionSet * readNonDominatedSolutionSet(string path); - void readNonDominatedSolutionSet(string path, NonDominatedSolutionList * solutionSet); + vector< vector > readFront(string path); + vector getMaximumValues(vector< vector > front, int noObjectives); + vector getMinimumValues(vector< vector > front, int noObjectives); + double distance(vector a, vector b); + double distanceToClosedPoint(vector point, vector< vector > front); + double distanceToNearestPoint(vector point, vector< vector > front); + vector< vector > getNormalizedFront(vector< vector > front, + vector maximumValue, vector minimumValue); + vector< vector > invertedFront(vector< vector > front); + SolutionSet * readNonDominatedSolutionSet(string path); + void readNonDominatedSolutionSet(string path, NonDominatedSolutionList * solutionSet); }; #endif /* __METRICSUTIL__ */ diff --git a/src/util/AdaptiveGrid.cpp b/src/util/AdaptiveGrid.cpp index 7cd1cee..ef8b2a6 100644 --- a/src/util/AdaptiveGrid.cpp +++ b/src/util/AdaptiveGrid.cpp @@ -28,18 +28,19 @@ using namespace std; * @param objetives Number of objectives of the problem. */ -AdaptiveGrid::AdaptiveGrid(int bisections, int objetives) { - bisections_ = bisections; - objectives_ = objetives ; - lowerLimits_ = new double[objectives_]; - upperLimits_ = new double[objectives_]; - divisionSize_ = new double[objectives_]; - - sizehypercubes_ = (int)pow(2.0,bisections_*objectives_); // Size int * - - hypercubes_ = new int[sizehypercubes_]; - for (int i = 0; i < sizehypercubes_;i++) - hypercubes_[i] = 0; +AdaptiveGrid::AdaptiveGrid(int bisections, int objetives) +{ + bisections_ = bisections; + objectives_ = objetives ; + lowerLimits_ = new double[objectives_]; + upperLimits_ = new double[objectives_]; + divisionSize_ = new double[objectives_]; + + sizehypercubes_ = (int)pow(2.0,bisections_*objectives_); // Size int * + + hypercubes_ = new int[sizehypercubes_]; + for (int i = 0; i < sizehypercubes_; i++) + hypercubes_[i] = 0; }//AdaptativeGrid @@ -48,27 +49,33 @@ AdaptiveGrid::AdaptiveGrid(int bisections, int objetives) { * SolutionSet. * @param solutionSet The SolutionSet considered. */ -void AdaptiveGrid::updateLimits(SolutionSet * solutionSet){ +void AdaptiveGrid::updateLimits(SolutionSet * solutionSet) +{ //Init the lower and upper limits - for (int obj = 0; obj < objectives_; obj++){ - //Set the lower limits to the max real - lowerLimits_[obj] = numeric_limits::max( ); - //Set the upper limits to the min real - upperLimits_[obj] = numeric_limits::min( ); ; + for (int obj = 0; obj < objectives_; obj++) + { + //Set the lower limits to the max real + lowerLimits_[obj] = numeric_limits::max( ); + //Set the upper limits to the min real + upperLimits_[obj] = numeric_limits::min( ); ; } // for //Find the max and min limits of objetives into the population - for (int ind = 0; ind < solutionSet->size(); ind++){ - Solution * tmpIndividual = solutionSet->get(ind); - for (int obj = 0; obj < objectives_; obj++) { - if (tmpIndividual->getObjective(obj) < lowerLimits_[obj]) { - lowerLimits_[obj] = tmpIndividual->getObjective(obj); - } - if (tmpIndividual->getObjective(obj) > upperLimits_[obj]) { - upperLimits_[obj] = tmpIndividual->getObjective(obj); - } - } // for + for (int ind = 0; ind < solutionSet->size(); ind++) + { + Solution * tmpIndividual = solutionSet->get(ind); + for (int obj = 0; obj < objectives_; obj++) + { + if (tmpIndividual->getObjective(obj) < lowerLimits_[obj]) + { + lowerLimits_[obj] = tmpIndividual->getObjective(obj); + } + if (tmpIndividual->getObjective(obj) > upperLimits_[obj]) + { + upperLimits_[obj] = tmpIndividual->getObjective(obj); + } + } // for } // for }//updateLimits @@ -80,21 +87,23 @@ void AdaptiveGrid::updateLimits(SolutionSet * solutionSet){ * @param solutionSet The SolutionSet considered. */ -void AdaptiveGrid::addSolutionSet(SolutionSet * solutionSet){ +void AdaptiveGrid::addSolutionSet(SolutionSet * solutionSet) +{ //Calculate the location of all individuals and update the grid mostPopulated_ = 0; int location_; - for (int ind = 0; ind < solutionSet->size();ind++){ - location_ = location(solutionSet->get(ind)); - hypercubes_[location_]++; - if (hypercubes_[location_] > hypercubes_[mostPopulated_]) - mostPopulated_ = location_; + for (int ind = 0; ind < solutionSet->size(); ind++) + { + location_ = location(solutionSet->get(ind)); + hypercubes_[location_]++; + if (hypercubes_[location_] > hypercubes_[mostPopulated_]) + mostPopulated_ = location_; } // for //The grid has been updated, so also update ocuppied's hypercubes calculateOccupied(); - } // addSolutionSet +} // addSolutionSet /** @@ -102,23 +111,26 @@ void AdaptiveGrid::addSolutionSet(SolutionSet * solutionSet){ * in a specific SolutionSet. * @param solutionSet The SolutionSet. */ -void AdaptiveGrid::updateGrid(SolutionSet * solutionSet){ +void AdaptiveGrid::updateGrid(SolutionSet * solutionSet) +{ //Update lower and upper limits updateLimits(solutionSet); //Calculate the division size - for (int obj = 0; obj < objectives_; obj++){ - divisionSize_[obj] = upperLimits_[obj] - lowerLimits_[obj]; + for (int obj = 0; obj < objectives_; obj++) + { + divisionSize_[obj] = upperLimits_[obj] - lowerLimits_[obj]; } // for //Clean the hypercubes - for (int i = 0; i < sizehypercubes_;i++) { - hypercubes_[i] = 0; + for (int i = 0; i < sizehypercubes_; i++) + { + hypercubes_[i] = 0; } //Add the population addSolutionSet(solutionSet); - } //updateGrid +} //updateGrid /** @@ -129,239 +141,270 @@ void AdaptiveGrid::updateGrid(SolutionSet * solutionSet){ * @param solution Solution considered to update the grid. * @param solutionSet SolutionSet used to update the grid. */ -void AdaptiveGrid::updateGrid(Solution * solution, SolutionSet * solutionSet, int eval){ +void AdaptiveGrid::updateGrid(Solution * solution, SolutionSet * solutionSet, int eval) +{ int location_ = location(solution); - if (location_ == -1) {//Re-build the Adaptative-Grid - //Update lower and upper limits - updateLimits(solutionSet); - - //Actualize the lower and upper limits whit the individual - for (int obj = 0; obj < objectives_; obj++){ - if (solution->getObjective(obj) < lowerLimits_[obj]) - lowerLimits_[obj] = solution->getObjective(obj); - if (solution->getObjective(obj) > upperLimits_[obj]) - upperLimits_[obj] = solution->getObjective(obj); - } // for - - //Calculate the division size - for (int obj = 0; obj < objectives_; obj++){ - divisionSize_[obj] = upperLimits_[obj] - lowerLimits_[obj]; - } + if (location_ == -1) //Re-build the Adaptative-Grid + { + //Update lower and upper limits + updateLimits(solutionSet); + + //Actualize the lower and upper limits whit the individual + for (int obj = 0; obj < objectives_; obj++) + { + if (solution->getObjective(obj) < lowerLimits_[obj]) + lowerLimits_[obj] = solution->getObjective(obj); + if (solution->getObjective(obj) > upperLimits_[obj]) + upperLimits_[obj] = solution->getObjective(obj); + } // for - //Clean the hypercube - for (int i = 0; i < sizehypercubes_; i++) { - hypercubes_[i] = 0; - } + //Calculate the division size + for (int obj = 0; obj < objectives_; obj++) + { + divisionSize_[obj] = upperLimits_[obj] - lowerLimits_[obj]; + } - //add the population - addSolutionSet(solutionSet); + //Clean the hypercube + for (int i = 0; i < sizehypercubes_; i++) + { + hypercubes_[i] = 0; + } + + //add the population + addSolutionSet(solutionSet); } // if - } //updateGrid +} //updateGrid /** * Calculates the hypercube of a solution. * @param solution The Solution. */ -int AdaptiveGrid::location(Solution * solution){ +int AdaptiveGrid::location(Solution * solution) +{ //Create a int [] to store the range of each objetive int * position = new int[objectives_]; //Calculate the position for each objetive - for (int obj = 0; obj < objectives_; obj++) { - - position[obj] = 0; //Inicialize - - if ((solution->getObjective(obj) > upperLimits_[obj]) - || (solution->getObjective(obj) < lowerLimits_[obj])) - { - delete [] position; - return -1; - } - else if (solution->getObjective(obj) ==lowerLimits_[obj]) - position[obj] = 0; - else if (solution->getObjective(obj) ==upperLimits_[obj]) - position[obj] = ((int)pow(2.0,bisections_))-1; - else { - double tmpSize = divisionSize_[obj]; - double value = solution->getObjective(obj); - double account = lowerLimits_[obj]; - int ranges = (int) pow(2.0,bisections_); - for (int b = 0; b < bisections_; b++){ - tmpSize /= 2.0; - ranges /= 2; - if (value > (account + tmpSize)){ - position[obj] += ranges; - account += tmpSize; - } // if - } // for - } // if + for (int obj = 0; obj < objectives_; obj++) + { + + position[obj] = 0; //Inicialize + + if ((solution->getObjective(obj) > upperLimits_[obj]) + || (solution->getObjective(obj) < lowerLimits_[obj])) + { + delete [] position; + return -1; + } + else if (solution->getObjective(obj) ==lowerLimits_[obj]) + position[obj] = 0; + else if (solution->getObjective(obj) ==upperLimits_[obj]) + position[obj] = ((int)pow(2.0,bisections_))-1; + else + { + double tmpSize = divisionSize_[obj]; + double value = solution->getObjective(obj); + double account = lowerLimits_[obj]; + int ranges = (int) pow(2.0,bisections_); + for (int b = 0; b < bisections_; b++) + { + tmpSize /= 2.0; + ranges /= 2; + if (value > (account + tmpSize)) + { + position[obj] += ranges; + account += tmpSize; + } // if + } // for + } // if } //Calcualate the location into the hypercubes int location = 0; - for (int obj = 0; obj < objectives_; obj++) { - location += position[obj] * (int)pow(2.0,obj * bisections_); - } + for (int obj = 0; obj < objectives_; obj++) + { + location += position[obj] * (int)pow(2.0,obj * bisections_); + } delete [] position; return location; - } //location +} //location /** * Returns the value of the most populated hypercube. * @return The hypercube with the maximum number of solutions. */ -int AdaptiveGrid::getMostPopulated(){ +int AdaptiveGrid::getMostPopulated() +{ return mostPopulated_; - } // getMostPopulated +} // getMostPopulated - /** - * Returns the number of solutions into a specific hypercube. - * @param location Number of the hypercube. - * @return The number of solutions into a specific hypercube. - */ -int AdaptiveGrid::getLocationDensity(int location){ - return hypercubes_[location]; - } //getLocationDensity +/** +* Returns the number of solutions into a specific hypercube. +* @param location Number of the hypercube. +* @return The number of solutions into a specific hypercube. +*/ +int AdaptiveGrid::getLocationDensity(int location) +{ + return hypercubes_[location]; +} //getLocationDensity - /** - * Decreases the number of solutions into a specific hypercube. - * @param location Number of hypercube. - */ -void AdaptiveGrid::removeSolution(int location) { +/** +* Decreases the number of solutions into a specific hypercube. +* @param location Number of hypercube. +*/ +void AdaptiveGrid::removeSolution(int location) +{ //Decrease the solutions in the location specified. hypercubes_[location]--; //Update the most poblated hypercube if (location == mostPopulated_) - for (int i = 0; i < sizehypercubes_;i++) - if (hypercubes_[i] > hypercubes_[mostPopulated_]) - mostPopulated_ = i; + for (int i = 0; i < sizehypercubes_; i++) + if (hypercubes_[i] > hypercubes_[mostPopulated_]) + mostPopulated_ = i; //If hypercubes[location] now becomes to zero, then update ocupped hypercubes if (hypercubes_[location]==0) - calculateOccupied(); - } //removeSolution + calculateOccupied(); +} //removeSolution /** * Increases the number of solutions into a specific hypercube. * @param location Number of hypercube. */ -void AdaptiveGrid::addSolution(int location) { +void AdaptiveGrid::addSolution(int location) +{ //Increase the solutions in the location specified. hypercubes_[location]++; //Update the most poblated hypercube if (hypercubes_[location] > hypercubes_[mostPopulated_]) - mostPopulated_ = location; + mostPopulated_ = location; //if hypercubes[location] becomes to one, then recalculate //the occupied hypercubes if (hypercubes_[location] == 1) - calculateOccupied(); - } //addSolution + calculateOccupied(); +} //addSolution - /** - * Returns the number of bi-divisions performed in each objective. - * @return the number of bi-divisions. - */ - int AdaptiveGrid::getBisections() { +/** +* Returns the number of bi-divisions performed in each objective. +* @return the number of bi-divisions. +*/ +int AdaptiveGrid::getBisections() +{ return bisections_; - } //getBisections - - /** - * Retunrns a String representing the grid. - * @return The String. - */ - string AdaptiveGrid::toString() { - stringstream result; +} //getBisections + +/** + * Retunrns a String representing the grid. + * @return The String. + */ +string AdaptiveGrid::toString() +{ + stringstream result; result << "Grid\n"; - for (int obj = 0; obj < objectives_; obj++){ - result << "Objective " << obj << " " << lowerLimits_[obj] << " - " << upperLimits_[obj] << "\n"; + for (int obj = 0; obj < objectives_; obj++) + { + result << "Objective " << obj << " " << lowerLimits_[obj] << " - " << upperLimits_[obj] << "\n"; } // for return result.str(); - } // toString +} // toString - /** - * Returns a random hypercube using a rouleteWheel method. - * @return the number of the selected hypercube. - */ -int AdaptiveGrid::rouletteWheel(){ +/** + * Returns a random hypercube using a rouleteWheel method. +* @return the number of the selected hypercube. +*/ +int AdaptiveGrid::rouletteWheel() +{ //Calculate the inverse sum double inverseSum = 0.0; - for (int i = 0; i < sizehypercubes_; i++) { - if (hypercubes_[i] > 0) { - inverseSum += 1.0 / (double)hypercubes_[i]; - } + for (int i = 0; i < sizehypercubes_; i++) + { + if (hypercubes_[i] > 0) + { + inverseSum += 1.0 / (double)hypercubes_[i]; + } } //Calculate a random value between 0 and sumaInversa double random = PseudoRandom::randDouble(0.0,inverseSum); int hypercube = 0; double accumulatedSum = 0.0; - while (hypercube < sizehypercubes_){ - if (hypercubes_[hypercube] > 0) { - accumulatedSum += 1.0 / (double)hypercubes_[hypercube]; - } // if - - if (accumulatedSum > random) { - return hypercube; - } // if - - hypercube++; + while (hypercube < sizehypercubes_) + { + if (hypercubes_[hypercube] > 0) + { + accumulatedSum += 1.0 / (double)hypercubes_[hypercube]; + } // if + + if (accumulatedSum > random) + { + return hypercube; + } // if + + hypercube++; } // while return hypercube; - } //rouletteWheel +} //rouletteWheel - /** - * Calculates the number of hypercubes having one or more solutions. - * return the number of hypercubes with more than zero solutions. - */ -int AdaptiveGrid::calculateOccupied(){ +/** +* Calculates the number of hypercubes having one or more solutions. +* return the number of hypercubes with more than zero solutions. +*/ +int AdaptiveGrid::calculateOccupied() +{ int total = 0; - for (int i = 0; i < sizehypercubes_; i++) { - if (hypercubes_[i] > 0) { - total++; - } // if + for (int i = 0; i < sizehypercubes_; i++) + { + if (hypercubes_[i] > 0) + { + total++; + } // if } // for occupiedsize_ = total; occupied_ = new int[occupiedsize_]; int base = 0; - for (int i = 0; i < sizehypercubes_;i++){ - if (hypercubes_[i] > 0){ - occupied_[base] = i; - base++; - } // if + for (int i = 0; i < sizehypercubes_; i++) + { + if (hypercubes_[i] > 0) + { + occupied_[base] = i; + base++; + } // if } // for return total; - } //calculateOcuppied +} //calculateOcuppied - /** - * Returns the number of hypercubes with more than zero solutions. - * @return the number of hypercubes with more than zero solutions. - */ -int AdaptiveGrid::occupiedHypercubes(){ +/** + * Returns the number of hypercubes with more than zero solutions. + * @return the number of hypercubes with more than zero solutions. + */ +int AdaptiveGrid::occupiedHypercubes() +{ return occupiedsize_; - } // occupiedHypercubes +} // occupiedHypercubes - /** - * Returns a random hypercube that has more than zero solutions. - * @return The hypercube. - */ -int AdaptiveGrid:: randomOccupiedHypercube(){ +/** + * Returns a random hypercube that has more than zero solutions. + * @return The hypercube. + */ +int AdaptiveGrid:: randomOccupiedHypercube() +{ int rand = PseudoRandom::randInt(0,occupiedsize_-1); return occupied_[rand]; - } //randomOccupiedHypercube +} //randomOccupiedHypercube diff --git a/src/util/AdaptiveGrid.h b/src/util/AdaptiveGrid.h index 648b814..1a1b2d3 100644 --- a/src/util/AdaptiveGrid.h +++ b/src/util/AdaptiveGrid.h @@ -32,73 +32,74 @@ /** * This class implements some utilities for calculating distances */ -class AdaptiveGrid { +class AdaptiveGrid +{ private: - /** - * Number of bi-divisions of the objective space - */ - int bisections_; + /** + * Number of bi-divisions of the objective space + */ + int bisections_; - /** - * Objectives of the problem - */ - int objectives_; + /** + * Objectives of the problem + */ + int objectives_; - /** - * Number of solutions into a specific hypercube in the adaptative grid - */ - int * hypercubes_; + /** + * Number of solutions into a specific hypercube in the adaptative grid + */ + int * hypercubes_; - int sizehypercubes_; - /** - * - * Grid lower bounds - */ - double * lowerLimits_; + int sizehypercubes_; + /** + * + * Grid lower bounds + */ + double * lowerLimits_; - /** - * Grid upper bounds - */ - double * upperLimits_; + /** + * Grid upper bounds + */ + double * upperLimits_; - /** - * Size of hypercube for each dimension - */ - double * divisionSize_; + /** + * Size of hypercube for each dimension + */ + double * divisionSize_; - /** - * Hypercube with maximum number of solutions - */ - int mostPopulated_; + /** + * Hypercube with maximum number of solutions + */ + int mostPopulated_; - /** - * Indicates when an hypercube has solutions - */ - int * occupied_; + /** + * Indicates when an hypercube has solutions + */ + int * occupied_; - int occupiedsize_; + int occupiedsize_; - void updateLimits(SolutionSet * solutionSet); + void updateLimits(SolutionSet * solutionSet); public: - AdaptiveGrid(int bisections, int objetives); - - void addSolutionSet(SolutionSet * solutionSet); - void updateGrid(SolutionSet * solutionSet); - void updateGrid(Solution * solution, SolutionSet * solutionSet, int eval); - int location(Solution * solution); - int getMostPopulated(); - int getLocationDensity(int location); - void removeSolution(int location); - void addSolution(int location); - int getBisections(); - string toString(); - int rouletteWheel(); - int calculateOccupied(); - int occupiedHypercubes(); - int randomOccupiedHypercube(); + AdaptiveGrid(int bisections, int objetives); + + void addSolutionSet(SolutionSet * solutionSet); + void updateGrid(SolutionSet * solutionSet); + void updateGrid(Solution * solution, SolutionSet * solutionSet, int eval); + int location(Solution * solution); + int getMostPopulated(); + int getLocationDensity(int location); + void removeSolution(int location); + void addSolution(int location); + int getBisections(); + string toString(); + int rouletteWheel(); + int calculateOccupied(); + int occupiedHypercubes(); + int randomOccupiedHypercube(); }; diff --git a/src/util/AdaptiveRandomNeighborhood.cpp b/src/util/AdaptiveRandomNeighborhood.cpp index a9b19ff..64758f3 100644 --- a/src/util/AdaptiveRandomNeighborhood.cpp +++ b/src/util/AdaptiveRandomNeighborhood.cpp @@ -31,19 +31,21 @@ * Constructor. * Defines a neighborhood of a given size. */ -AdaptiveRandomNeighborhood::AdaptiveRandomNeighborhood(SolutionSet * solutionSet, int numberOfRandomNeighbours) { - solutionSet_ = solutionSet; - numberOfRandomNeighbours_ = numberOfRandomNeighbours; - //problem_ = solutionSet_->get(0)->getProblem() ; - - //list_ = new int * [solutionSet_->size()]; - - for (int i = 0; i < solutionSet_->size(); i++) { - //list_[i] = new int [] - vector list_i; - list_i.push_back(i); - list_.push_back(list_i); - } +AdaptiveRandomNeighborhood::AdaptiveRandomNeighborhood(SolutionSet * solutionSet, int numberOfRandomNeighbours) +{ + solutionSet_ = solutionSet; + numberOfRandomNeighbours_ = numberOfRandomNeighbours; + //problem_ = solutionSet_->get(0)->getProblem() ; + + //list_ = new int * [solutionSet_->size()]; + + for (int i = 0; i < solutionSet_->size(); i++) + { + //list_[i] = new int [] + vector list_i; + list_i.push_back(i); + list_.push_back(list_i); + } // if(std::find(v.begin(), v.end(), x) != v.end()) { // /* v contains x */ @@ -51,90 +53,111 @@ AdaptiveRandomNeighborhood::AdaptiveRandomNeighborhood(SolutionSet * solutionSet // /* v does not contain x */ // } - //cout << "list: " << list_ << endl; - for (int i = 0; i < solutionSet_->size(); i++) { - //list_.at(i).push_back(i); - for (int j = 0; j < numberOfRandomNeighbours_; j++) { - int random = PseudoRandom::randInt(0, solutionSet_->size() - 1); - //cout << "i: " << i >> " random: " << random << " listb: " << list_at(random) << endl; - //if (!list_.at(random).contains((Integer) i)) - if (find(list_.at(random).begin(), list_.at(random).end(), i) == list_.at(random).end()) { - list_.at(random).push_back(i); - } + //cout << "list: " << list_ << endl; + for (int i = 0; i < solutionSet_->size(); i++) + { + //list_.at(i).push_back(i); + for (int j = 0; j < numberOfRandomNeighbours_; j++) + { + int random = PseudoRandom::randInt(0, solutionSet_->size() - 1); + //cout << "i: " << i >> " random: " << random << " listb: " << list_at(random) << endl; + //if (!list_.at(random).contains((Integer) i)) + if (find(list_.at(random).begin(), list_.at(random).end(), i) == list_.at(random).end()) + { + list_.at(random).push_back(i); + } + } } - } - //cout << "L: " << list_ << endl; - cout << "L:" << endl; - for (int i = 0; i < list_.size(); i++) { - cout << "\t["; - for (int j = 0; j < list_.at(i).size(); j++) { - cout << list_.at(i).at(j); - if (j < list_.at(i).size()-1) { - cout << ","; - } else { - cout << "]" << endl; - } + //cout << "L: " << list_ << endl; + cout << "L:" << endl; + for (int i = 0; i < list_.size(); i++) + { + cout << "\t["; + for (int j = 0; j < list_.at(i).size(); j++) + { + cout << list_.at(i).at(j); + if (j < list_.at(i).size()-1) + { + cout << ","; + } + else + { + cout << "]" << endl; + } + } } - } } -vector AdaptiveRandomNeighborhood::getNeighbors(int i) { - if (i > list_.size()) { - cerr << "Error in AdaptiveRandomNeighborhood.getNeighbors" - << "the parameter " << i << " is less than " << list_.size() - << endl; - exit(-1); - } - return list_.at(i); +vector AdaptiveRandomNeighborhood::getNeighbors(int i) +{ + if (i > list_.size()) + { + cerr << "Error in AdaptiveRandomNeighborhood.getNeighbors" + << "the parameter " << i << " is less than " << list_.size() + << endl; + exit(-1); + } + return list_.at(i); } -int AdaptiveRandomNeighborhood::getNumberOfRandomNeighbours() { - return numberOfRandomNeighbours_; +int AdaptiveRandomNeighborhood::getNumberOfRandomNeighbours() +{ + return numberOfRandomNeighbours_; } -SolutionSet * AdaptiveRandomNeighborhood::getBestFitnessSolutionInNeighborhood(Comparator * comparator) { - SolutionSet * result = new SolutionSet(); - for (int i = 0; i < list_.size(); i++) { - Solution * bestSolution = solutionSet_->get(list_.at(i).at(0)); - for (int j = 1; j < list_.at(i).size(); j++) { - if (comparator->compare(bestSolution, solutionSet_->get(list_.at(i).at(j))) > 0) { - bestSolution = solutionSet_->get(list_.at(i).at(j)); - } +SolutionSet * AdaptiveRandomNeighborhood::getBestFitnessSolutionInNeighborhood(Comparator * comparator) +{ + SolutionSet * result = new SolutionSet(); + for (int i = 0; i < list_.size(); i++) + { + Solution * bestSolution = solutionSet_->get(list_.at(i).at(0)); + for (int j = 1; j < list_.at(i).size(); j++) + { + if (comparator->compare(bestSolution, solutionSet_->get(list_.at(i).at(j))) > 0) + { + bestSolution = solutionSet_->get(list_.at(i).at(j)); + } + } + result->add(bestSolution); } - result->add(bestSolution); - } - return result; + return result; } -vector> AdaptiveRandomNeighborhood::getNeighborhood() { - return list_; +vector> AdaptiveRandomNeighborhood::getNeighborhood() +{ + return list_; } -void AdaptiveRandomNeighborhood::recompute() { - list_.clear(); +void AdaptiveRandomNeighborhood::recompute() +{ + list_.clear(); - for (int i = 0; i < solutionSet_->size(); i++) { - //list_[i] = new int [] - vector list_i; - list_i.push_back(i); - list_.push_back(list_i); - } + for (int i = 0; i < solutionSet_->size(); i++) + { + //list_[i] = new int [] + vector list_i; + list_i.push_back(i); + list_.push_back(list_i); + } - for (int i = 0; i < solutionSet_->size(); i++) { - for (int j = 0; j < numberOfRandomNeighbours_; j++) { - int random = PseudoRandom::randInt(0, solutionSet_->size() - 1); - //if (!list_.at(random).contains((Integer) i)) - if (find(list_.at(random).begin(), list_.at(random).end(), i) == list_.at(random).end()) { - list_.at(random).push_back(i); - } + for (int i = 0; i < solutionSet_->size(); i++) + { + for (int j = 0; j < numberOfRandomNeighbours_; j++) + { + int random = PseudoRandom::randInt(0, solutionSet_->size() - 1); + //if (!list_.at(random).contains((Integer) i)) + if (find(list_.at(random).begin(), list_.at(random).end(), i) == list_.at(random).end()) + { + list_.at(random).push_back(i); + } + } } - } } diff --git a/src/util/AdaptiveRandomNeighborhood.h b/src/util/AdaptiveRandomNeighborhood.h index 617060a..318e7ce 100644 --- a/src/util/AdaptiveRandomNeighborhood.h +++ b/src/util/AdaptiveRandomNeighborhood.h @@ -35,23 +35,24 @@ using namespace std; /** * Class representing an adaptive random neighborhood */ -class AdaptiveRandomNeighborhood { +class AdaptiveRandomNeighborhood +{ private: - SolutionSet * solutionSet_; - vector> list_; - int numberOfRandomNeighbours_; + SolutionSet * solutionSet_; + vector> list_; + int numberOfRandomNeighbours_; public: - AdaptiveRandomNeighborhood(SolutionSet * solutionSet, int numberOfRandomNeighbours); - vector getNeighbors(int i); - int getNumberOfRandomNeighbours(); - SolutionSet * getBestFitnessSolutionInNeighborhood(Comparator * comparator); - vector> getNeighborhood(); - void recompute(); - //string toString(); + AdaptiveRandomNeighborhood(SolutionSet * solutionSet, int numberOfRandomNeighbours); + vector getNeighbors(int i); + int getNumberOfRandomNeighbours(); + SolutionSet * getBestFitnessSolutionInNeighborhood(Comparator * comparator); + vector> getNeighborhood(); + void recompute(); + //string toString(); }; // AdaptiveRandomNeighborhood diff --git a/src/util/Distance.cpp b/src/util/Distance.cpp index b62040a..a1b5a62 100644 --- a/src/util/Distance.cpp +++ b/src/util/Distance.cpp @@ -32,8 +32,9 @@ /** * Constructor. */ -Distance::Distance() { - //do nothing. +Distance::Distance() +{ + //do nothing. } // Distance @@ -43,29 +44,33 @@ Distance::Distance() { * @param solutionSet The SolutionSet. * @return a matrix with distances. */ -double ** Distance::distanceMatrix(SolutionSet * solutionSet) { - Solution * solutionI; - Solution * solutionJ; - - //The matrix of distances - int size = solutionSet->size(); - double ** distance = nullptr;// = new double [size][size]; - for (int i = 0; i < solutionSet->size(); i++){ - distance[i] = new double[size]; - } - //-> Calculate the distances - for (int i = 0; i < solutionSet->size(); i++){ - distance[i][i] = 0.0; - solutionI = solutionSet->get(i); - for (int j = i + 1; j < solutionSet->size(); j++){ - solutionJ = solutionSet->get(j); - distance[i][j] = this->distanceBetweenObjectives(solutionI,solutionJ); - distance[j][i] = distance[i][j]; +double ** Distance::distanceMatrix(SolutionSet * solutionSet) +{ + Solution * solutionI; + Solution * solutionJ; + + //The matrix of distances + int size = solutionSet->size(); + double ** distance = nullptr;// = new double [size][size]; + for (int i = 0; i < solutionSet->size(); i++) + { + distance[i] = new double[size]; + } + //-> Calculate the distances + for (int i = 0; i < solutionSet->size(); i++) + { + distance[i][i] = 0.0; + solutionI = solutionSet->get(i); + for (int j = i + 1; j < solutionSet->size(); j++) + { + solutionJ = solutionSet->get(j); + distance[i][j] = this->distanceBetweenObjectives(solutionI,solutionJ); + distance[j][i] = distance[i][j]; + } // for } // for - } // for - //->Return the matrix of distances - return distance; + //->Return the matrix of distances + return distance; } // distanceMatrix @@ -77,19 +82,21 @@ double ** Distance::distanceMatrix(SolutionSet * solutionSet) { * @return The minimum distance between solution and the set. */ double Distance::distanceToSolutionSetInObjectiveSpace(Solution *solution, - SolutionSet * solutionSet) { - //At start point the distance is the max - double distance = std::numeric_limits::max(); - - // found the min distance respect to population - for (int i = 0; i < solutionSet->size();i++){ - double aux = this->distanceBetweenObjectives(solution,solutionSet->get(i)); - if (aux < distance) - distance = aux; - } // for - - //->Return the best distance - return distance; + SolutionSet * solutionSet) +{ + //At start point the distance is the max + double distance = std::numeric_limits::max(); + + // found the min distance respect to population + for (int i = 0; i < solutionSet->size(); i++) + { + double aux = this->distanceBetweenObjectives(solution,solutionSet->get(i)); + if (aux < distance) + distance = aux; + } // for + + //->Return the best distance + return distance; } // distanceToSolutionSetinObjectiveSpace @@ -101,19 +108,21 @@ double Distance::distanceToSolutionSetInObjectiveSpace(Solution *solution, * @return The minimum distance between solution and the set. */ double Distance::distanceToSolutionSetInSolutionSpace(Solution * solution, - SolutionSet * solutionSet) { - //At start point the distance is the max - double distance = std::numeric_limits::max(); - - // found the min distance respect to population - for (int i = 0; i < solutionSet->size(); i++) { - double aux = this->distanceBetweenSolutions(solution,solutionSet->get(i)); - if (aux < distance) - distance = aux; - } // for - - //->Return the best distance - return distance; + SolutionSet * solutionSet) +{ + //At start point the distance is the max + double distance = std::numeric_limits::max(); + + // found the min distance respect to population + for (int i = 0; i < solutionSet->size(); i++) + { + double aux = this->distanceBetweenSolutions(solution,solutionSet->get(i)); + if (aux < distance) + distance = aux; + } // for + + //->Return the best distance + return distance; } // distanceToSolutionSetInSolutionSpace @@ -123,22 +132,24 @@ double Distance::distanceToSolutionSetInSolutionSpace(Solution * solution, * @param solutionJ The second Solution. * @return the distance between solutions. */ -double Distance::distanceBetweenSolutions(Solution * solutionI, Solution * solutionJ) { - //->Obtain his decision variables - Variable ** decisionVariableI = solutionI->getDecisionVariables(); - Variable ** decisionVariableJ = solutionJ->getDecisionVariables(); - - double diff; //Auxiliar var - double distance = 0.0; - //-> Calculate the Euclidean distance - for (int i = 0; i < solutionI->getNumberOfVariables(); i++){ - diff = decisionVariableI[i]->getValue() - - decisionVariableJ[i]->getValue(); - distance += pow(diff,2.0); - } // for - - //-> Return the euclidean distance - return sqrt(distance); +double Distance::distanceBetweenSolutions(Solution * solutionI, Solution * solutionJ) +{ + //->Obtain his decision variables + Variable ** decisionVariableI = solutionI->getDecisionVariables(); + Variable ** decisionVariableJ = solutionJ->getDecisionVariables(); + + double diff; //Auxiliar var + double distance = 0.0; + //-> Calculate the Euclidean distance + for (int i = 0; i < solutionI->getNumberOfVariables(); i++) + { + diff = decisionVariableI[i]->getValue() - + decisionVariableJ[i]->getValue(); + distance += pow(diff,2.0); + } // for + + //-> Return the euclidean distance + return sqrt(distance); } // distanceBetweenSolutions @@ -148,17 +159,19 @@ double Distance::distanceBetweenSolutions(Solution * solutionI, Solution * solut * @param solutionJ The second Solution. * @return the distance between solutions in objective space. */ -double Distance::distanceBetweenObjectives(Solution * solutionI, Solution * solutionJ) { - double diff; //Auxiliar var - double distance = 0.0; - //-> Calculate the euclidean distance - for (int nObj = 0; nObj < solutionI->getNumberOfObjectives(); nObj++){ - diff = solutionI->getObjective(nObj) - solutionJ->getObjective(nObj); - distance += pow(diff,2.0); - } // for - - //Return the euclidean distance - return sqrt(distance); +double Distance::distanceBetweenObjectives(Solution * solutionI, Solution * solutionJ) +{ + double diff; //Auxiliar var + double distance = 0.0; + //-> Calculate the euclidean distance + for (int nObj = 0; nObj < solutionI->getNumberOfObjectives(); nObj++) + { + diff = solutionI->getObjective(nObj) - solutionJ->getObjective(nObj); + distance += pow(diff,2.0); + } // for + + //Return the euclidean distance + return sqrt(distance); } // distanceBetweenObjectives @@ -167,58 +180,64 @@ double Distance::distanceBetweenObjectives(Solution * solutionI, Solution * solu * @param solutionSet The SolutionSet. * @param nObjs Number of objectives. */ -void Distance::crowdingDistanceAssignment(SolutionSet * solutionSet, int nObjs) { - int size = solutionSet->size(); - - if (size == 0) - return; - - if (size == 1) { - solutionSet->get(0)->setCrowdingDistance(std::numeric_limits::max()); - return; - } // if - - if (size == 2) { - solutionSet->get(0)->setCrowdingDistance(std::numeric_limits::max()); - solutionSet->get(1)->setCrowdingDistance(std::numeric_limits::max()); - return; - } // if - - //Use a new SolutionSet to evite alter original solutionSet - SolutionSet * front = new SolutionSet(size); - for (int i = 0; i < size; i++){ - front->add(solutionSet->get(i)); - } - - for (int i = 0; i < size; i++) - front->get(i)->setCrowdingDistance(0.0); - - double objetiveMaxn; - double objetiveMinn; - double distance; - - for (int i = 0; isort(c); - delete c; - objetiveMinn = front->get(0)->getObjective(i); - objetiveMaxn = front->get(front->size()-1)->getObjective(i); - - //Set de crowding distance - front->get(0)->setCrowdingDistance(std::numeric_limits::max()); - front->get(size-1)->setCrowdingDistance(std::numeric_limits::max()); - - for (int j = 1; j < size-1; j++) { - distance = front->get(j+1)->getObjective(i) - front->get(j-1)->getObjective(i); - distance = distance / (objetiveMaxn - objetiveMinn); - distance += front->get(j)->getCrowdingDistance(); - front->get(j)->setCrowdingDistance(distance); +void Distance::crowdingDistanceAssignment(SolutionSet * solutionSet, int nObjs) +{ + int size = solutionSet->size(); + + if (size == 0) + return; + + if (size == 1) + { + solutionSet->get(0)->setCrowdingDistance(std::numeric_limits::max()); + return; + } // if + + if (size == 2) + { + solutionSet->get(0)->setCrowdingDistance(std::numeric_limits::max()); + solutionSet->get(1)->setCrowdingDistance(std::numeric_limits::max()); + return; + } // if + + //Use a new SolutionSet to evite alter original solutionSet + SolutionSet * front = new SolutionSet(size); + for (int i = 0; i < size; i++) + { + front->add(solutionSet->get(i)); + } + + for (int i = 0; i < size; i++) + front->get(i)->setCrowdingDistance(0.0); + + double objetiveMaxn; + double objetiveMinn; + double distance; + + for (int i = 0; isort(c); + delete c; + objetiveMinn = front->get(0)->getObjective(i); + objetiveMaxn = front->get(front->size()-1)->getObjective(i); + + //Set de crowding distance + front->get(0)->setCrowdingDistance(std::numeric_limits::max()); + front->get(size-1)->setCrowdingDistance(std::numeric_limits::max()); + + for (int j = 1; j < size-1; j++) + { + distance = front->get(j+1)->getObjective(i) - front->get(j-1)->getObjective(i); + distance = distance / (objetiveMaxn - objetiveMinn); + distance += front->get(j)->getCrowdingDistance(); + front->get(j)->setCrowdingDistance(distance); + } // for } // for - } // for - front->clear(); - delete front; + front->clear(); + delete front; } // crowdingDistanceAssignment diff --git a/src/util/Distance.h b/src/util/Distance.h index 2ed6d3a..171d227 100644 --- a/src/util/Distance.h +++ b/src/util/Distance.h @@ -35,18 +35,19 @@ using namespace std; /** * This class implements some utilities for calculating distances */ -class Distance { +class Distance +{ public: - Distance(); - double ** distanceMatrix(SolutionSet * solutionSet); - double distanceToSolutionSetInObjectiveSpace(Solution * solution, - SolutionSet * solutionSet); - double distanceToSolutionSetInSolutionSpace(Solution * solution, - SolutionSet * solutionSet); - double distanceBetweenSolutions(Solution * solutionI, Solution * solutionJ); - double distanceBetweenObjectives(Solution * solutionI, Solution * solutionJ); - void crowdingDistanceAssignment(SolutionSet * solutionSet, int nObjs); + Distance(); + double ** distanceMatrix(SolutionSet * solutionSet); + double distanceToSolutionSetInObjectiveSpace(Solution * solution, + SolutionSet * solutionSet); + double distanceToSolutionSetInSolutionSpace(Solution * solution, + SolutionSet * solutionSet); + double distanceBetweenSolutions(Solution * solutionI, Solution * solutionJ); + double distanceBetweenObjectives(Solution * solutionI, Solution * solutionJ); + void crowdingDistanceAssignment(SolutionSet * solutionSet, int nObjs); }; diff --git a/src/util/NonDominatedSolutionList.cpp b/src/util/NonDominatedSolutionList.cpp index ec9fe4d..71079ae 100644 --- a/src/util/NonDominatedSolutionList.cpp +++ b/src/util/NonDominatedSolutionList.cpp @@ -28,10 +28,11 @@ * a Pareto dominance comparator. */ NonDominatedSolutionList::NonDominatedSolutionList() -: SolutionSet() { + : SolutionSet() +{ - dominance = new DominanceComparator(); - equal = new SolutionComparator(); + dominance = new DominanceComparator(); + equal = new SolutionComparator(); } // NonDominatedList @@ -43,10 +44,11 @@ NonDominatedSolutionList::NonDominatedSolutionList() * @param dominance The comparator for dominance checking. */ NonDominatedSolutionList::NonDominatedSolutionList(Comparator *dominance) -: SolutionSet() { + : SolutionSet() +{ - this->dominance = dominance; - this->equal = new SolutionComparator(); + this->dominance = dominance; + this->equal = new SolutionComparator(); } // NonDominatedList @@ -54,10 +56,11 @@ NonDominatedSolutionList::NonDominatedSolutionList(Comparator *dominance) /** * Destructor. */ -NonDominatedSolutionList::~NonDominatedSolutionList() { +NonDominatedSolutionList::~NonDominatedSolutionList() +{ - delete dominance; - delete equal; + delete dominance; + delete equal; } // ~NonDominatedSolutionList @@ -69,33 +72,40 @@ NonDominatedSolutionList::~NonDominatedSolutionList() { * The decision variables can be null if the solution is read from a file; in * that case, the domination tests are omitted */ -bool NonDominatedSolutionList::add(Solution *solution) { - - int i = 0; - Solution * aux; //Store an solution temporally - - while (i < solutionsList_.size()) { - aux = solutionsList_[i]; - int flag = dominance->compare(solution,aux); - - if (flag == -1) { // A solution in the list is dominated by the new one - delete aux; - solutionsList_.erase(solutionsList_.begin()+i); - } else if (flag == 0) { // Non-dominated solutions - /* - flag = equal_->compare(solution,aux); - if (flag == 0) { - return false; // The new solution is in the list - } - */ - i++; - } else if (flag == 1) { // The new solution is dominated - return false; - } - } // while - - //At this point, the solution is inserted into the list - solutionsList_.push_back(solution); - - return true; +bool NonDominatedSolutionList::add(Solution *solution) +{ + + int i = 0; + Solution * aux; //Store an solution temporally + + while (i < solutionsList_.size()) + { + aux = solutionsList_[i]; + int flag = dominance->compare(solution,aux); + + if (flag == -1) // A solution in the list is dominated by the new one + { + delete aux; + solutionsList_.erase(solutionsList_.begin()+i); + } + else if (flag == 0) // Non-dominated solutions + { + /* + flag = equal_->compare(solution,aux); + if (flag == 0) { + return false; // The new solution is in the list + } + */ + i++; + } + else if (flag == 1) // The new solution is dominated + { + return false; + } + } // while + + //At this point, the solution is inserted into the list + solutionsList_.push_back(solution); + + return true; } // add diff --git a/src/util/NonDominatedSolutionList.h b/src/util/NonDominatedSolutionList.h index 4d48694..f55ac06 100644 --- a/src/util/NonDominatedSolutionList.h +++ b/src/util/NonDominatedSolutionList.h @@ -30,18 +30,19 @@ * This class implements an unbound list of non-dominated solutions */ -class NonDominatedSolutionList : public SolutionSet { +class NonDominatedSolutionList : public SolutionSet +{ private: - Comparator * dominance; - Comparator * equal; + Comparator * dominance; + Comparator * equal; public: - NonDominatedSolutionList(); - NonDominatedSolutionList(Comparator *dominance); - ~NonDominatedSolutionList(); + NonDominatedSolutionList(); + NonDominatedSolutionList(Comparator *dominance); + ~NonDominatedSolutionList(); - bool add(Solution *solution); + bool add(Solution *solution); }; // NonDominatedSolutionList diff --git a/src/util/PermutationUtility.cpp b/src/util/PermutationUtility.cpp index 5f67280..4857f9e 100644 --- a/src/util/PermutationUtility.cpp +++ b/src/util/PermutationUtility.cpp @@ -20,35 +20,40 @@ #include -int * PermutationUtility::intPermutation(int length) { +int * PermutationUtility::intPermutation(int length) +{ - int * aux = new int[length]; - int * result = new int[length]; + int * aux = new int[length]; + int * result = new int[length]; - // First, create an array from 0 to length - 1. - // Also is needed to create an random array of size length - for (int i = 0; i < length; i++) { - result[i] = i; - aux[i] = PseudoRandom::randInt(0,length-1); - } // for + // First, create an array from 0 to length - 1. + // Also is needed to create an random array of size length + for (int i = 0; i < length; i++) + { + result[i] = i; + aux[i] = PseudoRandom::randInt(0,length-1); + } // for - // Sort the random array with effect in result, and then we obtain a - // permutation array between 0 and length - 1 - for (int i = 0; i < length; i++) { - for (int j = i + 1; j < length; j++) { - if (aux[i] > aux[j]) { - int tmp; - tmp = aux[i]; - aux[i] = aux[j]; - aux[j] = tmp; - tmp = result[i]; - result[i] = result[j]; - result[j] = tmp; - } // if + // Sort the random array with effect in result, and then we obtain a + // permutation array between 0 and length - 1 + for (int i = 0; i < length; i++) + { + for (int j = i + 1; j < length; j++) + { + if (aux[i] > aux[j]) + { + int tmp; + tmp = aux[i]; + aux[i] = aux[j]; + aux[j] = tmp; + tmp = result[i]; + result[i] = result[j]; + result[j] = tmp; + } // if + } // for } // for - } // for - delete[] aux; + delete[] aux; - return result; + return result; } diff --git a/src/util/PermutationUtility.h b/src/util/PermutationUtility.h index 94bf4ea..2128222 100644 --- a/src/util/PermutationUtility.h +++ b/src/util/PermutationUtility.h @@ -23,10 +23,11 @@ #include -class PermutationUtility { +class PermutationUtility +{ public: - int * intPermutation(int length); + int * intPermutation(int length); }; diff --git a/src/util/PseudoRandom.cpp b/src/util/PseudoRandom.cpp index 488136b..8afe195 100644 --- a/src/util/PseudoRandom.cpp +++ b/src/util/PseudoRandom.cpp @@ -25,18 +25,20 @@ using namespace std; /** - * This file is aimed at defining the interface for the random generator. + * This file is aimed at defining the interface for the random generator. * The idea is that all the random numbers will be generated using a single * random generator which will be accesible throug this interface. **/ RandomGenerator * PseudoRandom::randomGenerator_ = NULL ; -PseudoRandom::PseudoRandom() { - //randomGenerator_ = NULL ; - if (PseudoRandom::randomGenerator_ == NULL) { - PseudoRandom::randomGenerator_ = new RandomGenerator(); - } +PseudoRandom::PseudoRandom() +{ + //randomGenerator_ = NULL ; + if (PseudoRandom::randomGenerator_ == NULL) + { + PseudoRandom::randomGenerator_ = new RandomGenerator(); + } } //static int PseudoRandom::randInt() { @@ -46,25 +48,31 @@ PseudoRandom::PseudoRandom() { // return randomGenerator_->rando //} -double PseudoRandom::randDouble() { - if (PseudoRandom::randomGenerator_ == NULL) { - PseudoRandom::randomGenerator_ = new RandomGenerator(); - } - return PseudoRandom::randomGenerator_->rndreal(0.0,1.0); +double PseudoRandom::randDouble() +{ + if (PseudoRandom::randomGenerator_ == NULL) + { + PseudoRandom::randomGenerator_ = new RandomGenerator(); + } + return PseudoRandom::randomGenerator_->rndreal(0.0,1.0); } -int PseudoRandom::randInt(int minBound, int maxBound) { - if (PseudoRandom::randomGenerator_ == NULL) { - PseudoRandom::randomGenerator_ = new RandomGenerator(); - } - return PseudoRandom::randomGenerator_->rnd(minBound,maxBound); +int PseudoRandom::randInt(int minBound, int maxBound) +{ + if (PseudoRandom::randomGenerator_ == NULL) + { + PseudoRandom::randomGenerator_ = new RandomGenerator(); + } + return PseudoRandom::randomGenerator_->rnd(minBound,maxBound); } -double PseudoRandom::randDouble(double minBound, double maxBound) { - if (PseudoRandom::randomGenerator_ == NULL) { - PseudoRandom::randomGenerator_ = new RandomGenerator(); - } - return PseudoRandom::randomGenerator_->rndreal(minBound,maxBound); +double PseudoRandom::randDouble(double minBound, double maxBound) +{ + if (PseudoRandom::randomGenerator_ == NULL) + { + PseudoRandom::randomGenerator_ = new RandomGenerator(); + } + return PseudoRandom::randomGenerator_->rndreal(minBound,maxBound); } @@ -76,19 +84,22 @@ double PseudoRandom::randDouble(double minBound, double maxBound) { * @param standardDeviation * @return A pseudo random number */ -double PseudoRandom::randNormal(double mean, double standardDeviation) { - double x1, x2, w, y1; - - do { - x1 = 2.0 * randDouble() - 1.0; - x2 = 2.0 * randDouble() - 1.0; - w = x1 * x1 + x2 * x2; - } while ( w >= 1.0); - - w = sqrt( (-2.0 * log(w)) / w ); - y1 = x1 * w; - y1 = y1 * standardDeviation + mean; - return y1; +double PseudoRandom::randNormal(double mean, double standardDeviation) +{ + double x1, x2, w, y1; + + do + { + x1 = 2.0 * randDouble() - 1.0; + x2 = 2.0 * randDouble() - 1.0; + w = x1 * x1 + x2 * x2; + } + while ( w >= 1.0); + + w = sqrt( (-2.0 * log(w)) / w ); + y1 = x1 * w; + y1 = y1 * standardDeviation + mean; + return y1; } @@ -98,31 +109,34 @@ double PseudoRandom::randNormal(double mean, double standardDeviation) { * @param dimension * @return A pseudo random point */ -double * PseudoRandom::randSphere(int dimension) { - int D = dimension ; - double * x = new double[dimension] ; +double * PseudoRandom::randSphere(int dimension) +{ + int D = dimension ; + double * x = new double[dimension] ; - double length = 0 ; - for (int i = 0; i < dimension; i++) - x[i] = 0.0 ; + double length = 0 ; + for (int i = 0; i < dimension; i++) + x[i] = 0.0 ; - // --------- Step 1. Direction + // --------- Step 1. Direction - for (int i = 0; i < D; i++) { - x[i] = randNormal(0, 1) ; - length += length + x[i]*x[i] ; - } + for (int i = 0; i < D; i++) + { + x[i] = randNormal(0, 1) ; + length += length + x[i]*x[i] ; + } - length = sqrt(length) ; + length = sqrt(length) ; - // --------- Step 2. Random radius + // --------- Step 2. Random radius - double r = randDouble(0, 1) ; + double r = randDouble(0, 1) ; - for (int i = 0; i < D; i++) { - x[i]=r*x[i]/length; - } + for (int i = 0; i < D; i++) + { + x[i]=r*x[i]/length; + } - return x ; + return x ; } - + diff --git a/src/util/PseudoRandom.h b/src/util/PseudoRandom.h index 9099bc0..ba08966 100644 --- a/src/util/PseudoRandom.h +++ b/src/util/PseudoRandom.h @@ -28,23 +28,24 @@ #include /** - * This file is aimed at defining the interface for the random generator. + * This file is aimed at defining the interface for the random generator. * The idea is that all the random numbers will be generated using a single * random generator which will be accesible throug this interface. **/ -class PseudoRandom { +class PseudoRandom +{ //private: public: - static RandomGenerator * randomGenerator_; - PseudoRandom(); + static RandomGenerator * randomGenerator_; + PseudoRandom(); public: - static double randDouble();// static int randInt(); - static int randInt(int minBound, int maxBound); - static double randDouble(double minBound, double maxBound); - static double randNormal(double mean, double standardDeviation); - static double * randSphere(int dimension); + static double randDouble();// static int randInt(); + static int randInt(int minBound, int maxBound); + static double randDouble(double minBound, double maxBound); + static double randNormal(double mean, double standardDeviation); + static double * randSphere(int dimension); }; diff --git a/src/util/RandomGenerator.cpp b/src/util/RandomGenerator.cpp index f217d84..3620e41 100644 --- a/src/util/RandomGenerator.cpp +++ b/src/util/RandomGenerator.cpp @@ -31,106 +31,125 @@ using namespace std; * http://www.iitk.ac.in/kangal/codes/nsga2/nsga2-v1.1.tar **/ -RandomGenerator::RandomGenerator() { - srand(time(NULL)); - //srand(0); - //cout << (unsigned)time(0) << endl; - seed_ = ((double) rand() / (double) (RAND_MAX )); - //cout << "Seed value is: " << seed_ << endl; - - // seed_ = RAND_MAX; - // cout << "Seed value is: " << seed_ << endl; - - // seed_ = (double) ((float) (float) seed_ / (float) RAND_MAX); - // cout << "Seed value is: " << seed_ << endl; - - randomize(); +RandomGenerator::RandomGenerator() +{ + srand(time(NULL)); + //srand(0); + //cout << (unsigned)time(0) << endl; + seed_ = ((double) rand() / (double) (RAND_MAX )); + //cout << "Seed value is: " << seed_ << endl; + + // seed_ = RAND_MAX; + // cout << "Seed value is: " << seed_ << endl; + + // seed_ = (double) ((float) (float) seed_ / (float) RAND_MAX); + // cout << "Seed value is: " << seed_ << endl; + + randomize(); } // RandomGenerator -int RandomGenerator::rnd (int low, int high) { - int res; - if (low >= high){ - res = low; - } else { - res = low + (int)(randomperc()*(high-low+1)); - if (res > high){ - res = high; +int RandomGenerator::rnd (int low, int high) +{ + int res; + if (low >= high) + { + res = low; + } + else + { + res = low + (int)(randomperc()*(high-low+1)); + if (res > high) + { + res = high; + } } - } - return (res); + return (res); } -double RandomGenerator::rndreal(double low, double high) { - return (low + (high - low) * randomperc()); +double RandomGenerator::rndreal(double low, double high) +{ + return (low + (high - low) * randomperc()); } -void RandomGenerator::randomize() { - int j1; +void RandomGenerator::randomize() +{ + int j1; - for (j1=0; j1<=54;j1++) { - oldrand_[j1] = .0; - } // for + for (j1=0; j1<=54; j1++) + { + oldrand_[j1] = .0; + } // for + + jrand_ = 0; + warmup_random(seed_); - jrand_ = 0; - warmup_random(seed_); - } // randomize -void RandomGenerator::warmup_random(double seed) { - int j1, i1; - double new_random, prev_random; - oldrand_[54] = seed; - new_random = 0.000000001; - prev_random = seed; - - for (j1=1; j1 <= 54; j1++) { - i1 = (21*j1)%54; - oldrand_[i1] = new_random; - new_random = prev_random - new_random; - - if (new_random < 0.0) { - new_random += 1.0; +void RandomGenerator::warmup_random(double seed) +{ + int j1, i1; + double new_random, prev_random; + oldrand_[54] = seed; + new_random = 0.000000001; + prev_random = seed; + + for (j1=1; j1 <= 54; j1++) + { + i1 = (21*j1)%54; + oldrand_[i1] = new_random; + new_random = prev_random - new_random; + + if (new_random < 0.0) + { + new_random += 1.0; + } + + prev_random = oldrand_[i1]; } - - prev_random = oldrand_[i1]; - } - advance_random(); - advance_random(); - advance_random(); - jrand_ = 0; + advance_random(); + advance_random(); + advance_random(); + jrand_ = 0; - return; + return; } -void RandomGenerator::advance_random() { - int j1; - double new_random; - for(j1=0; j1<24; j1++){ - new_random = oldrand_[j1]-oldrand_[j1+31]; - if(new_random<0.0){ - new_random = new_random+1.0; +void RandomGenerator::advance_random() +{ + int j1; + double new_random; + for(j1=0; j1<24; j1++) + { + new_random = oldrand_[j1]-oldrand_[j1+31]; + if(new_random<0.0) + { + new_random = new_random+1.0; + } + oldrand_[j1] = new_random; } - oldrand_[j1] = new_random; - } - for(j1=24; j1<55; j1++){ - new_random = oldrand_[j1]-oldrand_[j1-24]; - if(new_random<0.0){ - new_random = new_random+1.0; + for(j1=24; j1<55; j1++) + { + new_random = oldrand_[j1]-oldrand_[j1-24]; + if(new_random<0.0) + { + new_random = new_random+1.0; + } + oldrand_[j1] = new_random; } - oldrand_[j1] = new_random; - } } -double RandomGenerator::randomperc() { - jrand_++; - if(jrand_>=55){ - jrand_ = 1; - advance_random(); - } - return oldrand_[jrand_]; +double RandomGenerator::randomperc() +{ + jrand_++; + if(jrand_>=55) + { + jrand_ = 1; + advance_random(); + } + return oldrand_[jrand_]; } diff --git a/src/util/RandomGenerator.h b/src/util/RandomGenerator.h index 0306e28..abd29c8 100644 --- a/src/util/RandomGenerator.h +++ b/src/util/RandomGenerator.h @@ -33,23 +33,24 @@ * http://www.iitk.ac.in/kangal/codes/nsga2/nsga2-v1.1.tar **/ -class RandomGenerator { +class RandomGenerator +{ private: - double seed_; - double oldrand_[55]; - int jrand_; - void randomize(); - void warmup_random(double seed); - void advance_random(); - double randomperc(); - + double seed_; + double oldrand_[55]; + int jrand_; + void randomize(); + void warmup_random(double seed); + void advance_random(); + double randomperc(); + public: - RandomGenerator(void); - ~RandomGenerator(void); - int rnd (int low, int high); - double rndreal(double low, double high); - + RandomGenerator(void); + ~RandomGenerator(void); + int rnd (int low, int high); + double rndreal(double low, double high); + }; // RandomGenerator #endif diff --git a/src/util/Ranking.cpp b/src/util/Ranking.cpp index 32971e8..9d0520b 100644 --- a/src/util/Ranking.cpp +++ b/src/util/Ranking.cpp @@ -39,99 +39,117 @@ * Constructor. * @param solutionSet The SolutionSet to be ranked. */ -Ranking::Ranking (SolutionSet * solutionSet) { - - solutionSet_ = solutionSet; - dominance_ = new DominanceComparator(); - constraint_ = new OverallConstraintViolationComparator(); - - // dominateMe[i] contains the number of solutions dominating i - int * dominateMe = new int[solutionSet_->size()]; - - if (dominateMe == NULL) { - cout << "Fatal Problem: Cannot reserve memory in class Ranking" << endl; - exit(-1); - } - - // iDominate[k] contains the list of solutions dominated by k - vector * iDominate = new vector[solutionSet_->size()]; - - // front[i] contains the list of individuals belonging to the front i - vector * front = new vector[solutionSet_->size()+1]; - - // flagDominate is an auxiliar variable - int flagDominate; - - //-> Fast non dominated sorting algorithm - for (int p = 0; p < solutionSet_->size(); p++) { - dominateMe[p] = 0; - } - - // For all q individuals , calculate if p dominates q or vice versa - for (int p = 0; p < (solutionSet_->size() - 1); p++) { - for (int q = p + 1; q < solutionSet_->size(); q++) { - - flagDominate =constraint_->compare(solutionSet->get(p),solutionSet->get(q)); - if (flagDominate == 0) { - flagDominate =dominance_->compare(solutionSet->get(p),solutionSet->get(q)); - } // if - - if (flagDominate == -1) { - iDominate[p].push_back(q); - dominateMe[q]++; - } else if (flagDominate == 1) { - iDominate[q].push_back(p); - dominateMe[p]++; - } // if - +Ranking::Ranking (SolutionSet * solutionSet) +{ + + solutionSet_ = solutionSet; + dominance_ = new DominanceComparator(); + constraint_ = new OverallConstraintViolationComparator(); + + // dominateMe[i] contains the number of solutions dominating i + int * dominateMe = new int[solutionSet_->size()]; + + if (dominateMe == NULL) + { + cout << "Fatal Problem: Cannot reserve memory in class Ranking" << endl; + exit(-1); + } + + // iDominate[k] contains the list of solutions dominated by k + vector * iDominate = new vector[solutionSet_->size()]; + + // front[i] contains the list of individuals belonging to the front i + vector * front = new vector[solutionSet_->size()+1]; + + // flagDominate is an auxiliar variable + int flagDominate; + + //-> Fast non dominated sorting algorithm + for (int p = 0; p < solutionSet_->size(); p++) + { + dominateMe[p] = 0; + } + + // For all q individuals , calculate if p dominates q or vice versa + for (int p = 0; p < (solutionSet_->size() - 1); p++) + { + for (int q = p + 1; q < solutionSet_->size(); q++) + { + + flagDominate =constraint_->compare(solutionSet->get(p),solutionSet->get(q)); + if (flagDominate == 0) + { + flagDominate =dominance_->compare(solutionSet->get(p),solutionSet->get(q)); + } // if + + if (flagDominate == -1) + { + iDominate[p].push_back(q); + dominateMe[q]++; + } + else if (flagDominate == 1) + { + iDominate[q].push_back(p); + dominateMe[p]++; + } // if + + } // for } // for - } // for - - for (int p = 0; p < solutionSet_->size(); p++) { - // If nobody dominates p, p belongs to the first front - if (dominateMe[p] == 0) { - front[0].push_back(p); - solutionSet_->get(p)->setRank(0); - } // if - - } // for - - // Obtain the rest of fronts - int i = 0; - vector::iterator it1, it2; - while (front[i].size()!=0) { - i++; - for (it1=front[i-1].begin(); it1get(*it2)->setRank(i); + + for (int p = 0; p < solutionSet_->size(); p++) + { + // If nobody dominates p, p belongs to the first front + if (dominateMe[p] == 0) + { + front[0].push_back(p); + solutionSet_->get(p)->setRank(0); } // if - } // for + } // for - } // while - - ranking_ = new SolutionSet*[i]; - if (ranking_ == NULL) { - cout << "Fatal Error: Impossible to reserve memory in Ranking" << endl; - exit(-1); - } - - //0,1,2,....,i-1 are front, then i fronts - - numberOfSubfronts_ = i; - - for (int j = 0; j < i; j++) { - ranking_[j] = new SolutionSet(front[j].size()); - for (it1=front[j].begin(); it1add(new Solution(solutionSet_->get(*it1))); + + // Obtain the rest of fronts + int i = 0; + vector::iterator it1, it2; + while (front[i].size()!=0) + { + i++; + for (it1=front[i-1].begin(); it1get(*it2)->setRank(i); + } // if + } // for + } // for + } // while + + ranking_ = new SolutionSet*[i]; + if (ranking_ == NULL) + { + cout << "Fatal Error: Impossible to reserve memory in Ranking" << endl; + exit(-1); + } + + //0,1,2,....,i-1 are front, then i fronts + + numberOfSubfronts_ = i; + + for (int j = 0; j < i; j++) + { + ranking_[j] = new SolutionSet(front[j].size()); + for (it1=front[j].begin(); it1add(new Solution(solutionSet_->get(*it1))); + } // for } // for - } // for - delete [] dominateMe; - delete [] iDominate; - delete [] front; + delete [] dominateMe; + delete [] iDominate; + delete [] front; } // Ranking @@ -139,13 +157,15 @@ Ranking::Ranking (SolutionSet * solutionSet) { /** * Destructor */ -Ranking::~Ranking() { - for (int i = 0; i < numberOfSubfronts_; i++) { - delete ranking_[i]; - } - delete [] ranking_; - delete dominance_; - delete constraint_; +Ranking::~Ranking() +{ + for (int i = 0; i < numberOfSubfronts_; i++) + { + delete ranking_[i]; + } + delete [] ranking_; + delete dominance_; + delete constraint_; } // ~Ranking @@ -154,14 +174,16 @@ Ranking::~Ranking() { * @param rank The rank * @return Object representing the SolutionSet. */ -SolutionSet * Ranking::getSubfront(int rank) { - return ranking_[rank]; +SolutionSet * Ranking::getSubfront(int rank) +{ + return ranking_[rank]; } // getSubFront /** * Returns the total number of subFronts founds. */ -int Ranking::getNumberOfSubfronts() { - return numberOfSubfronts_; +int Ranking::getNumberOfSubfronts() +{ + return numberOfSubfronts_; } // getNumberOfSubfronts diff --git a/src/util/Ranking.h b/src/util/Ranking.h index a2c33c0..8891f8f 100644 --- a/src/util/Ranking.h +++ b/src/util/Ranking.h @@ -38,20 +38,21 @@ * solutions, subset 1 contains the non-dominated solutions after removing those * belonging to subset 0, and so on. */ -class Ranking { +class Ranking +{ private: - SolutionSet * solutionSet_; - SolutionSet ** ranking_; - int numberOfSubfronts_; - DominanceComparator * dominance_; - OverallConstraintViolationComparator * constraint_; + SolutionSet * solutionSet_; + SolutionSet ** ranking_; + int numberOfSubfronts_; + DominanceComparator * dominance_; + OverallConstraintViolationComparator * constraint_; public: - Ranking (SolutionSet * solutionSet); - ~Ranking(); - SolutionSet * getSubfront(int rank); - int getNumberOfSubfronts(); + Ranking (SolutionSet * solutionSet); + ~Ranking(); + SolutionSet * getSubfront(int rank); + int getNumberOfSubfronts(); }; diff --git a/src/util/archive/AdaptiveGridArchive.cpp b/src/util/archive/AdaptiveGridArchive.cpp index cd0c3cc..ab66624 100644 --- a/src/util/archive/AdaptiveGridArchive.cpp +++ b/src/util/archive/AdaptiveGridArchive.cpp @@ -20,20 +20,21 @@ #include - /** - * Constructor. - * - * @param maxSize The maximum size of the archive - * @param bisections The maximum number of bi-divisions for the adaptive - * grid. - * @param objectives The number of objectives. - */ +/** + * Constructor. + * + * @param maxSize The maximum size of the archive + * @param bisections The maximum number of bi-divisions for the adaptive + * grid. + * @param objectives The number of objectives. + */ AdaptiveGridArchive::AdaptiveGridArchive (int maxSize,int bisections, - int objectives) : Archive(maxSize) { + int objectives) : Archive(maxSize) +{ - maxSize_ = maxSize; - dominance_ = new DominanceComparator(); - grid_ = new AdaptiveGrid(bisections,objectives); + maxSize_ = maxSize; + dominance_ = new DominanceComparator(); + grid_ = new AdaptiveGrid(bisections,objectives); } /** @@ -48,74 +49,88 @@ AdaptiveGridArchive::AdaptiveGridArchive (int maxSize,int bisections, * otherwise. */ -bool AdaptiveGridArchive::add(Solution * solution, int eval) { - int i=0; - Solution * aux; //Store an solution temporally - - while (i < solutionsList_.size()){ - aux = solutionsList_[i]; - int flag = dominance_->compare(solution,aux); - if (flag == -1) { // The Individual to insert dominates other - solutionsList_.erase (solutionsList_.begin()+i); //Delete it from the archive - int location = grid_->location(aux); - if (grid_->getLocationDensity(location) > 1) {//The hypercube contains - grid_->removeSolution(location); //more than one individual - } else { - grid_->updateGrid(this); - } // else - } // if - else if (flag == 1) { // An Individual into the file dominates the - // solution to insert - return false; // The solution will not be inserted - } // else if - i++; - } // while - - // At this point, the solution may be inserted - if (size() == 0){ //The archive is empty - solutionsList_.push_back(solution); - grid_->updateGrid(this); - return true; - } // - - if (size() < maxSize_){ //The archive is not full - grid_->updateGrid(solution,this,eval); // Update the grid if applicable - int location ; - location= grid_->location(solution); // Get the location of the solution - grid_->addSolution(location); // Increment the density of the hypercube - solutionsList_.push_back(solution);// Add the solution to the list - return true; - } // if - - // At this point, the solution has to be inserted and the archive is full - grid_->updateGrid(solution,this,eval); - int location = grid_->location(solution); - if (location == grid_->getMostPopulated()) { // The solution is in the - // most populated hypercube - return false; // Not inserted - } - else { - // Remove an solution from most populated area - i=0; - bool removed = false; - - while (i < solutionsList_.size()){ - if (!removed) { - aux = solutionsList_[i]; - int location2 = grid_->location(aux); - if (location2 == grid_->getMostPopulated()) { - solutionsList_.erase (solutionsList_.begin()+i); - grid_->removeSolution(location2); - } // if - } // if - i++; - } // while - // A solution from most populated hypercube has been removed, - // insert now the solution - grid_->addSolution(location); - solutionsList_.push_back(solution); - } // else - return true; +bool AdaptiveGridArchive::add(Solution * solution, int eval) +{ + int i=0; + Solution * aux; //Store an solution temporally + + while (i < solutionsList_.size()) + { + aux = solutionsList_[i]; + int flag = dominance_->compare(solution,aux); + if (flag == -1) // The Individual to insert dominates other + { + solutionsList_.erase (solutionsList_.begin()+i); //Delete it from the archive + int location = grid_->location(aux); + if (grid_->getLocationDensity(location) > 1) //The hypercube contains + { + grid_->removeSolution(location); //more than one individual + } + else + { + grid_->updateGrid(this); + } // else + } // if + else if (flag == 1) // An Individual into the file dominates the + { + // solution to insert + return false; // The solution will not be inserted + } // else if + i++; + } // while + + // At this point, the solution may be inserted + if (size() == 0) //The archive is empty + { + solutionsList_.push_back(solution); + grid_->updateGrid(this); + return true; + } // + + if (size() < maxSize_) //The archive is not full + { + grid_->updateGrid(solution,this,eval); // Update the grid if applicable + int location ; + location= grid_->location(solution); // Get the location of the solution + grid_->addSolution(location); // Increment the density of the hypercube + solutionsList_.push_back(solution);// Add the solution to the list + return true; + } // if + + // At this point, the solution has to be inserted and the archive is full + grid_->updateGrid(solution,this,eval); + int location = grid_->location(solution); + if (location == grid_->getMostPopulated()) // The solution is in the + { + // most populated hypercube + return false; // Not inserted + } + else + { + // Remove an solution from most populated area + i=0; + bool removed = false; + + while (i < solutionsList_.size()) + { + if (!removed) + { + aux = solutionsList_[i]; + int location2 = grid_->location(aux); + if (location2 == grid_->getMostPopulated()) + { + solutionsList_.erase (solutionsList_.begin()+i); + grid_->removeSolution(location2); + } // if + } // if + i++; + } // while + // A solution from most populated hypercube has been removed, + // insert now the solution + grid_->addSolution(location); + solutionsList_.push_back(solution); + } // else + return true; } // add /** @@ -123,8 +138,9 @@ bool AdaptiveGridArchive::add(Solution * solution, int eval) { * @return the AdaptativeGrid */ -AdaptiveGrid * AdaptiveGridArchive::getGrid() { - return grid_; +AdaptiveGrid * AdaptiveGridArchive::getGrid() +{ + return grid_; } // AdaptativeGrid diff --git a/src/util/archive/AdaptiveGridArchive.h b/src/util/archive/AdaptiveGridArchive.h index d282a7d..33f1998 100644 --- a/src/util/archive/AdaptiveGridArchive.h +++ b/src/util/archive/AdaptiveGridArchive.h @@ -31,28 +31,29 @@ * This class implements an archive based on an adaptive grid used in PAES */ -class AdaptiveGridArchive : public Archive { +class AdaptiveGridArchive : public Archive +{ private: - /** - * Stores the adaptive grid - */ - AdaptiveGrid * grid_; + /** + * Stores the adaptive grid + */ + AdaptiveGrid * grid_; - /** - * Stores the maximum size of the archive - */ - int maxSize_; + /** + * Stores the maximum size of the archive + */ + int maxSize_; - /** - * Stores a Comparator for dominance checking - */ - Comparator * dominance_; + /** + * Stores a Comparator for dominance checking + */ + Comparator * dominance_; public: - AdaptiveGridArchive(int maxSize,int bisections, int objectives); - bool add(Solution * solution, int eval); - AdaptiveGrid * getGrid(); + AdaptiveGridArchive(int maxSize,int bisections, int objectives); + bool add(Solution * solution, int eval); + AdaptiveGrid * getGrid(); }; #endif /* ADAPTIVEGRIDARCHIVE_H_ */ diff --git a/src/util/archive/Archive.cpp b/src/util/archive/Archive.cpp index 6083de5..6b8b1a1 100644 --- a/src/util/archive/Archive.cpp +++ b/src/util/archive/Archive.cpp @@ -30,7 +30,8 @@ /** * Constructor. */ -Archive::Archive(int size) : SolutionSet(size) { - //do nothing. +Archive::Archive(int size) : SolutionSet(size) +{ + //do nothing. } // Archive diff --git a/src/util/archive/Archive.h b/src/util/archive/Archive.h index b10318e..ccdca42 100644 --- a/src/util/archive/Archive.h +++ b/src/util/archive/Archive.h @@ -26,10 +26,11 @@ /** * This class represents the super class for archive objects. */ -class Archive : public SolutionSet { +class Archive : public SolutionSet +{ public: - Archive(int size); + Archive(int size); }; diff --git a/src/util/archive/CrowdingArchive.cpp b/src/util/archive/CrowdingArchive.cpp index 397c328..c2f125d 100644 --- a/src/util/archive/CrowdingArchive.cpp +++ b/src/util/archive/CrowdingArchive.cpp @@ -31,26 +31,28 @@ * @param numberOfObjectives The number of objectives. */ CrowdingArchive::CrowdingArchive(int maxSize, int numberOfObjectives) -: Archive(maxSize) { + : Archive(maxSize) +{ - this->maxSize = maxSize; - this->objectives = numberOfObjectives; - this->dominance = new DominanceComparator(); - this->equals = new EqualSolutions(); - this->crowdingDistance = new CrowdingDistanceComparator(); - this->distance = new Distance(); + this->maxSize = maxSize; + this->objectives = numberOfObjectives; + this->dominance = new DominanceComparator(); + this->equals = new EqualSolutions(); + this->crowdingDistance = new CrowdingDistanceComparator(); + this->distance = new Distance(); } // CrowdingArchive /** * Destructor. */ -CrowdingArchive::~CrowdingArchive() { +CrowdingArchive::~CrowdingArchive() +{ - delete dominance; - delete equals; - delete crowdingDistance; - delete distance; + delete dominance; + delete equals; + delete crowdingDistance; + delete distance; } // ~CrowdingArchive @@ -65,40 +67,52 @@ CrowdingArchive::~CrowdingArchive() { * @return true if the Solution has been inserted, false * otherwise. */ -bool CrowdingArchive::add(Solution *solution){ - int flag = 0; - int i = 0; - Solution * aux; //Store an solution temporally - while (i < solutionsList_.size()){ - aux = solutionsList_[i]; +bool CrowdingArchive::add(Solution *solution) +{ + int flag = 0; + int i = 0; + Solution * aux; //Store an solution temporally + while (i < solutionsList_.size()) + { + aux = solutionsList_[i]; - flag = dominance->compare(solution,aux); - if (flag == 1) { // The solution to add is dominated - return false; // Discard the new solution - } else if (flag == -1) { // A solution in the archive is dominated - // Remove it from the population - delete aux; - solutionsList_.erase (solutionsList_.begin()+i); - } else { - if (equals->compare(aux,solution)==0) { - // There is an equal solution in the population - return false; // Discard the new solution - } // if - i++; + flag = dominance->compare(solution,aux); + if (flag == 1) // The solution to add is dominated + { + return false; // Discard the new solution + } + else if (flag == -1) // A solution in the archive is dominated + { + // Remove it from the population + delete aux; + solutionsList_.erase (solutionsList_.begin()+i); + } + else + { + if (equals->compare(aux,solution)==0) + { + // There is an equal solution in the population + return false; // Discard the new solution + } // if + i++; + } } - } - // Insert the solution into the archive - bool res = true; - solutionsList_.push_back(solution); - if (size() > maxSize) { // The archive is full - distance->crowdingDistanceAssignment(this,objectives); - int indexWorst_ = indexWorst(crowdingDistance); - if (solution == solutionsList_[indexWorst_]) { - res = false; - } else { - delete solutionsList_[indexWorst_]; + // Insert the solution into the archive + bool res = true; + solutionsList_.push_back(solution); + if (size() > maxSize) // The archive is full + { + distance->crowdingDistanceAssignment(this,objectives); + int indexWorst_ = indexWorst(crowdingDistance); + if (solution == solutionsList_[indexWorst_]) + { + res = false; + } + else + { + delete solutionsList_[indexWorst_]; + } + remove(indexWorst_); } - remove(indexWorst_); - } - return res; + return res; } // add diff --git a/src/util/archive/CrowdingArchive.h b/src/util/archive/CrowdingArchive.h index 8f9cde1..c0cc819 100644 --- a/src/util/archive/CrowdingArchive.h +++ b/src/util/archive/CrowdingArchive.h @@ -33,20 +33,21 @@ * This class implements a bounded archive based on crowding distances (as * defined in NSGA-II). */ -class CrowdingArchive : public Archive { +class CrowdingArchive : public Archive +{ private: - int maxSize; - int objectives; - Comparator *dominance; - Comparator *equals; - Comparator *crowdingDistance; - Distance *distance; + int maxSize; + int objectives; + Comparator *dominance; + Comparator *equals; + Comparator *crowdingDistance; + Distance *distance; public: - CrowdingArchive(int maxSize, int numberOfObjectives); - ~CrowdingArchive(); - bool add(Solution *solution); + CrowdingArchive(int maxSize, int numberOfObjectives); + ~CrowdingArchive(); + bool add(Solution *solution); }; diff --git a/src/util/comparators/Comparator.h b/src/util/comparators/Comparator.h index 304a75a..509a07c 100644 --- a/src/util/comparators/Comparator.h +++ b/src/util/comparators/Comparator.h @@ -29,11 +29,12 @@ * @class DominanceComparator * @brief This class is aimed at representing a Solution **/ -class Comparator { +class Comparator +{ public: - virtual ~Comparator(); - virtual int compare(void * one, void * two) = 0; + virtual ~Comparator(); + virtual int compare(void * one, void * two) = 0; }; diff --git a/src/util/comparators/CrowdingComparator.cpp b/src/util/comparators/CrowdingComparator.cpp index 6f7eea3..4d40b15 100644 --- a/src/util/comparators/CrowdingComparator.cpp +++ b/src/util/comparators/CrowdingComparator.cpp @@ -27,16 +27,18 @@ /** * Constructor */ -CrowdingComparator::CrowdingComparator() : Comparator() { - comparator = new RankComparator(); +CrowdingComparator::CrowdingComparator() : Comparator() +{ + comparator = new RankComparator(); } // CrowdingComparator /** * Destructor */ -CrowdingComparator::~CrowdingComparator() { - delete comparator; +CrowdingComparator::~CrowdingComparator() +{ + delete comparator; } // ~CrowdingComparator @@ -47,26 +49,27 @@ CrowdingComparator::~CrowdingComparator() { * @return -1, or 0, or 1 if o1 is less than, equal, or greater than o2, * respectively. **/ -int CrowdingComparator::compare(void *o1, void *o2) { +int CrowdingComparator::compare(void *o1, void *o2) +{ - if (o1 == NULL) - return 1; - else if (o2 == NULL) - return -1; + if (o1 == NULL) + return 1; + else if (o2 == NULL) + return -1; - int flagComparatorRank = comparator->compare(o1,o2); + int flagComparatorRank = comparator->compare(o1,o2); - if (flagComparatorRank != 0) - return flagComparatorRank; + if (flagComparatorRank != 0) + return flagComparatorRank; - /* His rank is equal, then distance crowding comparator */ - double distance1 = ((Solution *) o1)->getCrowdingDistance(); - double distance2 = ((Solution *) o2)->getCrowdingDistance(); - if (distance1 > distance2) - return -1; + /* His rank is equal, then distance crowding comparator */ + double distance1 = ((Solution *) o1)->getCrowdingDistance(); + double distance2 = ((Solution *) o2)->getCrowdingDistance(); + if (distance1 > distance2) + return -1; - if (distance1 < distance2) - return 1; + if (distance1 < distance2) + return 1; - return 0; + return 0; } // compare diff --git a/src/util/comparators/CrowdingComparator.h b/src/util/comparators/CrowdingComparator.h index 3c54f71..1f5d446 100644 --- a/src/util/comparators/CrowdingComparator.h +++ b/src/util/comparators/CrowdingComparator.h @@ -30,15 +30,16 @@ * This class implements a Comparator (a method for comparing * Solution objects) based on the crowding distance, as in NSGA-II. */ -class CrowdingComparator : public Comparator { +class CrowdingComparator : public Comparator +{ private: - Comparator * comparator; + Comparator * comparator; public: - CrowdingComparator(); - ~CrowdingComparator(); - int compare(void * o1, void * o2); + CrowdingComparator(); + ~CrowdingComparator(); + int compare(void * o1, void * o2); }; diff --git a/src/util/comparators/CrowdingDistanceComparator.cpp b/src/util/comparators/CrowdingDistanceComparator.cpp index b969825..377967f 100644 --- a/src/util/comparators/CrowdingDistanceComparator.cpp +++ b/src/util/comparators/CrowdingDistanceComparator.cpp @@ -29,21 +29,22 @@ * @return -1, or 0, or 1 if o1 is less than, equal, or greater than o2, * respectively. **/ -int CrowdingDistanceComparator::compare(void *o1, void *o2) { +int CrowdingDistanceComparator::compare(void *o1, void *o2) +{ - if (o1 == NULL) - return 1; - else if (o2 == NULL) - return -1; + if (o1 == NULL) + return 1; + else if (o2 == NULL) + return -1; - double distance1 = ((Solution *) o1)->getCrowdingDistance(); - double distance2 = ((Solution *) o2)->getCrowdingDistance(); - if (distance1 > distance2) - return -1; + double distance1 = ((Solution *) o1)->getCrowdingDistance(); + double distance2 = ((Solution *) o2)->getCrowdingDistance(); + if (distance1 > distance2) + return -1; - if (distance1 < distance2) - return 1; + if (distance1 < distance2) + return 1; - return 0; + return 0; } // compare diff --git a/src/util/comparators/CrowdingDistanceComparator.h b/src/util/comparators/CrowdingDistanceComparator.h index fa9101a..aa8e2d7 100644 --- a/src/util/comparators/CrowdingDistanceComparator.h +++ b/src/util/comparators/CrowdingDistanceComparator.h @@ -28,12 +28,13 @@ * This class implements a Comparator (a method for comparing * Solution objects) based on the crowding distance, as in NSGA-II. */ -class CrowdingDistanceComparator : public Comparator { +class CrowdingDistanceComparator : public Comparator +{ private: public: - int compare(void * o1, void * o2); + int compare(void * o1, void * o2); }; diff --git a/src/util/comparators/DominanceComparator.cpp b/src/util/comparators/DominanceComparator.cpp index fd35ae9..4c1e441 100644 --- a/src/util/comparators/DominanceComparator.cpp +++ b/src/util/comparators/DominanceComparator.cpp @@ -4,7 +4,7 @@ // Juan J. Durillo // Antonio J. Nebro // Esteban López-Camacho -// +// // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // // This program is free software: you can redistribute it and/or modify @@ -16,7 +16,7 @@ // 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 program. If not, see . @@ -26,7 +26,7 @@ * @class DominanceComparator * @brief This class is aimed at implementing a Dominance comparator. It returns true if solution one dominates to solution two. It returns - false in other case. Author must notice that two solutions are + false in other case. Author must notice that two solutions are non dominated only if: !compare(one,two) = false and !compare(two,one) **/ @@ -34,16 +34,18 @@ /** * Constructor */ -DominanceComparator::DominanceComparator() : Comparator() { - overallConstraintViolationComparator_ = new OverallConstraintViolationComparator(); +DominanceComparator::DominanceComparator() : Comparator() +{ + overallConstraintViolationComparator_ = new OverallConstraintViolationComparator(); } // DominanceComparator /** * Destructor */ -DominanceComparator::~DominanceComparator() { - delete overallConstraintViolationComparator_; +DominanceComparator::~DominanceComparator() +{ + delete overallConstraintViolationComparator_; } // ~DominanceComparator @@ -54,61 +56,73 @@ DominanceComparator::~DominanceComparator() { * @return -1, or 0, or 1 if o1 is less than, equal, or greater than o2, * respectively. **/ -int DominanceComparator::compare(void * o1, void * o2) { - - if (o1==NULL) - return 1; - else if (o2 == NULL) - return -1; - - Solution * one = (Solution *) o1; - Solution * two = (Solution *) o2; - - int dominate1 ; // dominate1 indicates if some objective of solution1 - // dominates the same objective in solution2. dominate2 - int dominate2 ; // is the complementary of dominate1. - - dominate1 = 0 ; - dominate2 = 0 ; - - int flag; //stores the result of the comparison - - if (one->getOverallConstraintViolation()!= - two->getOverallConstraintViolation() && - ((one->getOverallConstraintViolation() < 0) || - (two->getOverallConstraintViolation() < 0))){ - int returnValue = overallConstraintViolationComparator_->compare(one,two); - return returnValue; - } - - // Equal number of violated constraints. Applying a dominance Test then - double value1, value2; - for (int i = 0; i < one->getNumberOfObjectives(); i++) { - value1 = one->getObjective(i); - value2 = two->getObjective(i); - if (value1 < value2) { - flag = -1; - } else if (value1 > value2) { - flag = 1; - } else { - flag = 0; +int DominanceComparator::compare(void * o1, void * o2) +{ + + if (o1==NULL) + return 1; + else if (o2 == NULL) + return -1; + + Solution * one = (Solution *) o1; + Solution * two = (Solution *) o2; + + int dominate1 ; // dominate1 indicates if some objective of solution1 + // dominates the same objective in solution2. dominate2 + int dominate2 ; // is the complementary of dominate1. + + dominate1 = 0 ; + dominate2 = 0 ; + + int flag; //stores the result of the comparison + + if (one->getOverallConstraintViolation()!= + two->getOverallConstraintViolation() && + ((one->getOverallConstraintViolation() < 0) || + (two->getOverallConstraintViolation() < 0))) + { + int returnValue = overallConstraintViolationComparator_->compare(one,two); + return returnValue; } - if (flag == -1) { - dominate1 = 1; + // Equal number of violated constraints. Applying a dominance Test then + double value1, value2; + for (int i = 0; i < one->getNumberOfObjectives(); i++) + { + value1 = one->getObjective(i); + value2 = two->getObjective(i); + if (value1 < value2) + { + flag = -1; + } + else if (value1 > value2) + { + flag = 1; + } + else + { + flag = 0; + } + + if (flag == -1) + { + dominate1 = 1; + } + + if (flag == 1) + { + dominate2 = 1; + } } - if (flag == 1) { - dominate2 = 1; + if (dominate1 == dominate2) + { + return 0; //No one dominate the other + } + if (dominate1 == 1) + { + return -1; // solution1 dominate } - } - - if (dominate1 == dominate2) { - return 0; //No one dominate the other - } - if (dominate1 == 1) { - return -1; // solution1 dominate - } - return 1; // solution2 dominate + return 1; // solution2 dominate } // compare diff --git a/src/util/comparators/DominanceComparator.h b/src/util/comparators/DominanceComparator.h index f68a6bb..d52ac05 100644 --- a/src/util/comparators/DominanceComparator.h +++ b/src/util/comparators/DominanceComparator.h @@ -32,15 +32,16 @@ * Solution objects) based on a constraint violation test + * dominance checking, as in NSGA-II. */ -class DominanceComparator : public Comparator { +class DominanceComparator : public Comparator +{ private: - Comparator * overallConstraintViolationComparator_; + Comparator * overallConstraintViolationComparator_; public: - DominanceComparator(); - ~DominanceComparator(); - int compare(void *one, void *two); + DominanceComparator(); + ~DominanceComparator(); + int compare(void *one, void *two); }; #endif diff --git a/src/util/comparators/EpsilonDominanceComparator.cpp b/src/util/comparators/EpsilonDominanceComparator.cpp index af9859c..a94f86f 100644 --- a/src/util/comparators/EpsilonDominanceComparator.cpp +++ b/src/util/comparators/EpsilonDominanceComparator.cpp @@ -2,7 +2,7 @@ // // Authors: // Esteban López-Camacho -// +// // Copyright (c) 2014 Antonio J. Nebro // // This program is free software: you can redistribute it and/or modify @@ -14,7 +14,7 @@ // 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 program. If not, see . @@ -29,16 +29,18 @@ * Constructor. * @param eta Value for epsilon-dominance. */ -EpsilonDominanceComparator::EpsilonDominanceComparator(double eta) : Comparator() { - eta_ = eta; - overallConstraintViolationComparator_ = new OverallConstraintViolationComparator(); +EpsilonDominanceComparator::EpsilonDominanceComparator(double eta) : Comparator() +{ + eta_ = eta; + overallConstraintViolationComparator_ = new OverallConstraintViolationComparator(); } // EpsilonDominanceComparator /** * Destructor. */ -EpsilonDominanceComparator::~EpsilonDominanceComparator() { - delete overallConstraintViolationComparator_; +EpsilonDominanceComparator::~EpsilonDominanceComparator() +{ + delete overallConstraintViolationComparator_; } // ~EpsilonDominanceComparator /** @@ -48,61 +50,73 @@ EpsilonDominanceComparator::~EpsilonDominanceComparator() { * @return -1, or 0, or 1 if o1 dominates o2, both are * non-dominated, or o1 is dominated by o2, respectively. */ -int EpsilonDominanceComparator::compare(void *o1, void *o2) { - - if (o1==NULL) - return 1; - else if (o2 == NULL) - return -1; - - Solution * solution1 = (Solution *) o1; - Solution * solution2 = (Solution *) o2; - - int dominate1 ; // dominate1 indicates if some objective of solution1 - // dominates the same objective in solution2. dominate2 - int dominate2 ; // is the complementary of dominate1. - - dominate1 = 0 ; - dominate2 = 0 ; - - int flag; //stores the result of the comparison - - flag = overallConstraintViolationComparator_->compare(solution1,solution2); - - if (flag != 0) { - return flag; - } - - // Equal number of violated constraints. Applying a dominance Test then - double value1, value2; - for (int i = 0; i < solution1->getNumberOfObjectives(); i++) { - value1 = solution1->getObjective(i); - value2 = solution2->getObjective(i); - - //Objetive implements comparable!!! - if (value1/(1 + eta_) < value2) { - flag = -1; - } else if (value1/(1 + eta_) > value2) { - flag = 1; - } else { - flag = 0; +int EpsilonDominanceComparator::compare(void *o1, void *o2) +{ + + if (o1==NULL) + return 1; + else if (o2 == NULL) + return -1; + + Solution * solution1 = (Solution *) o1; + Solution * solution2 = (Solution *) o2; + + int dominate1 ; // dominate1 indicates if some objective of solution1 + // dominates the same objective in solution2. dominate2 + int dominate2 ; // is the complementary of dominate1. + + dominate1 = 0 ; + dominate2 = 0 ; + + int flag; //stores the result of the comparison + + flag = overallConstraintViolationComparator_->compare(solution1,solution2); + + if (flag != 0) + { + return flag; } - if (flag == -1) { - dominate1 = 1; + // Equal number of violated constraints. Applying a dominance Test then + double value1, value2; + for (int i = 0; i < solution1->getNumberOfObjectives(); i++) + { + value1 = solution1->getObjective(i); + value2 = solution2->getObjective(i); + + //Objetive implements comparable!!! + if (value1/(1 + eta_) < value2) + { + flag = -1; + } + else if (value1/(1 + eta_) > value2) + { + flag = 1; + } + else + { + flag = 0; + } + + if (flag == -1) + { + dominate1 = 1; + } + + if (flag == 1) + { + dominate2 = 1; + } } - if (flag == 1) { - dominate2 = 1; + if (dominate1 == dominate2) + { + return 0; //No one dominates the other + } + if (dominate1 == 1) + { + return -1; // solution1 dominates } - } - - if (dominate1 == dominate2) { - return 0; //No one dominates the other - } - if (dominate1 == 1) { - return -1; // solution1 dominates - } - return 1; // solution2 dominates + return 1; // solution2 dominates } // compare diff --git a/src/util/comparators/EpsilonDominanceComparator.h b/src/util/comparators/EpsilonDominanceComparator.h index c9dabe0..d0c466b 100644 --- a/src/util/comparators/EpsilonDominanceComparator.h +++ b/src/util/comparators/EpsilonDominanceComparator.h @@ -29,41 +29,42 @@ * This class implements a Comparator (a method for comparing * Solution objects) based on epsilon dominance. */ -class EpsilonDominanceComparator : public Comparator { +class EpsilonDominanceComparator : public Comparator +{ private: - /** - * Stores the value of eta, needed for epsilon-dominance. - */ - double eta_; + /** + * Stores the value of eta, needed for epsilon-dominance. + */ + double eta_; - /** - * Stores a comparator for check the OverallConstraintComparator - */ - Comparator *overallConstraintViolationComparator_; + /** + * Stores a comparator for check the OverallConstraintComparator + */ + Comparator *overallConstraintViolationComparator_; public: - /** - * Constructor. - * @param eta Value for epsilon-dominance. - */ - EpsilonDominanceComparator(double eta); + /** + * Constructor. + * @param eta Value for epsilon-dominance. + */ + EpsilonDominanceComparator(double eta); - /** - * Destructor. - */ - ~EpsilonDominanceComparator(); + /** + * Destructor. + */ + ~EpsilonDominanceComparator(); - /** - * Compares two solutions. - * @param o1 Object representing the first Solution. - * @param o1 Object representing the second Solution. - * @return -1, or 0, or 1 if o1 dominates o2, both are - * non-dominated, or o1 is dominated by o2, respectively. - */ - int compare(void *o1, void *o2); + /** + * Compares two solutions. + * @param o1 Object representing the first Solution. + * @param o1 Object representing the second Solution. + * @return -1, or 0, or 1 if o1 dominates o2, both are + * non-dominated, or o1 is dominated by o2, respectively. + */ + int compare(void *o1, void *o2); }; #endif diff --git a/src/util/comparators/EpsilonObjectiveComparator.cpp b/src/util/comparators/EpsilonObjectiveComparator.cpp index 5c675e2..dfede8d 100644 --- a/src/util/comparators/EpsilonObjectiveComparator.cpp +++ b/src/util/comparators/EpsilonObjectiveComparator.cpp @@ -31,9 +31,10 @@ * @param nObj Index of the objective to compare. * @param eta Value for epsilon-dominance. */ -EpsilonObjectiveComparator::EpsilonObjectiveComparator(int nObj, double eta) : Comparator() { - objective_ = nObj; - eta_ = eta; +EpsilonObjectiveComparator::EpsilonObjectiveComparator(int nObj, double eta) : Comparator() +{ + objective_ = nObj; + eta_ = eta; } // EpsilonObjectiveComparator @@ -44,23 +45,29 @@ EpsilonObjectiveComparator::EpsilonObjectiveComparator(int nObj, double eta) : C * @return -1, or 0, or 1 if o1 is less than, equal, or greater than o2, * respectively. */ -int EpsilonObjectiveComparator::compare(void *o1, void *o2) { +int EpsilonObjectiveComparator::compare(void *o1, void *o2) +{ - if (o1==NULL) - return 1; - else if (o2 == NULL) - return -1; + if (o1==NULL) + return 1; + else if (o2 == NULL) + return -1; - double objetive1 = ((Solution *) o1)->getObjective(objective_); - double objetive2 = ((Solution *) o2)->getObjective(objective_); + double objetive1 = ((Solution *) o1)->getObjective(objective_); + double objetive2 = ((Solution *) o2)->getObjective(objective_); - //Objetive implements comparable!!! - if (objetive1/(1 + eta_) < objetive2) { - return -1; - } else if (objetive1/(1 + eta_) > objetive2) { - return 1; - } else { - return 0; - } + //Objetive implements comparable!!! + if (objetive1/(1 + eta_) < objetive2) + { + return -1; + } + else if (objetive1/(1 + eta_) > objetive2) + { + return 1; + } + else + { + return 0; + } } // compare diff --git a/src/util/comparators/EpsilonObjectiveComparator.h b/src/util/comparators/EpsilonObjectiveComparator.h index c2c80c4..e41ea8a 100644 --- a/src/util/comparators/EpsilonObjectiveComparator.h +++ b/src/util/comparators/EpsilonObjectiveComparator.h @@ -29,37 +29,38 @@ * Solution objects) based on epsilon dominance over a given * objective function. */ -class EpsilonObjectiveComparator : public Comparator { +class EpsilonObjectiveComparator : public Comparator +{ private: - /** - * Stores the objective index to compare - */ - int objective_; + /** + * Stores the objective index to compare + */ + int objective_; - /** - * Stores the eta value for epsilon-dominance - */ - double eta_; + /** + * Stores the eta value for epsilon-dominance + */ + double eta_; public: - /** - * Constructor. - * @param nObj Index of the objective to compare. - * @param eta Value for epsilon-dominance. - */ - EpsilonObjectiveComparator(int nObj, double eta); + /** + * Constructor. + * @param nObj Index of the objective to compare. + * @param eta Value for epsilon-dominance. + */ + EpsilonObjectiveComparator(int nObj, double eta); - /** - * Compares two solutions. - * @param o1 Object representing the first Solution. - * @param o2 Object representing the second Solution. - * @return -1, or 0, or 1 if o1 is less than, equal, or greater than o2, - * respectively. - */ - int compare(void *one, void *two); + /** + * Compares two solutions. + * @param o1 Object representing the first Solution. + * @param o2 Object representing the second Solution. + * @return -1, or 0, or 1 if o1 is less than, equal, or greater than o2, + * respectively. + */ + int compare(void *one, void *two); }; #endif diff --git a/src/util/comparators/EqualSolutions.cpp b/src/util/comparators/EqualSolutions.cpp index be74eca..140f7c5 100644 --- a/src/util/comparators/EqualSolutions.cpp +++ b/src/util/comparators/EqualSolutions.cpp @@ -38,59 +38,72 @@ * and solution2 are equals, or solution1 is greater than solution2, * respectively. */ -int EqualSolutions::compare(void * o1, void * o2) { - - if (o1==NULL) - return 1; - else if (o2 == NULL) - return -1; - - int dominate1 ; // dominate1 indicates if some objective of solution1 - // dominates the same objective in solution2. dominate2 - int dominate2 ; // is the complementary of dominate1. - - dominate1 = 0 ; - dominate2 = 0 ; - - Solution * solution1 = (Solution *) o1; - Solution * solution2 = (Solution *) o2; - - int flag; - double value1, value2; - for (int i = 0; i < solution1->getNumberOfObjectives(); i++) { - Comparator * c = new ObjectiveComparator(i); - flag = c->compare(solution1,solution2); - delete c; - value1 = solution1->getObjective(i); - value2 = solution2->getObjective(i); - - if (value1 < value2) { - flag = -1; - } else if (value1 > value2) { - flag = 1; - } else { - flag = 0; +int EqualSolutions::compare(void * o1, void * o2) +{ + + if (o1==NULL) + return 1; + else if (o2 == NULL) + return -1; + + int dominate1 ; // dominate1 indicates if some objective of solution1 + // dominates the same objective in solution2. dominate2 + int dominate2 ; // is the complementary of dominate1. + + dominate1 = 0 ; + dominate2 = 0 ; + + Solution * solution1 = (Solution *) o1; + Solution * solution2 = (Solution *) o2; + + int flag; + double value1, value2; + for (int i = 0; i < solution1->getNumberOfObjectives(); i++) + { + Comparator * c = new ObjectiveComparator(i); + flag = c->compare(solution1,solution2); + delete c; + value1 = solution1->getObjective(i); + value2 = solution2->getObjective(i); + + if (value1 < value2) + { + flag = -1; + } + else if (value1 > value2) + { + flag = 1; + } + else + { + flag = 0; + } + + if (flag == -1) + { + dominate1 = 1; + } + + if (flag == 1) + { + dominate2 = 1; + } } - if (flag == -1) { - dominate1 = 1; + if (dominate1== 0 && dominate2 ==0) + { + return 0; //No one dominate the other } - if (flag == 1) { - dominate2 = 1; + if (dominate1 == 1) + { + return -1; // solution1 dominate + } + else if (dominate2 == 1) + { + return 1; // solution2 dominate } - } - - if (dominate1== 0 && dominate2 ==0) { - return 0; //No one dominate the other - } - - if (dominate1 == 1) { - return -1; // solution1 dominate - } else if (dominate2 == 1) { - return 1; // solution2 dominate - } - return 2; + return 2; } // compare diff --git a/src/util/comparators/EqualSolutions.h b/src/util/comparators/EqualSolutions.h index 32991b7..a3bcf75 100644 --- a/src/util/comparators/EqualSolutions.h +++ b/src/util/comparators/EqualSolutions.h @@ -31,10 +31,11 @@ * equal or not. A dominance test is applied to decide about what solution * is the best. */ -class EqualSolutions : public Comparator { +class EqualSolutions : public Comparator +{ public: - int compare(void *solution1, void *solution2); + int compare(void *solution1, void *solution2); }; #endif diff --git a/src/util/comparators/ObjectiveComparator.cpp b/src/util/comparators/ObjectiveComparator.cpp index f9cc5fc..9f4aaa6 100644 --- a/src/util/comparators/ObjectiveComparator.cpp +++ b/src/util/comparators/ObjectiveComparator.cpp @@ -26,9 +26,10 @@ * Constructor. * @param nObj The index of the objective to compare */ -ObjectiveComparator::ObjectiveComparator(int nObj) { - this->nObj = nObj; - ascendingOrder_ = true; +ObjectiveComparator::ObjectiveComparator(int nObj) +{ + this->nObj = nObj; + ascendingOrder_ = true; } // ObjectiveComparator /** @@ -36,9 +37,10 @@ ObjectiveComparator::ObjectiveComparator(int nObj) { * @param nObj The index of the objective to compare * @param descendingOrder TRUE if use a descending order, FALSE otherwise */ -ObjectiveComparator::ObjectiveComparator(int nObj, bool descendingOrder) { - this->nObj = nObj; - ascendingOrder_ = !descendingOrder; +ObjectiveComparator::ObjectiveComparator(int nObj, bool descendingOrder) +{ + this->nObj = nObj; + ascendingOrder_ = !descendingOrder; } // ObjectiveComparator /** @@ -48,30 +50,44 @@ ObjectiveComparator::ObjectiveComparator(int nObj, bool descendingOrder) { * @return -1, or 0, or 1 if o1 is less than, equal, or greater than o2, * respectively. **/ -int ObjectiveComparator::compare(void *o1, void *o2) { - if (o1==NULL) - return 1; - else if (o2 == NULL) - return -1; +int ObjectiveComparator::compare(void *o1, void *o2) +{ + if (o1==NULL) + return 1; + else if (o2 == NULL) + return -1; - double objetive1 = ((Solution *) o1)->getObjective(this->nObj); - double objetive2 = ((Solution *) o2)->getObjective(this->nObj); - if (ascendingOrder_) { - if (objetive1 < objetive2) { - return -1; - } else if (objetive1 > objetive2) { - return 1; - } else { - return 0; + double objetive1 = ((Solution *) o1)->getObjective(this->nObj); + double objetive2 = ((Solution *) o2)->getObjective(this->nObj); + if (ascendingOrder_) + { + if (objetive1 < objetive2) + { + return -1; + } + else if (objetive1 > objetive2) + { + return 1; + } + else + { + return 0; + } } - } else { - if (objetive1 < objetive2) { - return 1; - } else if (objetive1 > objetive2) { - return -1; - } else { - return 0; + else + { + if (objetive1 < objetive2) + { + return 1; + } + else if (objetive1 > objetive2) + { + return -1; + } + else + { + return 0; + } } - } } // compare diff --git a/src/util/comparators/ObjectiveComparator.h b/src/util/comparators/ObjectiveComparator.h index 601a4aa..111fd6d 100644 --- a/src/util/comparators/ObjectiveComparator.h +++ b/src/util/comparators/ObjectiveComparator.h @@ -28,16 +28,17 @@ * This class implements a Comparator (a method for comparing * Solution objects) based on a objective values. */ -class ObjectiveComparator : public Comparator { +class ObjectiveComparator : public Comparator +{ private: - int nObj; - bool ascendingOrder_; + int nObj; + bool ascendingOrder_; public: - ObjectiveComparator(int nObj); - ObjectiveComparator(int nObj, bool descendingOrder); - int compare(void * o1, void * o2); + ObjectiveComparator(int nObj); + ObjectiveComparator(int nObj, bool descendingOrder); + int compare(void * o1, void * o2); }; diff --git a/src/util/comparators/OverallConstraintViolationComparator.cpp b/src/util/comparators/OverallConstraintViolationComparator.cpp index 6fec3f0..f42c550 100644 --- a/src/util/comparators/OverallConstraintViolationComparator.cpp +++ b/src/util/comparators/OverallConstraintViolationComparator.cpp @@ -29,25 +29,38 @@ * @return -1, or 0, or 1 if o1 is less than, equal, or greater than o2, * respectively. */ -int OverallConstraintViolationComparator::compare(void *o1, void *o2) { - double overall1, overall2; - overall1 = ((Solution *) o1)->getOverallConstraintViolation(); - overall2 = ((Solution *) o2)->getOverallConstraintViolation(); +int OverallConstraintViolationComparator::compare(void *o1, void *o2) +{ + double overall1, overall2; + overall1 = ((Solution *) o1)->getOverallConstraintViolation(); + overall2 = ((Solution *) o2)->getOverallConstraintViolation(); - if ((overall1 < 0) && (overall2 < 0)) { - if (overall1 > overall2){ - return -1; - } else if (overall2 > overall1){ - return 1; - } else { - return 0; + if ((overall1 < 0) && (overall2 < 0)) + { + if (overall1 > overall2) + { + return -1; + } + else if (overall2 > overall1) + { + return 1; + } + else + { + return 0; + } + } + else if ((overall1 == 0) && (overall2 < 0)) + { + return -1; + } + else if ((overall1 < 0) && (overall2 == 0)) + { + return 1; + } + else + { + return 0; } - } else if ((overall1 == 0) && (overall2 < 0)) { - return -1; - } else if ((overall1 < 0) && (overall2 == 0)) { - return 1; - } else { - return 0; - } } // compare diff --git a/src/util/comparators/OverallConstraintViolationComparator.h b/src/util/comparators/OverallConstraintViolationComparator.h index 6680149..5a1359e 100644 --- a/src/util/comparators/OverallConstraintViolationComparator.h +++ b/src/util/comparators/OverallConstraintViolationComparator.h @@ -29,10 +29,11 @@ * Solution objects) based on the overall constraint violation of * the solucions, as in NSGA-II. */ -class OverallConstraintViolationComparator : public Comparator { +class OverallConstraintViolationComparator : public Comparator +{ public: - int compare(void * o1, void * o2); + int compare(void * o1, void * o2); }; diff --git a/src/util/comparators/RankComparator.cpp b/src/util/comparators/RankComparator.cpp index ec0168f..f3e17a3 100644 --- a/src/util/comparators/RankComparator.cpp +++ b/src/util/comparators/RankComparator.cpp @@ -29,23 +29,24 @@ * @return -1, or 0, or 1 if o1 is less than, equal, or greater than o2, * respectively. */ -int RankComparator::compare(void *o1, void *o2) { +int RankComparator::compare(void *o1, void *o2) +{ - if (o1 == NULL) - return 1; - else if (o2 == NULL) - return -1; + if (o1 == NULL) + return 1; + else if (o2 == NULL) + return -1; - Solution * solution1 = (Solution *) o1; - Solution * solution2 = (Solution *) o2; + Solution * solution1 = (Solution *) o1; + Solution * solution2 = (Solution *) o2; - if (solution1->getRank() < solution2->getRank()) - return -1; + if (solution1->getRank() < solution2->getRank()) + return -1; - if (solution1->getRank() > solution2->getRank()) - return 1; + if (solution1->getRank() > solution2->getRank()) + return 1; - return 0; + return 0; } // compare diff --git a/src/util/comparators/RankComparator.h b/src/util/comparators/RankComparator.h index dcc8609..97d0250 100644 --- a/src/util/comparators/RankComparator.h +++ b/src/util/comparators/RankComparator.h @@ -28,10 +28,11 @@ * This class implements a Comparator (a method for comparing * Solution objects) based on the rank of the solutions. */ -class RankComparator : public Comparator { +class RankComparator : public Comparator +{ public: - int compare(void * o1, void * o2); + int compare(void * o1, void * o2); }; diff --git a/src/util/comparators/SolutionComparator.cpp b/src/util/comparators/SolutionComparator.cpp index 036ee92..1d7ae3b 100644 --- a/src/util/comparators/SolutionComparator.cpp +++ b/src/util/comparators/SolutionComparator.cpp @@ -35,23 +35,25 @@ double SolutionComparator::EPSILON = 1e-10; * @return 0, if both solutions are equals with a certain dissimilarity, -1 * otherwise. **/ -int SolutionComparator::compare(void *o1, void *o2) { +int SolutionComparator::compare(void *o1, void *o2) +{ - Solution * solution1 = (Solution *) o1; - Solution * solution2 = (Solution *) o2; + Solution * solution1 = (Solution *) o1; + Solution * solution2 = (Solution *) o2; - int res = -1; + int res = -1; - if (solution1->getNumberOfVariables() != solution2->getNumberOfVariables()) - return res; + if (solution1->getNumberOfVariables() != solution2->getNumberOfVariables()) + return res; - Distance * d = new Distance(); - if (d->distanceBetweenSolutions(solution1,solution2) < EPSILON) { - res = 0; - } - delete d; + Distance * d = new Distance(); + if (d->distanceBetweenSolutions(solution1,solution2) < EPSILON) + { + res = 0; + } + delete d; - return res; + return res; } // compare diff --git a/src/util/comparators/SolutionComparator.h b/src/util/comparators/SolutionComparator.h index d628456..2bd6442 100644 --- a/src/util/comparators/SolutionComparator.h +++ b/src/util/comparators/SolutionComparator.h @@ -29,13 +29,14 @@ * This class implements a Comparator (a method for comparing * Solution objects) based on the values of the variables. */ -class SolutionComparator : public Comparator { +class SolutionComparator : public Comparator +{ private: - static double EPSILON; + static double EPSILON; public: - int compare(void * o1, void * o2); + int compare(void * o1, void * o2); }; // SolutionComparator diff --git a/src/util/wrapper/XReal.cpp b/src/util/wrapper/XReal.cpp index 720072b..ce8dafe 100644 --- a/src/util/wrapper/XReal.cpp +++ b/src/util/wrapper/XReal.cpp @@ -27,7 +27,8 @@ /** * Constructor */ -XReal::XReal() { +XReal::XReal() +{ } // Constructor @@ -35,9 +36,10 @@ XReal::XReal() { * Constructor * @param solution */ -XReal::XReal(Solution * solution) { - type_ = solution->getType(); - solution_ = solution; +XReal::XReal(Solution * solution) +{ + type_ = solution->getType(); + solution_ = solution; } @@ -47,20 +49,24 @@ XReal::XReal(Solution * solution) { * @return The value of the variable * @throws JMException */ -double XReal::getValue(int index) { - if ((typeid(*type_) == typeid(RealSolutionType)) || - (typeid(*type_) == typeid(BinaryRealSolutionType))){ - return solution_->getDecisionVariables()[index]->getValue(); - } - else if (typeid(*type_) == typeid(ArrayRealSolutionType)) { - return ((ArrayReal*)(solution_->getDecisionVariables()[0]))->array_[index]; - } - else { - cout << "ERROR GRAVE: solution type " - << typeid(*type_).name() << " invalid" << endl; - exit(-1); - } - return 0.0; +double XReal::getValue(int index) +{ + if ((typeid(*type_) == typeid(RealSolutionType)) || + (typeid(*type_) == typeid(BinaryRealSolutionType))) + { + return solution_->getDecisionVariables()[index]->getValue(); + } + else if (typeid(*type_) == typeid(ArrayRealSolutionType)) + { + return ((ArrayReal*)(solution_->getDecisionVariables()[0]))->array_[index]; + } + else + { + cout << "ERROR GRAVE: solution type " + << typeid(*type_).name() << " invalid" << endl; + exit(-1); + } + return 0.0; } // getValue @@ -70,19 +76,23 @@ double XReal::getValue(int index) { * @param value Value to be assigned * @throws JMException */ -void XReal::setValue(int index, double value) { - if ((typeid(*type_) == typeid(RealSolutionType)) || - (typeid(*type_) == typeid(BinaryRealSolutionType))){ - solution_->getDecisionVariables()[index]->setValue(value); - } - else if (typeid(*type_) == typeid(ArrayRealSolutionType)) { - ((ArrayReal*)(solution_->getDecisionVariables()[0]))->array_[index]=value; - } - else { - cout << "ERROR GRAVE: solution type " - << typeid(*type_).name() << " invalid" << endl; - exit(-1); - } +void XReal::setValue(int index, double value) +{ + if ((typeid(*type_) == typeid(RealSolutionType)) || + (typeid(*type_) == typeid(BinaryRealSolutionType))) + { + solution_->getDecisionVariables()[index]->setValue(value); + } + else if (typeid(*type_) == typeid(ArrayRealSolutionType)) + { + ((ArrayReal*)(solution_->getDecisionVariables()[0]))->array_[index]=value; + } + else + { + cout << "ERROR GRAVE: solution type " + << typeid(*type_).name() << " invalid" << endl; + exit(-1); + } } // setValue @@ -92,18 +102,20 @@ void XReal::setValue(int index, double value) { * @return The lower bound of the variable * @throws JMException */ -double XReal::getLowerBound(int index) { - if ((typeid(*type_) == typeid(RealSolutionType)) || - (typeid(*type_) == typeid(BinaryRealSolutionType))) - return solution_->getDecisionVariables()[index]->getLowerBound(); - else if (typeid(*type_) == typeid(ArrayRealSolutionType)) - return ((ArrayReal*)(solution_->getDecisionVariables()[0]))->getLowerBound(index); - else { - cout << "ERROR GRAVE: solution type " - << typeid(*type_).name() << " invalid" << endl; - exit(-1); - } - return 0.0; +double XReal::getLowerBound(int index) +{ + if ((typeid(*type_) == typeid(RealSolutionType)) || + (typeid(*type_) == typeid(BinaryRealSolutionType))) + return solution_->getDecisionVariables()[index]->getLowerBound(); + else if (typeid(*type_) == typeid(ArrayRealSolutionType)) + return ((ArrayReal*)(solution_->getDecisionVariables()[0]))->getLowerBound(index); + else + { + cout << "ERROR GRAVE: solution type " + << typeid(*type_).name() << " invalid" << endl; + exit(-1); + } + return 0.0; } // getLowerBound @@ -113,18 +125,20 @@ double XReal::getLowerBound(int index) { * @return The upper bound of the variable * @throws JMException */ -double XReal::getUpperBound(int index) { - if ((typeid(*type_) == typeid(RealSolutionType)) || - (typeid(*type_) == typeid(BinaryRealSolutionType))) - return solution_->getDecisionVariables()[index]->getUpperBound(); - else if (typeid(*type_) == typeid(ArrayRealSolutionType)) - return ((ArrayReal*)(solution_->getDecisionVariables()[0]))->getUpperBound(index); - else { - cout << "ERROR GRAVE: solution type " - << typeid(*type_).name() << " invalid" << endl; - exit(-1); - } - return 0.0; +double XReal::getUpperBound(int index) +{ + if ((typeid(*type_) == typeid(RealSolutionType)) || + (typeid(*type_) == typeid(BinaryRealSolutionType))) + return solution_->getDecisionVariables()[index]->getUpperBound(); + else if (typeid(*type_) == typeid(ArrayRealSolutionType)) + return ((ArrayReal*)(solution_->getDecisionVariables()[0]))->getUpperBound(index); + else + { + cout << "ERROR GRAVE: solution type " + << typeid(*type_).name() << " invalid" << endl; + exit(-1); + } + return 0.0; } // getUpperBound @@ -132,19 +146,21 @@ double XReal::getUpperBound(int index) { * Returns the number of variables of the solution * @return */ -int XReal::getNumberOfDecisionVariables() { - if ((typeid(*type_) == typeid(RealSolutionType)) || - (typeid(*type_) == typeid(BinaryRealSolutionType))) - //return solution_->getDecisionVariables().length ; - return solution_->getNumberOfVariables(); - else if (typeid(*type_) == typeid(ArrayRealSolutionType)) - return ((ArrayReal*)(solution_->getDecisionVariables()[0]))->getLength() ; - else { - cout << "ERROR GRAVE: solution type " - << typeid(*type_).name() << " invalid" << endl; - exit(-1); - } - return 0 ; +int XReal::getNumberOfDecisionVariables() +{ + if ((typeid(*type_) == typeid(RealSolutionType)) || + (typeid(*type_) == typeid(BinaryRealSolutionType))) + //return solution_->getDecisionVariables().length ; + return solution_->getNumberOfVariables(); + else if (typeid(*type_) == typeid(ArrayRealSolutionType)) + return ((ArrayReal*)(solution_->getDecisionVariables()[0]))->getLength() ; + else + { + cout << "ERROR GRAVE: solution type " + << typeid(*type_).name() << " invalid" << endl; + exit(-1); + } + return 0 ; } // getNumberOfDecisionVariables @@ -152,21 +168,24 @@ int XReal::getNumberOfDecisionVariables() { * Returns the number of variables of the solution * @return */ -int XReal::size() { - if ((typeid(*type_) == typeid(RealSolutionType)) || - (typeid(*type_) == typeid(BinaryRealSolutionType))) - return solution_->getNumberOfVariables(); - else if (typeid(*type_) == typeid(ArrayRealSolutionType)) - return ((ArrayReal*)(solution_->getDecisionVariables()[0]))->getLength(); - else { - cout << "ERROR GRAVE: solution type " - << typeid(*type_).name() << " invalid" << endl; - exit(-1); - } - return 0 ; +int XReal::size() +{ + if ((typeid(*type_) == typeid(RealSolutionType)) || + (typeid(*type_) == typeid(BinaryRealSolutionType))) + return solution_->getNumberOfVariables(); + else if (typeid(*type_) == typeid(ArrayRealSolutionType)) + return ((ArrayReal*)(solution_->getDecisionVariables()[0]))->getLength(); + else + { + cout << "ERROR GRAVE: solution type " + << typeid(*type_).name() << " invalid" << endl; + exit(-1); + } + return 0 ; } // size -Solution * XReal::getSolution() { - return solution_; +Solution * XReal::getSolution() +{ + return solution_; } // getSolution diff --git a/src/util/wrapper/XReal.h b/src/util/wrapper/XReal.h index dd5526c..5c9899b 100644 --- a/src/util/wrapper/XReal.h +++ b/src/util/wrapper/XReal.h @@ -33,22 +33,23 @@ * This class allows to apply a SBX crossover operator using two parent * solutions. **/ -class XReal { +class XReal +{ public: - XReal(); - XReal(Solution * solution); - double getValue(int index); - void setValue(int index, double value); - double getLowerBound(int index); - double getUpperBound(int index); - int getNumberOfDecisionVariables(); - int size(); - Solution * getSolution(); + XReal(); + XReal(Solution * solution); + double getValue(int index); + void setValue(int index, double value); + double getLowerBound(int index); + double getUpperBound(int index); + int getNumberOfDecisionVariables(); + int size(); + Solution * getSolution(); private: - Solution * solution_; - SolutionType * type_; + Solution * solution_; + SolutionType * type_; }; From 587ba235c76f1a51c48c229b9b64f4d81e4ac0b9 Mon Sep 17 00:00:00 2001 From: Sergio Vieira Date: Thu, 27 Jul 2017 14:34:55 -0300 Subject: [PATCH 05/29] - Adds file headers --- CMakeLists.txt | 10 +++++++++- src/core/CMakeLists.txt | 3 +++ src/encodings/solutionType/CMakeLists.txt | 2 ++ src/encodings/variable/CMakeLists.txt | 2 ++ src/experiments/main/CMakeLists.txt | 2 -- src/experiments/settings/CMakeLists.txt | 2 ++ src/experiments/util/CMakeLists.txt | 2 ++ src/main/CMakeLists.txt | 6 ++++-- src/metaheuristics/gde3/CMakeLists.txt | 2 ++ src/metaheuristics/mochc/CMakeLists.txt | 2 ++ src/metaheuristics/moead/CMakeLists.txt | 2 ++ src/metaheuristics/nsgaII/CMakeLists.txt | 2 ++ src/metaheuristics/omopso/CMakeLists.txt | 2 ++ src/metaheuristics/paes/CMakeLists.txt | 2 ++ .../singleObjective/cmaes/utils/CMakeLists.txt | 2 ++ .../differentialEvolution/CMakeLists.txt | 2 ++ .../singleObjective/geneticAlgorithm/CMakeLists.txt | 2 ++ .../particleSwarmOptimization/CMakeLists.txt | 2 ++ src/metaheuristics/smpso/CMakeLists.txt | 2 ++ src/metaheuristics/smsemoa/CMakeLists.txt | 2 ++ src/operators/crossover/CMakeLists.txt | 2 ++ src/operators/mutation/CMakeLists.txt | 2 ++ src/operators/selection/CMakeLists.txt | 2 ++ src/problems/DTLZ/CMakeLists.txt | 2 ++ src/problems/LZ09/CMakeLists.txt | 2 ++ src/problems/ZDT/CMakeLists.txt | 2 ++ .../singleObjective/cec2005Competition/CMakeLists.txt | 2 ++ src/qualityIndicator/fastHypervolume/CMakeLists.txt | 2 ++ src/qualityIndicator/main/CMakeLists.txt | 2 ++ src/qualityIndicator/util/CMakeLists.txt | 2 ++ src/util/archive/CMakeLists.txt | 2 ++ src/util/comparators/CMakeLists.txt | 2 ++ src/util/wrapper/CMakeLists.txt | 2 ++ 33 files changed, 74 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae6bb5e..99c0e4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,13 @@ macro(LIST_APPEND var) set_property(GLOBAL APPEND PROPERTY SOURCE_LIST "${var}") endmacro(LIST_APPEND) +define_property(GLOBAL PROPERTY HEADER_LIST BRIEF_DOCS "Global list of header code" FULL_DOCS "Global list of header code") +set_property(GLOBAL PROPERTY HEADER_LIST "") + +macro(LIST_APPEND_HEADER var) + set_property(GLOBAL APPEND PROPERTY HEADER_LIST "${var}") +endmacro(LIST_APPEND_HEADER) + include_directories( ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/src/core @@ -56,4 +63,5 @@ include_directories( ) add_subdirectory(${PROJECT_SOURCE_DIR}/src) get_property(my_source_list GLOBAL PROPERTY SOURCE_LIST) -add_library(${PROJECT_NAME} SHARED ${my_source_list}) +get_property(my_header_list GLOBAL PROPERTY HEADER_LIST) +add_library(${PROJECT_NAME} ${my_source_list} ${my_header_list}) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index c384717..ff99a5c 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1,2 +1,5 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) + diff --git a/src/encodings/solutionType/CMakeLists.txt b/src/encodings/solutionType/CMakeLists.txt index c384717..e87499b 100644 --- a/src/encodings/solutionType/CMakeLists.txt +++ b/src/encodings/solutionType/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/encodings/variable/CMakeLists.txt b/src/encodings/variable/CMakeLists.txt index c384717..e87499b 100644 --- a/src/encodings/variable/CMakeLists.txt +++ b/src/encodings/variable/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/experiments/main/CMakeLists.txt b/src/experiments/main/CMakeLists.txt index c384717..e69de29 100644 --- a/src/experiments/main/CMakeLists.txt +++ b/src/experiments/main/CMakeLists.txt @@ -1,2 +0,0 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) diff --git a/src/experiments/settings/CMakeLists.txt b/src/experiments/settings/CMakeLists.txt index c384717..e87499b 100644 --- a/src/experiments/settings/CMakeLists.txt +++ b/src/experiments/settings/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/experiments/util/CMakeLists.txt b/src/experiments/util/CMakeLists.txt index c384717..e87499b 100644 --- a/src/experiments/util/CMakeLists.txt +++ b/src/experiments/util/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt index c384717..e365a04 100644 --- a/src/main/CMakeLists.txt +++ b/src/main/CMakeLists.txt @@ -1,2 +1,4 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) +include_directories(${PROJECT_SOURCE_DIR}/src) +link_directories(${PROJECT_SOURCE_DIR}/src) +add_executable(OMOPSO_main OMOPSO_main.cpp) +target_link_libraries(OMOPSO_main jMetalCpp) diff --git a/src/metaheuristics/gde3/CMakeLists.txt b/src/metaheuristics/gde3/CMakeLists.txt index c384717..e87499b 100644 --- a/src/metaheuristics/gde3/CMakeLists.txt +++ b/src/metaheuristics/gde3/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/metaheuristics/mochc/CMakeLists.txt b/src/metaheuristics/mochc/CMakeLists.txt index c384717..e87499b 100644 --- a/src/metaheuristics/mochc/CMakeLists.txt +++ b/src/metaheuristics/mochc/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/metaheuristics/moead/CMakeLists.txt b/src/metaheuristics/moead/CMakeLists.txt index c384717..e87499b 100644 --- a/src/metaheuristics/moead/CMakeLists.txt +++ b/src/metaheuristics/moead/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/metaheuristics/nsgaII/CMakeLists.txt b/src/metaheuristics/nsgaII/CMakeLists.txt index c384717..e87499b 100644 --- a/src/metaheuristics/nsgaII/CMakeLists.txt +++ b/src/metaheuristics/nsgaII/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/metaheuristics/omopso/CMakeLists.txt b/src/metaheuristics/omopso/CMakeLists.txt index c384717..e87499b 100644 --- a/src/metaheuristics/omopso/CMakeLists.txt +++ b/src/metaheuristics/omopso/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/metaheuristics/paes/CMakeLists.txt b/src/metaheuristics/paes/CMakeLists.txt index c384717..e87499b 100644 --- a/src/metaheuristics/paes/CMakeLists.txt +++ b/src/metaheuristics/paes/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/metaheuristics/singleObjective/cmaes/utils/CMakeLists.txt b/src/metaheuristics/singleObjective/cmaes/utils/CMakeLists.txt index c384717..e87499b 100644 --- a/src/metaheuristics/singleObjective/cmaes/utils/CMakeLists.txt +++ b/src/metaheuristics/singleObjective/cmaes/utils/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/metaheuristics/singleObjective/differentialEvolution/CMakeLists.txt b/src/metaheuristics/singleObjective/differentialEvolution/CMakeLists.txt index c384717..e87499b 100644 --- a/src/metaheuristics/singleObjective/differentialEvolution/CMakeLists.txt +++ b/src/metaheuristics/singleObjective/differentialEvolution/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/metaheuristics/singleObjective/geneticAlgorithm/CMakeLists.txt b/src/metaheuristics/singleObjective/geneticAlgorithm/CMakeLists.txt index c384717..e87499b 100644 --- a/src/metaheuristics/singleObjective/geneticAlgorithm/CMakeLists.txt +++ b/src/metaheuristics/singleObjective/geneticAlgorithm/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/CMakeLists.txt b/src/metaheuristics/singleObjective/particleSwarmOptimization/CMakeLists.txt index c384717..e87499b 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/CMakeLists.txt +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/metaheuristics/smpso/CMakeLists.txt b/src/metaheuristics/smpso/CMakeLists.txt index c384717..e87499b 100644 --- a/src/metaheuristics/smpso/CMakeLists.txt +++ b/src/metaheuristics/smpso/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/metaheuristics/smsemoa/CMakeLists.txt b/src/metaheuristics/smsemoa/CMakeLists.txt index c384717..e87499b 100644 --- a/src/metaheuristics/smsemoa/CMakeLists.txt +++ b/src/metaheuristics/smsemoa/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/operators/crossover/CMakeLists.txt b/src/operators/crossover/CMakeLists.txt index c384717..e87499b 100644 --- a/src/operators/crossover/CMakeLists.txt +++ b/src/operators/crossover/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/operators/mutation/CMakeLists.txt b/src/operators/mutation/CMakeLists.txt index c384717..e87499b 100644 --- a/src/operators/mutation/CMakeLists.txt +++ b/src/operators/mutation/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/operators/selection/CMakeLists.txt b/src/operators/selection/CMakeLists.txt index c384717..e87499b 100644 --- a/src/operators/selection/CMakeLists.txt +++ b/src/operators/selection/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/problems/DTLZ/CMakeLists.txt b/src/problems/DTLZ/CMakeLists.txt index c384717..e87499b 100644 --- a/src/problems/DTLZ/CMakeLists.txt +++ b/src/problems/DTLZ/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/problems/LZ09/CMakeLists.txt b/src/problems/LZ09/CMakeLists.txt index c384717..e87499b 100644 --- a/src/problems/LZ09/CMakeLists.txt +++ b/src/problems/LZ09/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/problems/ZDT/CMakeLists.txt b/src/problems/ZDT/CMakeLists.txt index c384717..e87499b 100644 --- a/src/problems/ZDT/CMakeLists.txt +++ b/src/problems/ZDT/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/problems/singleObjective/cec2005Competition/CMakeLists.txt b/src/problems/singleObjective/cec2005Competition/CMakeLists.txt index c384717..e87499b 100644 --- a/src/problems/singleObjective/cec2005Competition/CMakeLists.txt +++ b/src/problems/singleObjective/cec2005Competition/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/qualityIndicator/fastHypervolume/CMakeLists.txt b/src/qualityIndicator/fastHypervolume/CMakeLists.txt index c384717..e87499b 100644 --- a/src/qualityIndicator/fastHypervolume/CMakeLists.txt +++ b/src/qualityIndicator/fastHypervolume/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/qualityIndicator/main/CMakeLists.txt b/src/qualityIndicator/main/CMakeLists.txt index c384717..ac75eba 100644 --- a/src/qualityIndicator/main/CMakeLists.txt +++ b/src/qualityIndicator/main/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +#file(GLOB HEADERS *.h) +#LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/qualityIndicator/util/CMakeLists.txt b/src/qualityIndicator/util/CMakeLists.txt index c384717..e87499b 100644 --- a/src/qualityIndicator/util/CMakeLists.txt +++ b/src/qualityIndicator/util/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/util/archive/CMakeLists.txt b/src/util/archive/CMakeLists.txt index c384717..e87499b 100644 --- a/src/util/archive/CMakeLists.txt +++ b/src/util/archive/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/util/comparators/CMakeLists.txt b/src/util/comparators/CMakeLists.txt index c384717..e87499b 100644 --- a/src/util/comparators/CMakeLists.txt +++ b/src/util/comparators/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) diff --git a/src/util/wrapper/CMakeLists.txt b/src/util/wrapper/CMakeLists.txt index c384717..e87499b 100644 --- a/src/util/wrapper/CMakeLists.txt +++ b/src/util/wrapper/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB SOURCES *.cpp) LIST_APPEND(${SOURCES}) +file(GLOB HEADERS *.h) +LIST_APPEND_HEADER(${HEADERS}) From 14c8310c0a6ab3efb2ed433748b137e75ec3a617 Mon Sep 17 00:00:00 2001 From: Sergio Vieira Date: Thu, 27 Jul 2017 15:58:28 -0300 Subject: [PATCH 06/29] - Updates cmake files - Code improvements --- CMakeLists.txt | 11 +++++++++++ src/core/CMakeLists.txt | 8 +++----- src/encodings/solutionType/CMakeLists.txt | 7 +++---- src/encodings/variable/CMakeLists.txt | 7 +++---- src/experiments/CMakeLists.txt | 3 +++ src/experiments/ExperimentExecution.cpp | 1 + src/experiments/settings/CMakeLists.txt | 7 +++---- src/experiments/util/CMakeLists.txt | 7 +++---- src/metaheuristics/gde3/CMakeLists.txt | 7 +++---- src/metaheuristics/mochc/CMakeLists.txt | 7 +++---- src/metaheuristics/moead/CMakeLists.txt | 7 +++---- src/metaheuristics/nsgaII/CMakeLists.txt | 7 +++---- src/metaheuristics/omopso/CMakeLists.txt | 7 +++---- src/metaheuristics/paes/CMakeLists.txt | 7 +++---- .../singleObjective/cmaes/CMakeLists.txt | 3 +++ .../singleObjective/cmaes/utils/CMakeLists.txt | 7 +++---- .../differentialEvolution/CMakeLists.txt | 7 +++---- .../singleObjective/geneticAlgorithm/CMakeLists.txt | 7 +++---- .../particleSwarmOptimization/CMakeLists.txt | 7 +++---- src/metaheuristics/smpso/CMakeLists.txt | 7 +++---- src/metaheuristics/smsemoa/CMakeLists.txt | 7 +++---- src/operators/crossover/CMakeLists.txt | 7 +++---- src/operators/mutation/CMakeLists.txt | 7 +++---- src/operators/mutation/PolynomialMutation.cpp | 2 +- src/operators/selection/CMakeLists.txt | 7 +++---- src/problems/CMakeLists.txt | 3 +++ src/problems/DTLZ/CMakeLists.txt | 7 +++---- src/problems/LZ09/CMakeLists.txt | 7 +++---- src/problems/ZDT/CMakeLists.txt | 7 +++---- src/problems/singleObjective/CMakeLists.txt | 3 +++ .../singleObjective/cec2005Competition/CMakeLists.txt | 7 +++---- src/qualityIndicator/CMakeLists.txt | 3 +++ src/qualityIndicator/fastHypervolume/CMakeLists.txt | 7 +++---- src/qualityIndicator/main/CMakeLists.txt | 7 +++---- src/qualityIndicator/util/CMakeLists.txt | 7 +++---- src/util/CMakeLists.txt | 3 +++ src/util/archive/CMakeLists.txt | 7 +++---- src/util/comparators/CMakeLists.txt | 7 +++---- src/util/wrapper/CMakeLists.txt | 7 +++---- 39 files changed, 121 insertions(+), 122 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 99c0e4c..018e88f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,17 @@ cmake_minimum_required(VERSION 3.6) project(jMetalCpp) set(CMAKE_CXX_STANDARD 11) +function (ListToString result delim) + list(GET ARGV 2 temp) + math(EXPR N "${ARGC}-1") + foreach(IDX RANGE 3 ${N}) + list(GET ARGV ${IDX} STR) + set(temp "${temp}${delim}${STR}") + endforeach() + set(${result} "${temp}" PARENT_SCOPE) +endfunction(ListToString) + + define_property(GLOBAL PROPERTY SOURCE_LIST BRIEF_DOCS "Global list of source code" FULL_DOCS "Global list of source code") set_property(GLOBAL PROPERTY SOURCE_LIST "") diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index ff99a5c..ca3372a 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1,5 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) - +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") diff --git a/src/encodings/solutionType/CMakeLists.txt b/src/encodings/solutionType/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/encodings/solutionType/CMakeLists.txt +++ b/src/encodings/solutionType/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/encodings/variable/CMakeLists.txt b/src/encodings/variable/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/encodings/variable/CMakeLists.txt +++ b/src/encodings/variable/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/experiments/CMakeLists.txt b/src/experiments/CMakeLists.txt index 5603ab0..762c9c8 100644 --- a/src/experiments/CMakeLists.txt +++ b/src/experiments/CMakeLists.txt @@ -1,3 +1,6 @@ +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") add_subdirectory(main) add_subdirectory(settings) add_subdirectory(util) diff --git a/src/experiments/ExperimentExecution.cpp b/src/experiments/ExperimentExecution.cpp index fe2c0a7..f55817b 100644 --- a/src/experiments/ExperimentExecution.cpp +++ b/src/experiments/ExperimentExecution.cpp @@ -27,6 +27,7 @@ void* executeRun(void* ctx) RunExperiment* cptr = (RunExperiment*)ctx; cptr->run(); //pthread_exit(0); + return nullptr; } // executeRun diff --git a/src/experiments/settings/CMakeLists.txt b/src/experiments/settings/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/experiments/settings/CMakeLists.txt +++ b/src/experiments/settings/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/experiments/util/CMakeLists.txt b/src/experiments/util/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/experiments/util/CMakeLists.txt +++ b/src/experiments/util/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/metaheuristics/gde3/CMakeLists.txt b/src/metaheuristics/gde3/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/metaheuristics/gde3/CMakeLists.txt +++ b/src/metaheuristics/gde3/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/metaheuristics/mochc/CMakeLists.txt b/src/metaheuristics/mochc/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/metaheuristics/mochc/CMakeLists.txt +++ b/src/metaheuristics/mochc/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/metaheuristics/moead/CMakeLists.txt b/src/metaheuristics/moead/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/metaheuristics/moead/CMakeLists.txt +++ b/src/metaheuristics/moead/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/metaheuristics/nsgaII/CMakeLists.txt b/src/metaheuristics/nsgaII/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/metaheuristics/nsgaII/CMakeLists.txt +++ b/src/metaheuristics/nsgaII/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/metaheuristics/omopso/CMakeLists.txt b/src/metaheuristics/omopso/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/metaheuristics/omopso/CMakeLists.txt +++ b/src/metaheuristics/omopso/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/metaheuristics/paes/CMakeLists.txt b/src/metaheuristics/paes/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/metaheuristics/paes/CMakeLists.txt +++ b/src/metaheuristics/paes/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/metaheuristics/singleObjective/cmaes/CMakeLists.txt b/src/metaheuristics/singleObjective/cmaes/CMakeLists.txt index 47202fc..7122541 100644 --- a/src/metaheuristics/singleObjective/cmaes/CMakeLists.txt +++ b/src/metaheuristics/singleObjective/cmaes/CMakeLists.txt @@ -1 +1,4 @@ +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") add_subdirectory(utils) \ No newline at end of file diff --git a/src/metaheuristics/singleObjective/cmaes/utils/CMakeLists.txt b/src/metaheuristics/singleObjective/cmaes/utils/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/metaheuristics/singleObjective/cmaes/utils/CMakeLists.txt +++ b/src/metaheuristics/singleObjective/cmaes/utils/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/metaheuristics/singleObjective/differentialEvolution/CMakeLists.txt b/src/metaheuristics/singleObjective/differentialEvolution/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/metaheuristics/singleObjective/differentialEvolution/CMakeLists.txt +++ b/src/metaheuristics/singleObjective/differentialEvolution/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/metaheuristics/singleObjective/geneticAlgorithm/CMakeLists.txt b/src/metaheuristics/singleObjective/geneticAlgorithm/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/metaheuristics/singleObjective/geneticAlgorithm/CMakeLists.txt +++ b/src/metaheuristics/singleObjective/geneticAlgorithm/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/CMakeLists.txt b/src/metaheuristics/singleObjective/particleSwarmOptimization/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/CMakeLists.txt +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/metaheuristics/smpso/CMakeLists.txt b/src/metaheuristics/smpso/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/metaheuristics/smpso/CMakeLists.txt +++ b/src/metaheuristics/smpso/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/metaheuristics/smsemoa/CMakeLists.txt b/src/metaheuristics/smsemoa/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/metaheuristics/smsemoa/CMakeLists.txt +++ b/src/metaheuristics/smsemoa/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/operators/crossover/CMakeLists.txt b/src/operators/crossover/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/operators/crossover/CMakeLists.txt +++ b/src/operators/crossover/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/operators/mutation/CMakeLists.txt b/src/operators/mutation/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/operators/mutation/CMakeLists.txt +++ b/src/operators/mutation/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/operators/mutation/PolynomialMutation.cpp b/src/operators/mutation/PolynomialMutation.cpp index 89fdf15..0f72bee 100644 --- a/src/operators/mutation/PolynomialMutation.cpp +++ b/src/operators/mutation/PolynomialMutation.cpp @@ -94,7 +94,7 @@ void * PolynomialMutation::doMutation(double probability, Solution *solution) } // for delete x; - + return nullptr; } // doMutation diff --git a/src/operators/selection/CMakeLists.txt b/src/operators/selection/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/operators/selection/CMakeLists.txt +++ b/src/operators/selection/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/problems/CMakeLists.txt b/src/problems/CMakeLists.txt index 99cd101..9543ef7 100644 --- a/src/problems/CMakeLists.txt +++ b/src/problems/CMakeLists.txt @@ -1,3 +1,6 @@ +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") add_subdirectory(DTLZ) add_subdirectory(LZ09) add_subdirectory(singleObjective) diff --git a/src/problems/DTLZ/CMakeLists.txt b/src/problems/DTLZ/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/problems/DTLZ/CMakeLists.txt +++ b/src/problems/DTLZ/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/problems/LZ09/CMakeLists.txt b/src/problems/LZ09/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/problems/LZ09/CMakeLists.txt +++ b/src/problems/LZ09/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/problems/ZDT/CMakeLists.txt b/src/problems/ZDT/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/problems/ZDT/CMakeLists.txt +++ b/src/problems/ZDT/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/problems/singleObjective/CMakeLists.txt b/src/problems/singleObjective/CMakeLists.txt index 9f4a222..59a3d9c 100644 --- a/src/problems/singleObjective/CMakeLists.txt +++ b/src/problems/singleObjective/CMakeLists.txt @@ -1 +1,4 @@ +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") add_subdirectory(cec2005Competition) \ No newline at end of file diff --git a/src/problems/singleObjective/cec2005Competition/CMakeLists.txt b/src/problems/singleObjective/cec2005Competition/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/problems/singleObjective/cec2005Competition/CMakeLists.txt +++ b/src/problems/singleObjective/cec2005Competition/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/qualityIndicator/CMakeLists.txt b/src/qualityIndicator/CMakeLists.txt index 0b76022..ef24757 100644 --- a/src/qualityIndicator/CMakeLists.txt +++ b/src/qualityIndicator/CMakeLists.txt @@ -1,3 +1,6 @@ +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") add_subdirectory(fastHypervolume) add_subdirectory(main) add_subdirectory(util) \ No newline at end of file diff --git a/src/qualityIndicator/fastHypervolume/CMakeLists.txt b/src/qualityIndicator/fastHypervolume/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/qualityIndicator/fastHypervolume/CMakeLists.txt +++ b/src/qualityIndicator/fastHypervolume/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/qualityIndicator/main/CMakeLists.txt b/src/qualityIndicator/main/CMakeLists.txt index ac75eba..294ec59 100644 --- a/src/qualityIndicator/main/CMakeLists.txt +++ b/src/qualityIndicator/main/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -#file(GLOB HEADERS *.h) -#LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/qualityIndicator/util/CMakeLists.txt b/src/qualityIndicator/util/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/qualityIndicator/util/CMakeLists.txt +++ b/src/qualityIndicator/util/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index f8d4f34..e33bba1 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -1,3 +1,6 @@ +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") add_subdirectory(archive) add_subdirectory(comparators) add_subdirectory(wrapper) \ No newline at end of file diff --git a/src/util/archive/CMakeLists.txt b/src/util/archive/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/util/archive/CMakeLists.txt +++ b/src/util/archive/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/util/comparators/CMakeLists.txt b/src/util/comparators/CMakeLists.txt index e87499b..294ec59 100644 --- a/src/util/comparators/CMakeLists.txt +++ b/src/util/comparators/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file diff --git a/src/util/wrapper/CMakeLists.txt b/src/util/wrapper/CMakeLists.txt index e87499b..ca3372a 100644 --- a/src/util/wrapper/CMakeLists.txt +++ b/src/util/wrapper/CMakeLists.txt @@ -1,4 +1,3 @@ -file(GLOB SOURCES *.cpp) -LIST_APPEND(${SOURCES}) -file(GLOB HEADERS *.h) -LIST_APPEND_HEADER(${HEADERS}) +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") From d36c57d8678bd741bd9d7b894f9f4545f0adbf24 Mon Sep 17 00:00:00 2001 From: Sergio Vieira Date: Thu, 27 Jul 2017 16:03:13 -0300 Subject: [PATCH 07/29] - Replace all NULL to nullptr --- src/core/Problem.cpp | 8 +++---- src/core/Solution.cpp | 18 +++++++------- src/core/SolutionSet.cpp | 6 ++--- src/core/SolutionType.cpp | 2 +- .../solutionType/ArrayRealSolutionType.cpp | 2 +- .../solutionType/BinaryRealSolutionType.cpp | 2 +- .../solutionType/BinarySolutionType.cpp | 4 ++-- .../solutionType/RealSolutionType.cpp | 2 +- src/encodings/variable/ArrayReal.cpp | 4 ++-- src/encodings/variable/Binary.cpp | 2 +- src/experiments/ExperimentExecution.cpp | 6 ++--- src/experiments/Settings.cpp | 2 +- src/experiments/util/RunExperiment.cpp | 2 +- src/main/OMOPSO_main.cpp | 4 ++-- src/metaheuristics/gde3/GDE3.cpp | 2 +- src/metaheuristics/mochc/MOCHC.cpp | 2 +- src/metaheuristics/nsgaII/NSGAII.cpp | 4 ++-- src/metaheuristics/nsgaII/ssNSGAII.cpp | 4 ++-- .../singleObjective/cmaes/CMAES.cpp | 6 ++--- .../particleSwarmOptimization/PSO.cpp | 6 ++--- .../StandardPSO2007.cpp | 4 ++-- .../StandardPSO2011.cpp | 4 ++-- src/metaheuristics/smpso/SMPSO.cpp | 24 +++++++++---------- src/metaheuristics/smsemoa/FastSMSEMOA.cpp | 2 +- src/metaheuristics/smsemoa/SMSEMOA.cpp | 4 ++-- .../DifferentialEvolutionCrossover.cpp | 8 +++---- src/operators/crossover/HUXCrossover.cpp | 6 ++--- src/operators/crossover/SBXCrossover.cpp | 8 +++---- .../crossover/SinglePointCrossover.cpp | 6 ++--- src/operators/mutation/BitFlipMutation.cpp | 2 +- src/operators/mutation/NonUniformMutation.cpp | 8 +++---- src/operators/mutation/PolynomialMutation.cpp | 6 ++--- src/operators/mutation/UniformMutation.cpp | 4 ++-- .../selection/BestSolutionSelection.cpp | 6 ++--- src/operators/selection/BinaryTournament.cpp | 2 +- src/operators/selection/BinaryTournament2.cpp | 2 +- .../selection/WorstSolutionSelection.cpp | 6 ++--- src/problems/DTLZ/DTLZ1.cpp | 4 ++-- src/problems/DTLZ/DTLZ2.cpp | 4 ++-- src/problems/DTLZ/DTLZ3.cpp | 4 ++-- src/problems/DTLZ/DTLZ4.cpp | 4 ++-- src/problems/DTLZ/DTLZ5.cpp | 4 ++-- src/problems/DTLZ/DTLZ6.cpp | 4 ++-- src/problems/DTLZ/DTLZ7.cpp | 4 ++-- src/problems/Fonseca.cpp | 8 +++---- src/problems/Kursawe.cpp | 6 ++--- src/problems/LZ09/LZ09_F1.cpp | 4 ++-- src/problems/LZ09/LZ09_F2.cpp | 4 ++-- src/problems/LZ09/LZ09_F3.cpp | 4 ++-- src/problems/LZ09/LZ09_F4.cpp | 4 ++-- src/problems/LZ09/LZ09_F5.cpp | 4 ++-- src/problems/LZ09/LZ09_F6.cpp | 4 ++-- src/problems/LZ09/LZ09_F7.cpp | 4 ++-- src/problems/LZ09/LZ09_F8.cpp | 4 ++-- src/problems/LZ09/LZ09_F9.cpp | 4 ++-- src/problems/ProblemFactory.cpp | 4 ++-- src/problems/Schaffer.cpp | 6 ++--- src/problems/Srinivas.cpp | 8 +++---- src/problems/Tanaka.cpp | 6 ++--- src/problems/ZDT/ZDT1.cpp | 4 ++-- src/problems/ZDT/ZDT2.cpp | 4 ++-- src/problems/ZDT/ZDT3.cpp | 4 ++-- src/problems/ZDT/ZDT4.cpp | 4 ++-- src/problems/ZDT/ZDT6.cpp | 4 ++-- src/problems/singleObjective/Griewank.cpp | 4 ++-- src/problems/singleObjective/Rastrigin.cpp | 8 +++---- src/problems/singleObjective/Rosenbrock.cpp | 8 +++---- src/problems/singleObjective/Sphere.cpp | 8 +++---- .../fastHypervolume/FastHypervolume.cpp | 4 ++-- src/util/PseudoRandom.cpp | 14 +++++------ src/util/RandomGenerator.cpp | 2 +- src/util/Ranking.cpp | 4 ++-- src/util/comparators/CrowdingComparator.cpp | 4 ++-- .../CrowdingDistanceComparator.cpp | 4 ++-- src/util/comparators/DominanceComparator.cpp | 4 ++-- .../EpsilonDominanceComparator.cpp | 4 ++-- .../EpsilonObjectiveComparator.cpp | 4 ++-- src/util/comparators/EqualSolutions.cpp | 4 ++-- src/util/comparators/ObjectiveComparator.cpp | 4 ++-- src/util/comparators/RankComparator.cpp | 4 ++-- 80 files changed, 198 insertions(+), 198 deletions(-) diff --git a/src/core/Problem.cpp b/src/core/Problem.cpp index c46d993..553a48c 100644 --- a/src/core/Problem.cpp +++ b/src/core/Problem.cpp @@ -32,7 +32,7 @@ const int Problem::DEFAULT_PRECISSION = 16; */ Problem::Problem() { - solutionType_ = NULL; + solutionType_ = nullptr; } // Problem @@ -99,7 +99,7 @@ void Problem::setNumberOfObjectives(int numberOfObjectives) */ double Problem::getLowerLimit(int i) { - if ((lowerLimit_ == NULL) || (i >= numberOfVariables_)) + if ((lowerLimit_ == nullptr) || (i >= numberOfVariables_)) { cout << "Error: lower limits have been not initialized or accessing to a variable out of range" << endl; // exit(-1); @@ -115,7 +115,7 @@ double Problem::getLowerLimit(int i) */ double Problem::getUpperLimit(int i) { - if ((upperLimit_ == NULL) || (i >= numberOfVariables_)) + if ((upperLimit_ == nullptr) || (i >= numberOfVariables_)) { cout << "Error: upper limits have been not initialized or accessing to a variable out of range" << endl; //exit(-1); @@ -185,7 +185,7 @@ void Problem::setPrecision(int * precision) */ int Problem::getLength(int var) { - if (length_ == NULL) + if (length_ == nullptr) { return DEFAULT_PRECISSION; } diff --git a/src/core/Solution.cpp b/src/core/Solution.cpp index 3a24b0d..3e2aeee 100644 --- a/src/core/Solution.cpp +++ b/src/core/Solution.cpp @@ -29,15 +29,15 @@ */ Solution::Solution () { - problem_ = NULL; + problem_ = nullptr; marked_ = false; overallConstraintViolation_ = 0.0; numberOfViolatedConstraints_ = 0; numberOfVariables_ = 0; numberOfObjectives_ = 0; - type_ = NULL; - variable_ = NULL; - objective_ = NULL; + type_ = nullptr; + variable_ = nullptr; + objective_ = nullptr; rank_ = 0; } //Solution @@ -54,9 +54,9 @@ Solution::Solution (int numberOfObjectives) overallConstraintViolation_ = 0.0; numberOfObjectives_ = numberOfObjectives; numberOfVariables_ = 0; - variable_ = NULL; + variable_ = nullptr; objective_ = new double[numberOfObjectives_]; - if (objective_ == NULL) + if (objective_ == nullptr) { cout << "ERROR GRAVE: Impossible to reserve memory for storing objectives in class Solution" << endl; exit(-1); @@ -80,7 +80,7 @@ Solution::Solution (Problem *problem) // creating the objective vector objective_ = new double[numberOfObjectives_]; - if (objective_ == NULL) + if (objective_ == nullptr) { cout << "ERROR GRAVE: Impossible to reserve memory for storing objectives in class Solution" << endl; exit(-1); @@ -132,7 +132,7 @@ Solution::Solution (Solution *solution) // creating the objective vector objective_ = new double[numberOfObjectives_]; - if (objective_ == NULL) + if (objective_ == nullptr) { cout << "ERROR GRAVE: Impossible to reserve memory for storing objectives in class Solution" << endl; exit(-1); @@ -171,7 +171,7 @@ Solution::Solution (Solution *solution) Solution::~Solution() { delete[]objective_ ; - if (variable_ != NULL) + if (variable_ != nullptr) for (int i = 0; i < numberOfVariables_; i++) delete variable_[i] ; delete [] variable_ ; diff --git a/src/core/SolutionSet.cpp b/src/core/SolutionSet.cpp index 090fa31..186681a 100644 --- a/src/core/SolutionSet.cpp +++ b/src/core/SolutionSet.cpp @@ -120,7 +120,7 @@ int SolutionSet::getMaxSize() */ void SolutionSet::sort(Comparator * comparator) { - if (comparator == NULL) + if (comparator == nullptr) { cout << "Error. No criterium for compare exist" << endl; exit(-1); @@ -184,7 +184,7 @@ Solution * SolutionSet::best(Comparator * comparator) int indexBest = this->indexBest(comparator); if (indexBest < 0) { - return NULL; + return nullptr; } else { @@ -236,7 +236,7 @@ Solution * SolutionSet::worst(Comparator * comparator) int index = indexWorst(comparator); if (index < 0) { - return NULL; + return nullptr; } else { diff --git a/src/core/SolutionType.cpp b/src/core/SolutionType.cpp index d9c086e..e9b1942 100644 --- a/src/core/SolutionType.cpp +++ b/src/core/SolutionType.cpp @@ -50,7 +50,7 @@ Variable ** SolutionType::copyVariables(Variable **vars) int var; Variable ** variables = new Variable*[numberOfVar]; - if (variables == NULL) + if (variables == nullptr) { cout << "Error grave: Impossible to reserve memory for allocating a copy of variables" << endl; exit(-1); diff --git a/src/encodings/solutionType/ArrayRealSolutionType.cpp b/src/encodings/solutionType/ArrayRealSolutionType.cpp index 3462a49..b84d34f 100644 --- a/src/encodings/solutionType/ArrayRealSolutionType.cpp +++ b/src/encodings/solutionType/ArrayRealSolutionType.cpp @@ -39,7 +39,7 @@ Variable ** ArrayRealSolutionType::createVariables() int i; Variable **variables = new Variable*[1]; //malloc(sizeof(Real) * problem->getNumberOfVariables()); - if (problem_->getSolutionType() == NULL) + if (problem_->getSolutionType() == nullptr) { cout << "Error grave: Impossible to reserve memory for variable type" << endl; exit(-1); diff --git a/src/encodings/solutionType/BinaryRealSolutionType.cpp b/src/encodings/solutionType/BinaryRealSolutionType.cpp index 48e6f40..a06feeb 100644 --- a/src/encodings/solutionType/BinaryRealSolutionType.cpp +++ b/src/encodings/solutionType/BinaryRealSolutionType.cpp @@ -42,7 +42,7 @@ Variable ** BinaryRealSolutionType::createVariables() for (int var = 0; var < problem_->getNumberOfVariables(); var++) { - if (problem_->getPrecision() == NULL) + if (problem_->getPrecision() == nullptr) { int * precision = new int[problem_->getNumberOfVariables()] ; for (int i = 0; i < problem_->getNumberOfVariables(); i++) diff --git a/src/encodings/solutionType/BinarySolutionType.cpp b/src/encodings/solutionType/BinarySolutionType.cpp index beaf90e..6548645 100644 --- a/src/encodings/solutionType/BinarySolutionType.cpp +++ b/src/encodings/solutionType/BinarySolutionType.cpp @@ -40,7 +40,7 @@ Variable **BinarySolutionType::createVariables() //BinaryReal * binaryReal; Variable **variables = new Variable*[problem_->getNumberOfVariables()]; //malloc(sizeof(Real) * problem->getNumberOfVariables()); -// if (problem_->variableType_ == NULL) { +// if (problem_->variableType_ == nullptr) { // cout << "Error grave: Impossible to reserve memory for variable type" << endl; // exit(-1); // } @@ -49,7 +49,7 @@ Variable **BinarySolutionType::createVariables() variables[var] = new Binary(problem_->getLength(var)); /* for (int var = 0; var < problem_->getNumberOfVariables(); var++) { - if (problem_->getPrecision() == NULL) { + if (problem_->getPrecision() == nullptr) { int * precision = new int[problem_->getNumberOfVariables()] ; for (int i = 0; i < problem_->getNumberOfVariables(); i++) precision[i] = BinaryReal::DEFAULT_PRECISION ; diff --git a/src/encodings/solutionType/RealSolutionType.cpp b/src/encodings/solutionType/RealSolutionType.cpp index b2fff6f..3419052 100644 --- a/src/encodings/solutionType/RealSolutionType.cpp +++ b/src/encodings/solutionType/RealSolutionType.cpp @@ -41,7 +41,7 @@ Variable **RealSolutionType::createVariables() int i; Variable **variables = new Variable*[problem_->getNumberOfVariables()]; //malloc(sizeof(Real) * problem->getNumberOfVariables()); - if (variables == NULL) + if (variables == nullptr) { cout << "Error grave: Impossible to reserve memory for variable type" << endl; exit(-1); diff --git a/src/encodings/variable/ArrayReal.cpp b/src/encodings/variable/ArrayReal.cpp index 61ec172..9b9e8ec 100644 --- a/src/encodings/variable/ArrayReal.cpp +++ b/src/encodings/variable/ArrayReal.cpp @@ -27,9 +27,9 @@ */ ArrayReal::ArrayReal() { - problem_ = NULL; + problem_ = nullptr; size_ = 0; - array_ = NULL; + array_ = nullptr; } // Constructor diff --git a/src/encodings/variable/Binary.cpp b/src/encodings/variable/Binary.cpp index b2c28b4..ee41073 100644 --- a/src/encodings/variable/Binary.cpp +++ b/src/encodings/variable/Binary.cpp @@ -27,7 +27,7 @@ */ Binary::Binary() { - bits_ = NULL ; + bits_ = nullptr ; numberOfBits_ = -1 ; } //Binary diff --git a/src/experiments/ExperimentExecution.cpp b/src/experiments/ExperimentExecution.cpp index f55817b..1cfea78 100644 --- a/src/experiments/ExperimentExecution.cpp +++ b/src/experiments/ExperimentExecution.cpp @@ -97,7 +97,7 @@ void ExperimentExecution::runExperiment(int numberOfThreads) //pthread_mutex_t mutex; mutex mtx; - //result = pthread_mutex_init(&mutex, NULL) ; + //result = pthread_mutex_init(&mutex, nullptr) ; // if (result != 0) { // perror("ERROR WHILE INITIALIZING THE MUTEX"); // exit(-1) ; @@ -113,7 +113,7 @@ void ExperimentExecution::runExperiment(int numberOfThreads) { experiments_[i] = new RunExperiment(this, map_, i, numberOfThreads, problemList_.size(), i, &mtx); -// result = pthread_create(&p[i], NULL, executeRun, experiments_[i]); +// result = pthread_create(&p[i], nullptr, executeRun, experiments_[i]); // if (result != 0) { // perror("ERROR WHILE CREATING THREADS"); // exit(-1) ; @@ -122,7 +122,7 @@ void ExperimentExecution::runExperiment(int numberOfThreads) } // for (int i = 0; i < numberOfThreads; i++) { -// result = pthread_join(p[i], NULL) ; +// result = pthread_join(p[i], nullptr) ; // cout << "Joined thread number " << (i+1) << "." < settings) { - return NULL ; + return nullptr ; } // configure diff --git a/src/experiments/util/RunExperiment.cpp b/src/experiments/util/RunExperiment.cpp index c650647..b38c3ee 100644 --- a/src/experiments/util/RunExperiment.cpp +++ b/src/experiments/util/RunExperiment.cpp @@ -74,7 +74,7 @@ void RunExperiment::run() cout << "Experiment directory: " << experimentBaseDirectory_ << endl; cout << "Number of threads: " << numberOfThreads_ << endl; - SolutionSet * resultFront = NULL; + SolutionSet * resultFront = nullptr; int problemIndex = -1; int algorithmIndex = -1; diff --git a/src/main/OMOPSO_main.cpp b/src/main/OMOPSO_main.cpp index 9878b42..571bbd9 100644 --- a/src/main/OMOPSO_main.cpp +++ b/src/main/OMOPSO_main.cpp @@ -50,7 +50,7 @@ int main(int argc, char ** argv) map parameters; // Operator parameters - indicators = NULL; + indicators = nullptr; if (argc>=2) { @@ -106,7 +106,7 @@ int main(int argc, char ** argv) cout << "Objectives values have been written to file FUN" << endl; population->printObjectivesToFile("FUN"); - if (indicators != NULL) + if (indicators != nullptr) { cout << "Quality indicators" << endl ; cout << "Hypervolume: " << indicators->getHypervolume(population) << endl; diff --git a/src/metaheuristics/gde3/GDE3.cpp b/src/metaheuristics/gde3/GDE3.cpp index 83972ca..3c54d7d 100644 --- a/src/metaheuristics/gde3/GDE3.cpp +++ b/src/metaheuristics/gde3/GDE3.cpp @@ -141,7 +141,7 @@ SolutionSet * GDE3::execute() int remain = populationSize; int index = 0; - SolutionSet * front = NULL; + SolutionSet * front = nullptr; for (int i = 0; i < populationSize; i++) { delete population->get(i); diff --git a/src/metaheuristics/mochc/MOCHC.cpp b/src/metaheuristics/mochc/MOCHC.cpp index 7ce5d92..c03357e 100644 --- a/src/metaheuristics/mochc/MOCHC.cpp +++ b/src/metaheuristics/mochc/MOCHC.cpp @@ -91,7 +91,7 @@ SolutionSet *MOCHC::rankingAndCrowdingSelection(SolutionSet * pop, int size) Distance * distance = new Distance(); int remain = size; int index = 0; - SolutionSet * front = NULL; + SolutionSet * front = nullptr; // Obtain the next front front = ranking->getSubfront(index); diff --git a/src/metaheuristics/nsgaII/NSGAII.cpp b/src/metaheuristics/nsgaII/NSGAII.cpp index d4bf074..d2c3bde 100644 --- a/src/metaheuristics/nsgaII/NSGAII.cpp +++ b/src/metaheuristics/nsgaII/NSGAII.cpp @@ -133,7 +133,7 @@ SolutionSet * NSGAII::execute() int remain = populationSize; int index = 0; - SolutionSet * front = NULL; + SolutionSet * front = nullptr; for (int i=0; isize(); i++) { delete population->get(i); @@ -188,7 +188,7 @@ SolutionSet * NSGAII::execute() // of NSGA-II. In particular, it finds the number of evaluations required // by the algorithm to obtain a Pareto front with a hypervolume higher // than the hypervolume of the true Pareto front. -// if ((indicators != NULL) && (requiredEvaluations == 0)) { +// if ((indicators != nullptr) && (requiredEvaluations == 0)) { // double HV = indicators->getHypervolume(population); // if (HV >= (0.98 * indicators->getTrueParetoFrontHypervolume())) { // requiredEvaluations = evaluations; diff --git a/src/metaheuristics/nsgaII/ssNSGAII.cpp b/src/metaheuristics/nsgaII/ssNSGAII.cpp index d6ab3cb..0fdc7d2 100644 --- a/src/metaheuristics/nsgaII/ssNSGAII.cpp +++ b/src/metaheuristics/nsgaII/ssNSGAII.cpp @@ -128,7 +128,7 @@ SolutionSet * ssNSGAII::execute() int remain = populationSize; int index = 0; - SolutionSet * front = NULL; + SolutionSet * front = nullptr; for (int i=0; isize(); i++) { delete population->get(i); @@ -182,7 +182,7 @@ SolutionSet * ssNSGAII::execute() // by the algorithm to obtain a Pareto front with a hypervolume higher // than the hypervolume of the true Pareto front. // TODO: -// if ((indicators != NULL) && +// if ((indicators != nullptr) && // (requiredEvaluations == 0)) { // double HV = indicators.getHypervolume(population); // if (HV >= (0.98 * indicators.getTrueParetoFrontHypervolume())) { diff --git a/src/metaheuristics/singleObjective/cmaes/CMAES.cpp b/src/metaheuristics/singleObjective/cmaes/CMAES.cpp index 11f599a..0d8203f 100644 --- a/src/metaheuristics/singleObjective/cmaes/CMAES.cpp +++ b/src/metaheuristics/singleObjective/cmaes/CMAES.cpp @@ -33,7 +33,7 @@ */ CMAES::CMAES(Problem *problem) : Algorithm(problem) { - bestSolutionEver = NULL; + bestSolutionEver = nullptr; } // CMAES @@ -333,11 +333,11 @@ void CMAES::storeBest(Comparator * comparator) { Solution * bestInPopulation = new Solution(population_->best(comparator)); - if ((bestSolutionEver == NULL) || + if ((bestSolutionEver == nullptr) || (bestSolutionEver->getObjective(0) > bestInPopulation->getObjective(0))) { - if (bestSolutionEver != NULL) + if (bestSolutionEver != nullptr) { delete bestSolutionEver; } diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp b/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp index 638bac2..e89093a 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp @@ -287,7 +287,7 @@ SolutionSet * PSO::execute() initParams(); success_ = false; - globalBest_ = NULL; + globalBest_ = nullptr; //->Step 1 (and 3) Create the initial population and evaluate for (int i = 0; i < particlesSize_; i++) @@ -296,9 +296,9 @@ SolutionSet * PSO::execute() problem_->evaluate(particle); evaluations_ ++; particles_->add(particle); - if ((globalBest_ == NULL) || (particle->getObjective(0) < globalBest_->getObjective(0))) + if ((globalBest_ == nullptr) || (particle->getObjective(0) < globalBest_->getObjective(0))) { - if (globalBest_!= NULL) + if (globalBest_!= nullptr) { delete globalBest_; } diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp index 5d3563b..34af3b8 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp @@ -106,11 +106,11 @@ void StandardPSO2007::deleteParams() Solution * StandardPSO2007::getNeighborBest(int i) { - Solution * bestLocalBestSolution = NULL ; + Solution * bestLocalBestSolution = nullptr ; for (int index : neighborhood_->getNeighbors(i)) { - if ((bestLocalBestSolution == NULL) || (bestLocalBestSolution->getObjective(0) > localBest_[index]->getObjective(0))) + if ((bestLocalBestSolution == nullptr) || (bestLocalBestSolution->getObjective(0) > localBest_[index]->getObjective(0))) { bestLocalBestSolution = localBest_[index] ; } diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp index d29060e..ba33f4f 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp @@ -107,11 +107,11 @@ void StandardPSO2011::deleteParams() Solution * StandardPSO2011::getNeighborBest(int i) { - Solution * bestLocalBestSolution = NULL ; + Solution * bestLocalBestSolution = nullptr ; for (int index : neighborhood_->getNeighbors(i)) { - if ((bestLocalBestSolution == NULL) || (bestLocalBestSolution->getObjective(0) > localBest_[index]->getObjective(0))) + if ((bestLocalBestSolution == nullptr) || (bestLocalBestSolution->getObjective(0) > localBest_[index]->getObjective(0))) { bestLocalBestSolution = localBest_[index] ; } diff --git a/src/metaheuristics/smpso/SMPSO.cpp b/src/metaheuristics/smpso/SMPSO.cpp index 477ddb4..31efdf5 100644 --- a/src/metaheuristics/smpso/SMPSO.cpp +++ b/src/metaheuristics/smpso/SMPSO.cpp @@ -113,18 +113,18 @@ void SMPSO::setAlgParams() void * ChVel1Ptr = getInputParameter("ChVel1"); void * ChVel2Ptr = getInputParameter("ChVel2"); - if (r1MaxPtr != NULL) r1Max_ = * (double *) r1MaxPtr; - if (r1MinPtr != NULL) r1Min_ = * (double *) r1MinPtr; - if (r2MaxPtr != NULL) r2Max_ = * (double *) r2MaxPtr; - if (r2MinPtr != NULL) r2Min_ = * (double *) r2MinPtr; - if (C1MaxPtr != NULL) C1Max_ = * (double *) C1MaxPtr; - if (C1MinPtr != NULL) C1Min_ = * (double *) C1MinPtr; - if (C2MaxPtr != NULL) C2Max_ = * (double *) C2MaxPtr; - if (C2MinPtr != NULL) C2Min_ = * (double *) C2MinPtr; - if (WMaxPtr != NULL) WMax_ = * (double *) WMaxPtr; - if (WMinPtr != NULL) WMin_ = * (double *) WMinPtr; - if (ChVel1Ptr != NULL) ChVel1_ = * (double *) ChVel1Ptr; - if (ChVel2Ptr != NULL) ChVel2_ = * (double *) ChVel2Ptr; + if (r1MaxPtr != nullptr) r1Max_ = * (double *) r1MaxPtr; + if (r1MinPtr != nullptr) r1Min_ = * (double *) r1MinPtr; + if (r2MaxPtr != nullptr) r2Max_ = * (double *) r2MaxPtr; + if (r2MinPtr != nullptr) r2Min_ = * (double *) r2MinPtr; + if (C1MaxPtr != nullptr) C1Max_ = * (double *) C1MaxPtr; + if (C1MinPtr != nullptr) C1Min_ = * (double *) C1MinPtr; + if (C2MaxPtr != nullptr) C2Max_ = * (double *) C2MaxPtr; + if (C2MinPtr != nullptr) C2Min_ = * (double *) C2MinPtr; + if (WMaxPtr != nullptr) WMax_ = * (double *) WMaxPtr; + if (WMinPtr != nullptr) WMin_ = * (double *) WMinPtr; + if (ChVel1Ptr != nullptr) ChVel1_ = * (double *) ChVel1Ptr; + if (ChVel2Ptr != nullptr) ChVel2_ = * (double *) ChVel2Ptr; } // setAlgParams diff --git a/src/metaheuristics/smsemoa/FastSMSEMOA.cpp b/src/metaheuristics/smsemoa/FastSMSEMOA.cpp index 5c37a38..16f5f77 100644 --- a/src/metaheuristics/smsemoa/FastSMSEMOA.cpp +++ b/src/metaheuristics/smsemoa/FastSMSEMOA.cpp @@ -167,7 +167,7 @@ SolutionSet * FastSMSEMOA::execute() delete cd; // all but the worst are carried over to the survivor population - SolutionSet * front = NULL; + SolutionSet * front = nullptr; for (int i=0; isize(); i++) { delete population->get(i); diff --git a/src/metaheuristics/smsemoa/SMSEMOA.cpp b/src/metaheuristics/smsemoa/SMSEMOA.cpp index 7eb7c10..5129fbd 100644 --- a/src/metaheuristics/smsemoa/SMSEMOA.cpp +++ b/src/metaheuristics/smsemoa/SMSEMOA.cpp @@ -193,7 +193,7 @@ SolutionSet * SMSEMOA::execute() } // all but the worst are carried over to the survivor population - SolutionSet *front = NULL; + SolutionSet *front = nullptr; for (int i=0; isize(); i++) { delete population->get(i); @@ -216,7 +216,7 @@ SolutionSet * SMSEMOA::execute() // of SMS-EMOA. In particular, it finds the number of evaluations required // by the algorithm to obtain a Pareto front with a hypervolume higher // than the hypervolume of the true Pareto front. - /*if (indicators != NULL && requiredEvaluations == 0) { + /*if (indicators != nullptr && requiredEvaluations == 0) { double HV = indicators->getHypervolume(population); if (HV >= (0.98 * indicators->getTrueParetoFrontHypervolume())) { requiredEvaluations = evaluations; diff --git a/src/operators/crossover/DifferentialEvolutionCrossover.cpp b/src/operators/crossover/DifferentialEvolutionCrossover.cpp index cb0d785..9bd82da 100644 --- a/src/operators/crossover/DifferentialEvolutionCrossover.cpp +++ b/src/operators/crossover/DifferentialEvolutionCrossover.cpp @@ -73,19 +73,19 @@ DifferentialEvolutionCrossover::DifferentialEvolutionCrossover(map parameters) : Crossover(parameters) { crossoverProbability_ = 0.0 ; - //TODO: crossoverProbability_ = NULL; - if (parameters["probability"] != NULL) + //TODO: crossoverProbability_ = nullptr; + if (parameters["probability"] != nullptr) crossoverProbability_ = *(double *)parameters["probability"]; } // SinglePointCrossover @@ -49,7 +49,7 @@ Solution ** HUXCrossover::doCrossover(double probability, Solution *parent1, Sol Solution** offSpring = new Solution*[2]; - if (offSpring == NULL) + if (offSpring == nullptr) { cout << "Error grave: Impossible reserve memory for allocating new solutions when performing SinglePointCrossover " << endl; exit(-1); diff --git a/src/operators/crossover/SBXCrossover.cpp b/src/operators/crossover/SBXCrossover.cpp index 93dd040..fde1da7 100644 --- a/src/operators/crossover/SBXCrossover.cpp +++ b/src/operators/crossover/SBXCrossover.cpp @@ -41,11 +41,11 @@ const double SBXCrossover::ETA_C_DEFAULT_ = 20.0; SBXCrossover::SBXCrossover(map parameters) : Crossover(parameters) { - //TODO: crossoverProbability_ = NULL; + //TODO: crossoverProbability_ = nullptr; distributionIndex_ = ETA_C_DEFAULT_; - if (parameters["probability"] != NULL) + if (parameters["probability"] != nullptr) crossoverProbability_ = *(double *)parameters["probability"]; - if (parameters["distributionIndex"] != NULL) + if (parameters["distributionIndex"] != nullptr) distributionIndex_ = *(double *)parameters["distributionIndex"]; } // SBXCrossover @@ -68,7 +68,7 @@ Solution ** SBXCrossover::doCrossover(double probability, Solution *parent1, Sol Solution** offSpring = new Solution*[2]; - if (offSpring == NULL) + if (offSpring == nullptr) { cout << "Error grave: Impossible reserve memory for allocating new solutions when performing SBXCrossover " << endl; exit(-1); diff --git a/src/operators/crossover/SinglePointCrossover.cpp b/src/operators/crossover/SinglePointCrossover.cpp index a142cb7..95aedd5 100644 --- a/src/operators/crossover/SinglePointCrossover.cpp +++ b/src/operators/crossover/SinglePointCrossover.cpp @@ -37,8 +37,8 @@ SinglePointCrossover::SinglePointCrossover(map parameters) : Crossover(parameters) { crossoverProbability_ = 0.0 ; - //TODO: crossoverProbability_ = NULL; - if (parameters["probability"] != NULL) + //TODO: crossoverProbability_ = nullptr; + if (parameters["probability"] != nullptr) crossoverProbability_ = *(double *)parameters["probability"]; } // SinglePointCrossover @@ -55,7 +55,7 @@ Solution ** SinglePointCrossover::doCrossover(double probability, Solution *pare Solution** offSpring = new Solution*[2]; - if (offSpring == NULL) + if (offSpring == nullptr) { cout << "Error grave: Impossible reserve memory for allocating new solutions when performing SinglePointCrossover " << endl; exit(-1); diff --git a/src/operators/mutation/BitFlipMutation.cpp b/src/operators/mutation/BitFlipMutation.cpp index 0741cc1..79f3a6c 100644 --- a/src/operators/mutation/BitFlipMutation.cpp +++ b/src/operators/mutation/BitFlipMutation.cpp @@ -30,7 +30,7 @@ BitFlipMutation::BitFlipMutation(map parameters) : Mutation(parameters) { mutationProbability_ = 0.0 ; - if (parameters["probability"] != NULL) + if (parameters["probability"] != nullptr) mutationProbability_ = *(double *) parameters["probability"]; } // BitFlipMutation diff --git a/src/operators/mutation/NonUniformMutation.cpp b/src/operators/mutation/NonUniformMutation.cpp index 14fc612..338bc0a 100644 --- a/src/operators/mutation/NonUniformMutation.cpp +++ b/src/operators/mutation/NonUniformMutation.cpp @@ -36,15 +36,15 @@ const string NonUniformMutation::VALID_TYPES[] = {"Real", "ArrayReal"}; NonUniformMutation::NonUniformMutation(map parameters) : Mutation(parameters) { - if (parameters["probability"] != NULL) + if (parameters["probability"] != nullptr) { mutationProbability_ = *(double *) parameters["probability"]; } - if (parameters["perturbation"] != NULL) + if (parameters["perturbation"] != nullptr) { perturbation_ = *(double *) parameters["perturbation"]; } - if (parameters["maxIterations"] != NULL) + if (parameters["maxIterations"] != nullptr) { maxIterations_ = *(int *) parameters["maxIterations"]; } @@ -120,7 +120,7 @@ void *NonUniformMutation::execute(void *object) { Solution *solution = (Solution *)object; // TODO: VALID_TYPES? - if (getParameter("currentIteration") != NULL) + if (getParameter("currentIteration") != nullptr) { currentIteration_ = *(int *) getParameter("currentIteration") ; } diff --git a/src/operators/mutation/PolynomialMutation.cpp b/src/operators/mutation/PolynomialMutation.cpp index 0f72bee..661f3b4 100644 --- a/src/operators/mutation/PolynomialMutation.cpp +++ b/src/operators/mutation/PolynomialMutation.cpp @@ -35,11 +35,11 @@ const double PolynomialMutation::eta_m_ = ETA_M_DEFAULT_; PolynomialMutation::PolynomialMutation(map parameters) : Mutation(parameters) { - // TODO: mutationProbability_ = NULL; + // TODO: mutationProbability_ = nullptr; distributionIndex_ = eta_m_; - if (parameters["probability"] != NULL) + if (parameters["probability"] != nullptr) mutationProbability_ = *(double *) parameters["probability"]; - if (parameters["distributionIndex"] != NULL) + if (parameters["distributionIndex"] != nullptr) distributionIndex_ = *(double *) parameters["distributionIndex"]; } // PolynomialMutation diff --git a/src/operators/mutation/UniformMutation.cpp b/src/operators/mutation/UniformMutation.cpp index e69da11..69221cb 100644 --- a/src/operators/mutation/UniformMutation.cpp +++ b/src/operators/mutation/UniformMutation.cpp @@ -36,11 +36,11 @@ const string UniformMutation::VALID_TYPES[] = {"Real", "ArrayReal"}; UniformMutation::UniformMutation(map parameters) : Mutation(parameters) { - if (parameters["probability"] != NULL) + if (parameters["probability"] != nullptr) { mutationProbability_ = *(double *) parameters["probability"]; } - if (parameters["perturbation"] != NULL) + if (parameters["perturbation"] != nullptr) { perturbation_ = *(double *) parameters["perturbation"]; } diff --git a/src/operators/selection/BestSolutionSelection.cpp b/src/operators/selection/BestSolutionSelection.cpp index 7076627..e35ba94 100644 --- a/src/operators/selection/BestSolutionSelection.cpp +++ b/src/operators/selection/BestSolutionSelection.cpp @@ -34,8 +34,8 @@ BestSolutionSelection::BestSolutionSelection(map parameters) : Selection(parameters) { - comparator_ = NULL; - if (parameters["comparator"] != NULL) + comparator_ = nullptr; + if (parameters["comparator"] != nullptr) { comparator_ = (Comparator *) parameters["comparator"]; } @@ -54,7 +54,7 @@ void * BestSolutionSelection::execute(void * object) if (solutionSet->size() == 0) { - return NULL; + return nullptr; } int bestSolution = 0; diff --git a/src/operators/selection/BinaryTournament.cpp b/src/operators/selection/BinaryTournament.cpp index e0e24c8..141ce1a 100644 --- a/src/operators/selection/BinaryTournament.cpp +++ b/src/operators/selection/BinaryTournament.cpp @@ -35,7 +35,7 @@ BinaryTournament::BinaryTournament(map parameters) : Selection(parameters) { - if (parameters["comparator"] != NULL) + if (parameters["comparator"] != nullptr) comparator_ = (Comparator *) parameters["comparator"]; else comparator_ = new DominanceComparator(); diff --git a/src/operators/selection/BinaryTournament2.cpp b/src/operators/selection/BinaryTournament2.cpp index 14a0eac..bb5305e 100644 --- a/src/operators/selection/BinaryTournament2.cpp +++ b/src/operators/selection/BinaryTournament2.cpp @@ -41,7 +41,7 @@ BinaryTournament2::BinaryTournament2(map parameters) index_ = 0; a_ = new int[1]; // Initialized as dummy dominance_ = new DominanceComparator(); - if (dominance_ == NULL) + if (dominance_ == nullptr) { cout << "BinaryTournament::BinaryTournament: error creating comparator" ; cout << endl ; diff --git a/src/operators/selection/WorstSolutionSelection.cpp b/src/operators/selection/WorstSolutionSelection.cpp index 4c89ef5..733c7a6 100644 --- a/src/operators/selection/WorstSolutionSelection.cpp +++ b/src/operators/selection/WorstSolutionSelection.cpp @@ -34,8 +34,8 @@ WorstSolutionSelection::WorstSolutionSelection(map parameters) : Selection(parameters) { - comparator_ = NULL; - if (parameters["comparator"] != NULL) + comparator_ = nullptr; + if (parameters["comparator"] != nullptr) { comparator_ = (Comparator *) parameters["comparator"]; } @@ -54,7 +54,7 @@ void * WorstSolutionSelection::execute(void * object) if (solutionSet->size() == 0) { - return NULL; + return nullptr; } int worstSolution = 0; diff --git a/src/problems/DTLZ/DTLZ1.cpp b/src/problems/DTLZ/DTLZ1.cpp index 5c75951..bcceb0e 100644 --- a/src/problems/DTLZ/DTLZ1.cpp +++ b/src/problems/DTLZ/DTLZ1.cpp @@ -30,14 +30,14 @@ DTLZ1::DTLZ1(string solutionType, int numberOfVariables, int numberOfObjectives) problemName_ = "DTLZ1"; lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); diff --git a/src/problems/DTLZ/DTLZ2.cpp b/src/problems/DTLZ/DTLZ2.cpp index d4b3baa..18c844f 100644 --- a/src/problems/DTLZ/DTLZ2.cpp +++ b/src/problems/DTLZ/DTLZ2.cpp @@ -30,14 +30,14 @@ DTLZ2::DTLZ2(string solutionType, int numberOfVariables, int numberOfObjectives) problemName_ = "DTLZ2"; lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); diff --git a/src/problems/DTLZ/DTLZ3.cpp b/src/problems/DTLZ/DTLZ3.cpp index f8a3ec9..32c551f 100644 --- a/src/problems/DTLZ/DTLZ3.cpp +++ b/src/problems/DTLZ/DTLZ3.cpp @@ -30,14 +30,14 @@ DTLZ3::DTLZ3(string solutionType, int numberOfVariables, int numberOfObjectives) problemName_ = "DTLZ3"; lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); diff --git a/src/problems/DTLZ/DTLZ4.cpp b/src/problems/DTLZ/DTLZ4.cpp index 1abb340..8287414 100644 --- a/src/problems/DTLZ/DTLZ4.cpp +++ b/src/problems/DTLZ/DTLZ4.cpp @@ -30,14 +30,14 @@ DTLZ4::DTLZ4(string solutionType, int numberOfVariables, int numberOfObjectives) problemName_ = "DTLZ4"; lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); diff --git a/src/problems/DTLZ/DTLZ5.cpp b/src/problems/DTLZ/DTLZ5.cpp index 90ee86d..4e80e87 100644 --- a/src/problems/DTLZ/DTLZ5.cpp +++ b/src/problems/DTLZ/DTLZ5.cpp @@ -30,14 +30,14 @@ DTLZ5::DTLZ5(string solutionType, int numberOfVariables, int numberOfObjectives) problemName_ = "DTLZ5"; lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); diff --git a/src/problems/DTLZ/DTLZ6.cpp b/src/problems/DTLZ/DTLZ6.cpp index f29ac75..cff8b5a 100644 --- a/src/problems/DTLZ/DTLZ6.cpp +++ b/src/problems/DTLZ/DTLZ6.cpp @@ -30,14 +30,14 @@ DTLZ6::DTLZ6(string solutionType, int numberOfVariables, int numberOfObjectives) problemName_ = "DTLZ6"; lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); diff --git a/src/problems/DTLZ/DTLZ7.cpp b/src/problems/DTLZ/DTLZ7.cpp index 90c1cf7..ced2b4d 100644 --- a/src/problems/DTLZ/DTLZ7.cpp +++ b/src/problems/DTLZ/DTLZ7.cpp @@ -30,14 +30,14 @@ DTLZ7::DTLZ7(string solutionType, int numberOfVariables, int numberOfObjectives) problemName_ = "DTLZ7"; lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); diff --git a/src/problems/Fonseca.cpp b/src/problems/Fonseca.cpp index fa73bb8..90a5f07 100644 --- a/src/problems/Fonseca.cpp +++ b/src/problems/Fonseca.cpp @@ -32,13 +32,13 @@ Fonseca::Fonseca(string solutionType) problemName_ = "Fonseca"; lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "Fonseca::Fonseca. Error reserving memory for storing the array of lower limits" << endl; } // if upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "Fonseca::Fonseca. Error reserving memory for storing the array of upper limits" << endl; exit(-1) ; @@ -93,14 +93,14 @@ void Fonseca::evaluate(Solution *solution) Variable **variables = solution->getDecisionVariables(); fx = new double[numberOfObjectives_]; - if (fx == NULL) + if (fx == nullptr) { cout << "Fonseca::evaluate: Error reserving memory for the function values array" << endl; exit(-1); } // if x = new double[numberOfVariables_]; - if (x == NULL) + if (x == nullptr) { cout << "Fonseca::evaluate: Error reserving memory for the variable values array" << endl; exit(-1); diff --git a/src/problems/Kursawe.cpp b/src/problems/Kursawe.cpp index e14d113..1b14cf9 100644 --- a/src/problems/Kursawe.cpp +++ b/src/problems/Kursawe.cpp @@ -44,14 +44,14 @@ Kursawe::Kursawe(string solutionType, int numberOfVariables) problemName_ = "Kursawe"; lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); @@ -102,7 +102,7 @@ void Kursawe::evaluate(Solution *solution) double aux, xi, xj; // auxiliary variables double * fx = new double[2]; // function values - if (fx == NULL) + if (fx == nullptr) { cout << "Error grave: Impossible to reserve memory while evaluating the problem" << endl; exit(-1); diff --git a/src/problems/LZ09/LZ09_F1.cpp b/src/problems/LZ09/LZ09_F1.cpp index 8254f83..1d74674 100644 --- a/src/problems/LZ09/LZ09_F1.cpp +++ b/src/problems/LZ09/LZ09_F1.cpp @@ -37,7 +37,7 @@ LZ09_F1::LZ09_F1(string solutionType, int ptype, int dtype, int ltype) ltype) ; lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "LZ09_F1::LZ09_F1: Error reserving memory for storing the " << "variable lower limits" << endl; @@ -45,7 +45,7 @@ LZ09_F1::LZ09_F1(string solutionType, int ptype, int dtype, int ltype) } upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "LZ09_F1::LZ09_F1: Error reserving memory for storing the " << "variable lower limits" << endl; diff --git a/src/problems/LZ09/LZ09_F2.cpp b/src/problems/LZ09/LZ09_F2.cpp index 39eef56..001bb13 100644 --- a/src/problems/LZ09/LZ09_F2.cpp +++ b/src/problems/LZ09/LZ09_F2.cpp @@ -37,7 +37,7 @@ LZ09_F2::LZ09_F2(string solutionType, int ptype, int dtype, int ltype) ltype) ; lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "LZ09_F2::LZ09_F2: Error reserving memory for storing the " << "variable lower limits" << endl; @@ -45,7 +45,7 @@ LZ09_F2::LZ09_F2(string solutionType, int ptype, int dtype, int ltype) } upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "LZ09_F2::LZ09_F2: Error reserving memory for storing the " << "variable lower limits" << endl; diff --git a/src/problems/LZ09/LZ09_F3.cpp b/src/problems/LZ09/LZ09_F3.cpp index 5ae88c7..d922f7d 100644 --- a/src/problems/LZ09/LZ09_F3.cpp +++ b/src/problems/LZ09/LZ09_F3.cpp @@ -37,7 +37,7 @@ LZ09_F3::LZ09_F3(string solutionType, int ptype, int dtype, int ltype) ltype) ; lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "LZ09_F3::LZ09_F3: Error reserving memory for storing the " << "variable lower limits" << endl; @@ -45,7 +45,7 @@ LZ09_F3::LZ09_F3(string solutionType, int ptype, int dtype, int ltype) } upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "LZ09_F3::LZ09_F3: Error reserving memory for storing the " << "variable lower limits" << endl; diff --git a/src/problems/LZ09/LZ09_F4.cpp b/src/problems/LZ09/LZ09_F4.cpp index 2b94772..2dc6f8d 100644 --- a/src/problems/LZ09/LZ09_F4.cpp +++ b/src/problems/LZ09/LZ09_F4.cpp @@ -37,7 +37,7 @@ LZ09_F4::LZ09_F4(string solutionType, int ptype, int dtype, int ltype) ltype) ; lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "LZ09_F4::LZ09_F4: Error reserving memory for storing the " << "variable lower limits" << endl; @@ -45,7 +45,7 @@ LZ09_F4::LZ09_F4(string solutionType, int ptype, int dtype, int ltype) } upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "LZ09_F4::LZ09_F4: Error reserving memory for storing the " << "variable lower limits" << endl; diff --git a/src/problems/LZ09/LZ09_F5.cpp b/src/problems/LZ09/LZ09_F5.cpp index 95e2d09..9091f51 100644 --- a/src/problems/LZ09/LZ09_F5.cpp +++ b/src/problems/LZ09/LZ09_F5.cpp @@ -37,7 +37,7 @@ LZ09_F5::LZ09_F5(string solutionType, int ptype, int dtype, int ltype) ltype) ; lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "LZ09_F5::LZ09_F5: Error reserving memory for storing the " << "variable lower limits" << endl; @@ -45,7 +45,7 @@ LZ09_F5::LZ09_F5(string solutionType, int ptype, int dtype, int ltype) } upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "LZ09_F5::LZ09_F5: Error reserving memory for storing the " << "variable lower limits" << endl; diff --git a/src/problems/LZ09/LZ09_F6.cpp b/src/problems/LZ09/LZ09_F6.cpp index 1862434..1da2db6 100644 --- a/src/problems/LZ09/LZ09_F6.cpp +++ b/src/problems/LZ09/LZ09_F6.cpp @@ -37,7 +37,7 @@ LZ09_F6::LZ09_F6(string solutionType, int ptype, int dtype, int ltype) ltype) ; lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "LZ09_F6::LZ09_F6: Error reserving memory for storing the " << "variable lower limits" << endl; @@ -45,7 +45,7 @@ LZ09_F6::LZ09_F6(string solutionType, int ptype, int dtype, int ltype) } upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "LZ09_F6::LZ09_F6: Error reserving memory for storing the " << "variable lower limits" << endl; diff --git a/src/problems/LZ09/LZ09_F7.cpp b/src/problems/LZ09/LZ09_F7.cpp index 4cb4a13..b339c7c 100644 --- a/src/problems/LZ09/LZ09_F7.cpp +++ b/src/problems/LZ09/LZ09_F7.cpp @@ -37,7 +37,7 @@ LZ09_F7::LZ09_F7(string solutionType, int ptype, int dtype, int ltype) ltype) ; lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "LZ09_F7::LZ09_F7: Error reserving memory for storing the " << "variable lower limits" << endl; @@ -45,7 +45,7 @@ LZ09_F7::LZ09_F7(string solutionType, int ptype, int dtype, int ltype) } upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "LZ09_F7::LZ09_F7: Error reserving memory for storing the " << "variable lower limits" << endl; diff --git a/src/problems/LZ09/LZ09_F8.cpp b/src/problems/LZ09/LZ09_F8.cpp index 23f1dd7..c9e8641 100644 --- a/src/problems/LZ09/LZ09_F8.cpp +++ b/src/problems/LZ09/LZ09_F8.cpp @@ -37,7 +37,7 @@ LZ09_F8::LZ09_F8(string solutionType, int ptype, int dtype, int ltype) ltype) ; lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "LZ09_F8::LZ09_F8: Error reserving memory for storing the " << "variable lower limits" << endl; @@ -45,7 +45,7 @@ LZ09_F8::LZ09_F8(string solutionType, int ptype, int dtype, int ltype) } upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "LZ09_F8::LZ09_F8: Error reserving memory for storing the " << "variable lower limits" << endl; diff --git a/src/problems/LZ09/LZ09_F9.cpp b/src/problems/LZ09/LZ09_F9.cpp index a4f9075..7e4c84e 100644 --- a/src/problems/LZ09/LZ09_F9.cpp +++ b/src/problems/LZ09/LZ09_F9.cpp @@ -37,7 +37,7 @@ LZ09_F9::LZ09_F9(string solutionType, int ptype, int dtype, int ltype) ltype) ; lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "LZ09_F9::LZ09_F9: Error reserving memory for storing the " << "variable lower limits" << endl; @@ -45,7 +45,7 @@ LZ09_F9::LZ09_F9(string solutionType, int ptype, int dtype, int ltype) } upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "LZ09_F9::LZ09_F9: Error reserving memory for storing the " << "variable lower limits" << endl; diff --git a/src/problems/ProblemFactory.cpp b/src/problems/ProblemFactory.cpp index 5bad382..aa4b9b2 100644 --- a/src/problems/ProblemFactory.cpp +++ b/src/problems/ProblemFactory.cpp @@ -28,7 +28,7 @@ */ Problem * ProblemFactory::getProblem(char * name) { - return getProblem(name, 0, NULL); + return getProblem(name, 0, nullptr); } @@ -42,7 +42,7 @@ Problem * ProblemFactory::getProblem(int argc, char ** argv) { if (argc==2) { - return getProblem(argv[1], 0, NULL); + return getProblem(argv[1], 0, nullptr); } else if (argc>2) { diff --git a/src/problems/Schaffer.cpp b/src/problems/Schaffer.cpp index 28f6da3..9d4d9f5 100644 --- a/src/problems/Schaffer.cpp +++ b/src/problems/Schaffer.cpp @@ -33,14 +33,14 @@ Schaffer::Schaffer(string solutionType) numberOfConstraints_ = 0; lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "Schaffer::Schaffer. Error reserving memory for storing the array of lower limits" << endl; exit(-1) ; } upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "Schaffer::Schaffer. Error reserving memory for storing the array of upper limits" << endl; exit(-1) ; @@ -80,7 +80,7 @@ void Schaffer::evaluate(Solution *solution) Variable **variables = solution->getDecisionVariables(); fx = new double[numberOfObjectives_]; - if (fx == NULL) + if (fx == nullptr) { cout << "Schaffer::evaluate: Error reserving memory while evaluating the problem" << endl; exit(-1); diff --git a/src/problems/Srinivas.cpp b/src/problems/Srinivas.cpp index e4c1354..3098c9f 100644 --- a/src/problems/Srinivas.cpp +++ b/src/problems/Srinivas.cpp @@ -34,14 +34,14 @@ Srinivas::Srinivas(string solutionType) problemName_ = "Srinivas"; lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "Srinivas::Srinivas. Error reserving memory for storing the array of lower limits" << endl; exit(-1) ; } upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "Srinivas::Srinivas. Error reserving memory for storing the array of upper limits" << endl; exit(-1) ; @@ -90,14 +90,14 @@ void Srinivas::evaluate(Solution *solution) Variable **variables = solution->getDecisionVariables(); double * fx = new double[numberOfObjectives_]; - if (fx == NULL) + if (fx == nullptr) { cout << "Srinivas::evaluate: Error reserving memory while evaluating the problem" << endl; exit(-1); } double * x = new double[numberOfVariables_]; - if (x == NULL) + if (x == nullptr) { cout << "Srinivas::evaluate: Error reserving memory for the variable values array" << endl; exit(-1); diff --git a/src/problems/Tanaka.cpp b/src/problems/Tanaka.cpp index dbcc398..f9e80f4 100644 --- a/src/problems/Tanaka.cpp +++ b/src/problems/Tanaka.cpp @@ -36,14 +36,14 @@ Tanaka::Tanaka(string solutionType) problemName_ = "Tanaka"; lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "Tanaka::Tanaka. Error reserving memory for storing the array of lower limits" << endl; exit(-1) ; } upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "Tanaka::Tanaka. Error reserving memory for storing the array of upper limits" << endl; exit(-1) ; @@ -92,7 +92,7 @@ void Tanaka::evaluate(Solution *solution) Variable **variables = solution->getDecisionVariables(); double * fx = new double[numberOfObjectives_]; - if (fx == NULL) + if (fx == nullptr) { cout << "Tanaka::evaluate: Error reserving memory while evaluating the problem" << endl; exit(-1); diff --git a/src/problems/ZDT/ZDT1.cpp b/src/problems/ZDT/ZDT1.cpp index 718236d..e3fc233 100644 --- a/src/problems/ZDT/ZDT1.cpp +++ b/src/problems/ZDT/ZDT1.cpp @@ -28,14 +28,14 @@ ZDT1::ZDT1(string solutionType, int numberOfVariables) problemName_ = "ZDT1"; lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); diff --git a/src/problems/ZDT/ZDT2.cpp b/src/problems/ZDT/ZDT2.cpp index ae25a4f..c8d9f9c 100644 --- a/src/problems/ZDT/ZDT2.cpp +++ b/src/problems/ZDT/ZDT2.cpp @@ -28,14 +28,14 @@ ZDT2::ZDT2(string solutionType, int numberOfVariables) problemName_ = "ZDT2"; lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); diff --git a/src/problems/ZDT/ZDT3.cpp b/src/problems/ZDT/ZDT3.cpp index 6518d63..40014d2 100644 --- a/src/problems/ZDT/ZDT3.cpp +++ b/src/problems/ZDT/ZDT3.cpp @@ -30,14 +30,14 @@ ZDT3::ZDT3(string solutionType, int numberOfVariables) problemName_ = "ZDT3"; lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); diff --git a/src/problems/ZDT/ZDT4.cpp b/src/problems/ZDT/ZDT4.cpp index 739d5a0..a453425 100644 --- a/src/problems/ZDT/ZDT4.cpp +++ b/src/problems/ZDT/ZDT4.cpp @@ -30,14 +30,14 @@ ZDT4::ZDT4(string solutionType, int numberOfVariables) problemName_ = "ZDT4"; lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); diff --git a/src/problems/ZDT/ZDT6.cpp b/src/problems/ZDT/ZDT6.cpp index f237647..4b0576c 100644 --- a/src/problems/ZDT/ZDT6.cpp +++ b/src/problems/ZDT/ZDT6.cpp @@ -30,14 +30,14 @@ ZDT6::ZDT6(string solutionType, int numberOfVariables) problemName_ = "ZDT6"; lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); diff --git a/src/problems/singleObjective/Griewank.cpp b/src/problems/singleObjective/Griewank.cpp index 7114e3c..1461ab1 100644 --- a/src/problems/singleObjective/Griewank.cpp +++ b/src/problems/singleObjective/Griewank.cpp @@ -36,14 +36,14 @@ Griewank::Griewank(string solutionType, int numberOfVariables) problemName_ = "Griewank"; lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "Griewank::Griewank. Error reserving memory for storing the array of lower limits" << endl; exit(-1) ; } // if upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "Griewank::Griewank. Error reserving memory for storing the array of upper limits" << endl; exit(-1) ; diff --git a/src/problems/singleObjective/Rastrigin.cpp b/src/problems/singleObjective/Rastrigin.cpp index 7964e9e..d07f86f 100644 --- a/src/problems/singleObjective/Rastrigin.cpp +++ b/src/problems/singleObjective/Rastrigin.cpp @@ -37,14 +37,14 @@ Rastrigin::Rastrigin(string solutionType, int numberOfVariables) problemName_ = "Rastrigin"; lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "Rastrigin::Rastrigin. Error reserving memory for storing the array of lower limits" << endl; exit(-1) ; } upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "Rastrigin::Rastrigin. Error reserving memory for storing the array of upper limits" << endl; exit(-1) ; @@ -83,14 +83,14 @@ void Rastrigin::evaluate(Solution *solution) Variable **variables = solution->getDecisionVariables(); double * fx = new double[numberOfObjectives_]; //(double *)malloc(sizeof(double) * numberOfObjectives_); - if (fx == NULL) + if (fx == nullptr) { cout << "Rastrigin::evaluate: Error reserving memory while evaluating the problem" << endl; exit(-1); } double * x = new double[numberOfVariables_]; - if (x == NULL) + if (x == nullptr) { cout << "Rastrigin::evaluate: Error reserving memory for the variable values array" << endl; exit(-1); diff --git a/src/problems/singleObjective/Rosenbrock.cpp b/src/problems/singleObjective/Rosenbrock.cpp index 7a4ad67..5b9125d 100644 --- a/src/problems/singleObjective/Rosenbrock.cpp +++ b/src/problems/singleObjective/Rosenbrock.cpp @@ -35,14 +35,14 @@ Rosenbrock::Rosenbrock(string solutionType, int numberOfVariables) problemName_ = "Rosenbrock"; lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "Rosenbrock::Rosenbrock. Error reserving memory for storing the array of lower limits" << endl; exit(-1) ; } upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "Rosenbrock::Rosenbrock. Error reserving memory for storing the array of upper limits" << endl; exit(-1) ; @@ -82,14 +82,14 @@ void Rosenbrock::evaluate(Solution *solution) Variable **variables = solution->getDecisionVariables(); double * fx = new double[numberOfObjectives_]; //(double *)malloc(sizeof(double) * numberOfObjectives_); - if (fx == NULL) + if (fx == nullptr) { cout << "Rosenbrock::evaluate: Error reserving memory while evaluating the problem" << endl; exit(-1); } double * x = new double[numberOfVariables_]; - if (x == NULL) + if (x == nullptr) { cout << "Rosenbrock::evaluate: Error reserving memory for the variable values array" << endl; exit(-1); diff --git a/src/problems/singleObjective/Sphere.cpp b/src/problems/singleObjective/Sphere.cpp index 26b631d..a4fc8e7 100644 --- a/src/problems/singleObjective/Sphere.cpp +++ b/src/problems/singleObjective/Sphere.cpp @@ -35,14 +35,14 @@ Sphere::Sphere(string solutionType, int numberOfVariables) problemName_ = "Sphere"; lowerLimit_ = new double[numberOfVariables_]; - if (lowerLimit_ == NULL) + if (lowerLimit_ == nullptr) { cout << "Sphere::Sphere. Error reserving memory for storing the array of lower limits" << endl; exit(-1) ; } upperLimit_ = new double[numberOfVariables_]; - if (upperLimit_ == NULL) + if (upperLimit_ == nullptr) { cout << "Sphere::Sphere. Error reserving memory for storing the array of upper limits" << endl; exit(-1) ; @@ -82,14 +82,14 @@ void Sphere::evaluate(Solution *solution) Variable **variables = solution->getDecisionVariables(); double * fx = new double[numberOfObjectives_]; //(double *)malloc(sizeof(double) * numberOfObjectives_); - if (fx == NULL) + if (fx == nullptr) { cout << "Sphere::evaluate: Error reserving memory while evaluating the problem" << endl; exit(-1); } double * x = new double[numberOfVariables_]; - if (x == NULL) + if (x == nullptr) { cout << "Sphere::evaluate: Error reserving memory for the variable values array" << endl; exit(-1); diff --git a/src/qualityIndicator/fastHypervolume/FastHypervolume.cpp b/src/qualityIndicator/fastHypervolume/FastHypervolume.cpp index b0fc266..e1092bd 100644 --- a/src/qualityIndicator/fastHypervolume/FastHypervolume.cpp +++ b/src/qualityIndicator/fastHypervolume/FastHypervolume.cpp @@ -27,7 +27,7 @@ */ FastHypervolume::FastHypervolume() { - referencePoint_ = NULL; + referencePoint_ = nullptr; numberOfObjectives_ = 0; } // FastHypervolume @@ -37,7 +37,7 @@ FastHypervolume::FastHypervolume() */ FastHypervolume::FastHypervolume(double offset) { - referencePoint_ = NULL; + referencePoint_ = nullptr; numberOfObjectives_ = 0; offset_ = offset; } // FastHypervolume diff --git a/src/util/PseudoRandom.cpp b/src/util/PseudoRandom.cpp index 8afe195..e5149e4 100644 --- a/src/util/PseudoRandom.cpp +++ b/src/util/PseudoRandom.cpp @@ -30,19 +30,19 @@ using namespace std; * random generator which will be accesible throug this interface. **/ -RandomGenerator * PseudoRandom::randomGenerator_ = NULL ; +RandomGenerator * PseudoRandom::randomGenerator_ = nullptr ; PseudoRandom::PseudoRandom() { - //randomGenerator_ = NULL ; - if (PseudoRandom::randomGenerator_ == NULL) + //randomGenerator_ = nullptr ; + if (PseudoRandom::randomGenerator_ == nullptr) { PseudoRandom::randomGenerator_ = new RandomGenerator(); } } //static int PseudoRandom::randInt() { -// if (randomGenerator_ == NULL) { +// if (randomGenerator_ == nullptr) { // new PseudoRandom(); // } // return randomGenerator_->rando @@ -50,7 +50,7 @@ PseudoRandom::PseudoRandom() double PseudoRandom::randDouble() { - if (PseudoRandom::randomGenerator_ == NULL) + if (PseudoRandom::randomGenerator_ == nullptr) { PseudoRandom::randomGenerator_ = new RandomGenerator(); } @@ -59,7 +59,7 @@ double PseudoRandom::randDouble() int PseudoRandom::randInt(int minBound, int maxBound) { - if (PseudoRandom::randomGenerator_ == NULL) + if (PseudoRandom::randomGenerator_ == nullptr) { PseudoRandom::randomGenerator_ = new RandomGenerator(); } @@ -68,7 +68,7 @@ int PseudoRandom::randInt(int minBound, int maxBound) double PseudoRandom::randDouble(double minBound, double maxBound) { - if (PseudoRandom::randomGenerator_ == NULL) + if (PseudoRandom::randomGenerator_ == nullptr) { PseudoRandom::randomGenerator_ = new RandomGenerator(); } diff --git a/src/util/RandomGenerator.cpp b/src/util/RandomGenerator.cpp index 3620e41..d45068b 100644 --- a/src/util/RandomGenerator.cpp +++ b/src/util/RandomGenerator.cpp @@ -33,7 +33,7 @@ using namespace std; RandomGenerator::RandomGenerator() { - srand(time(NULL)); + srand(time(nullptr)); //srand(0); //cout << (unsigned)time(0) << endl; seed_ = ((double) rand() / (double) (RAND_MAX )); diff --git a/src/util/Ranking.cpp b/src/util/Ranking.cpp index 9d0520b..ec8e033 100644 --- a/src/util/Ranking.cpp +++ b/src/util/Ranking.cpp @@ -49,7 +49,7 @@ Ranking::Ranking (SolutionSet * solutionSet) // dominateMe[i] contains the number of solutions dominating i int * dominateMe = new int[solutionSet_->size()]; - if (dominateMe == NULL) + if (dominateMe == nullptr) { cout << "Fatal Problem: Cannot reserve memory in class Ranking" << endl; exit(-1); @@ -128,7 +128,7 @@ Ranking::Ranking (SolutionSet * solutionSet) } // while ranking_ = new SolutionSet*[i]; - if (ranking_ == NULL) + if (ranking_ == nullptr) { cout << "Fatal Error: Impossible to reserve memory in Ranking" << endl; exit(-1); diff --git a/src/util/comparators/CrowdingComparator.cpp b/src/util/comparators/CrowdingComparator.cpp index 4d40b15..dc1c14c 100644 --- a/src/util/comparators/CrowdingComparator.cpp +++ b/src/util/comparators/CrowdingComparator.cpp @@ -52,9 +52,9 @@ CrowdingComparator::~CrowdingComparator() int CrowdingComparator::compare(void *o1, void *o2) { - if (o1 == NULL) + if (o1 == nullptr) return 1; - else if (o2 == NULL) + else if (o2 == nullptr) return -1; int flagComparatorRank = comparator->compare(o1,o2); diff --git a/src/util/comparators/CrowdingDistanceComparator.cpp b/src/util/comparators/CrowdingDistanceComparator.cpp index 377967f..0df9daa 100644 --- a/src/util/comparators/CrowdingDistanceComparator.cpp +++ b/src/util/comparators/CrowdingDistanceComparator.cpp @@ -32,9 +32,9 @@ int CrowdingDistanceComparator::compare(void *o1, void *o2) { - if (o1 == NULL) + if (o1 == nullptr) return 1; - else if (o2 == NULL) + else if (o2 == nullptr) return -1; double distance1 = ((Solution *) o1)->getCrowdingDistance(); diff --git a/src/util/comparators/DominanceComparator.cpp b/src/util/comparators/DominanceComparator.cpp index 4c1e441..b97c2e4 100644 --- a/src/util/comparators/DominanceComparator.cpp +++ b/src/util/comparators/DominanceComparator.cpp @@ -59,9 +59,9 @@ DominanceComparator::~DominanceComparator() int DominanceComparator::compare(void * o1, void * o2) { - if (o1==NULL) + if (o1==nullptr) return 1; - else if (o2 == NULL) + else if (o2 == nullptr) return -1; Solution * one = (Solution *) o1; diff --git a/src/util/comparators/EpsilonDominanceComparator.cpp b/src/util/comparators/EpsilonDominanceComparator.cpp index a94f86f..9525875 100644 --- a/src/util/comparators/EpsilonDominanceComparator.cpp +++ b/src/util/comparators/EpsilonDominanceComparator.cpp @@ -53,9 +53,9 @@ EpsilonDominanceComparator::~EpsilonDominanceComparator() int EpsilonDominanceComparator::compare(void *o1, void *o2) { - if (o1==NULL) + if (o1==nullptr) return 1; - else if (o2 == NULL) + else if (o2 == nullptr) return -1; Solution * solution1 = (Solution *) o1; diff --git a/src/util/comparators/EpsilonObjectiveComparator.cpp b/src/util/comparators/EpsilonObjectiveComparator.cpp index dfede8d..807540c 100644 --- a/src/util/comparators/EpsilonObjectiveComparator.cpp +++ b/src/util/comparators/EpsilonObjectiveComparator.cpp @@ -48,9 +48,9 @@ EpsilonObjectiveComparator::EpsilonObjectiveComparator(int nObj, double eta) : C int EpsilonObjectiveComparator::compare(void *o1, void *o2) { - if (o1==NULL) + if (o1==nullptr) return 1; - else if (o2 == NULL) + else if (o2 == nullptr) return -1; double objetive1 = ((Solution *) o1)->getObjective(objective_); diff --git a/src/util/comparators/EqualSolutions.cpp b/src/util/comparators/EqualSolutions.cpp index 140f7c5..024eced 100644 --- a/src/util/comparators/EqualSolutions.cpp +++ b/src/util/comparators/EqualSolutions.cpp @@ -41,9 +41,9 @@ int EqualSolutions::compare(void * o1, void * o2) { - if (o1==NULL) + if (o1==nullptr) return 1; - else if (o2 == NULL) + else if (o2 == nullptr) return -1; int dominate1 ; // dominate1 indicates if some objective of solution1 diff --git a/src/util/comparators/ObjectiveComparator.cpp b/src/util/comparators/ObjectiveComparator.cpp index 9f4aaa6..49f89e2 100644 --- a/src/util/comparators/ObjectiveComparator.cpp +++ b/src/util/comparators/ObjectiveComparator.cpp @@ -52,9 +52,9 @@ ObjectiveComparator::ObjectiveComparator(int nObj, bool descendingOrder) **/ int ObjectiveComparator::compare(void *o1, void *o2) { - if (o1==NULL) + if (o1==nullptr) return 1; - else if (o2 == NULL) + else if (o2 == nullptr) return -1; double objetive1 = ((Solution *) o1)->getObjective(this->nObj); diff --git a/src/util/comparators/RankComparator.cpp b/src/util/comparators/RankComparator.cpp index f3e17a3..ea10c29 100644 --- a/src/util/comparators/RankComparator.cpp +++ b/src/util/comparators/RankComparator.cpp @@ -32,9 +32,9 @@ int RankComparator::compare(void *o1, void *o2) { - if (o1 == NULL) + if (o1 == nullptr) return 1; - else if (o2 == NULL) + else if (o2 == nullptr) return -1; Solution * solution1 = (Solution *) o1; From 47ce490806e7e304fec4822daa5ec7b4978e06ec Mon Sep 17 00:00:00 2001 From: Sergio Vieira Date: Thu, 27 Jul 2017 16:13:07 -0300 Subject: [PATCH 08/29] - Adds new author --- src/encodings/variable/ArrayReal.cpp | 1 + src/encodings/variable/ArrayReal.h | 1 + src/encodings/variable/Binary.cpp | 1 + src/encodings/variable/Binary.h | 1 + src/encodings/variable/BinaryReal.cpp | 1 + src/encodings/variable/BinaryReal.h | 1 + src/experiments/Experiment.cpp | 1 + src/experiments/Experiment.h | 1 + src/experiments/ExperimentExecution.cpp | 1 + src/experiments/ExperimentExecution.h | 1 + src/experiments/ExperimentIndividual.cpp | 1 + src/experiments/ExperimentIndividual.h | 1 + src/experiments/ExperimentReport.cpp | 1 + src/experiments/ExperimentReport.h | 1 + src/experiments/main/StandardStudyExecution.cpp | 1 + src/experiments/main/StandardStudyExecution.h | 1 + src/experiments/main/StandardStudyExecutionSO.cpp | 1 + src/experiments/main/StandardStudyExecutionSO.h | 1 + src/experiments/main/StandardStudyReportPF.cpp | 1 + src/experiments/main/StandardStudyReportPF.h | 1 + src/experiments/main/StandardStudyReportRF.cpp | 1 + src/experiments/main/StandardStudyReportRF.h | 1 + src/experiments/main/StandardStudyReportSO.cpp | 1 + src/experiments/main/StandardStudyReportSO.h | 1 + src/experiments/settings/DE_Settings.cpp | 1 + src/experiments/settings/DE_Settings.h | 1 + src/experiments/settings/GDE3_Settings.cpp | 1 + src/experiments/settings/GDE3_Settings.h | 1 + src/experiments/settings/PSO_Settings.cpp | 1 + src/experiments/settings/PSO_Settings.h | 1 + src/experiments/settings/SMPSO_Settings.cpp | 1 + src/experiments/settings/SMPSO_Settings.h | 1 + src/experiments/settings/gGA_Settings.cpp | 1 + src/experiments/settings/gGA_Settings.h | 1 + src/experiments/settings/ssGA_Settings.cpp | 1 + src/experiments/settings/ssGA_Settings.h | 1 + src/experiments/util/FileUtils.cpp | 1 + src/experiments/util/FileUtils.h | 1 + src/experiments/util/RBoxplot.cpp | 1 + src/experiments/util/RBoxplot.h | 1 + src/experiments/util/RWilcoxon.cpp | 1 + src/experiments/util/RWilcoxon.h | 1 + src/experiments/util/RunExperiment.cpp | 1 + src/experiments/util/RunExperiment.h | 1 + src/experiments/util/Statistics.cpp | 1 + src/experiments/util/Statistics.h | 1 + src/main/CMAES_main.cpp | 1 + src/main/DE_main.cpp | 1 + src/main/GDE3_main.cpp | 1 + src/main/MOEAD_main.cpp | 1 + src/main/NSGAII_main.cpp | 1 + src/main/OMOPSO_main.cpp | 1 + src/main/PSO_main.cpp | 1 + src/main/SMPSO_main.cpp | 1 + src/main/SMPSOhv_main.cpp | 1 + src/main/StandardPSO2007_main.cpp | 1 + src/main/StandardPSO2011_main.cpp | 1 + src/main/ssGA_main.cpp | 1 + src/main/ssNSGAII_main.cpp | 1 + src/metaheuristics/gde3/GDE3.cpp | 1 + src/metaheuristics/gde3/GDE3.h | 1 + src/metaheuristics/moead/MOEAD.cpp | 1 + src/metaheuristics/moead/MOEAD.h | 1 + src/metaheuristics/moead/UtilsMOEAD.cpp | 1 + src/metaheuristics/moead/UtilsMOEAD.h | 1 + src/metaheuristics/nsgaII/NSGAII.cpp | 1 + src/metaheuristics/nsgaII/NSGAII.h | 1 + src/metaheuristics/nsgaII/ssNSGAII.cpp | 1 + src/metaheuristics/nsgaII/ssNSGAII.h | 1 + src/metaheuristics/omopso/OMOPSO.cpp | 1 + src/metaheuristics/omopso/OMOPSO.h | 1 + src/metaheuristics/singleObjective/cmaes/CMAES.cpp | 1 + src/metaheuristics/singleObjective/cmaes/CMAES.h | 1 + src/metaheuristics/singleObjective/cmaes/utils/UtilsCMAES.cpp | 1 + src/metaheuristics/singleObjective/cmaes/utils/UtilsCMAES.h | 1 + src/metaheuristics/singleObjective/differentialEvolution/DE.cpp | 1 + src/metaheuristics/singleObjective/differentialEvolution/DE.h | 1 + src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.cpp | 1 + src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.h | 1 + .../singleObjective/particleSwarmOptimization/PSO.cpp | 1 + .../singleObjective/particleSwarmOptimization/PSO.h | 1 + .../particleSwarmOptimization/StandardPSO2007.cpp | 1 + .../singleObjective/particleSwarmOptimization/StandardPSO2007.h | 1 + .../particleSwarmOptimization/StandardPSO2011.cpp | 1 + .../singleObjective/particleSwarmOptimization/StandardPSO2011.h | 1 + src/metaheuristics/smpso/SMPSO.cpp | 1 + src/metaheuristics/smpso/SMPSO.h | 1 + src/metaheuristics/smpso/SMPSOhv.cpp | 1 + src/metaheuristics/smpso/SMPSOhv.h | 1 + src/metaheuristics/smsemoa/FastSMSEMOA.cpp | 1 + src/metaheuristics/smsemoa/FastSMSEMOA.h | 1 + src/operators/crossover/DifferentialEvolutionCrossover.cpp | 1 + src/operators/crossover/DifferentialEvolutionCrossover.h | 1 + src/operators/mutation/NonUniformMutation.cpp | 1 + src/operators/mutation/NonUniformMutation.h | 1 + src/util/PseudoRandom.h | 1 + 96 files changed, 96 insertions(+) diff --git a/src/encodings/variable/ArrayReal.cpp b/src/encodings/variable/ArrayReal.cpp index 9b9e8ec..df9dd4c 100644 --- a/src/encodings/variable/ArrayReal.cpp +++ b/src/encodings/variable/ArrayReal.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/encodings/variable/ArrayReal.h b/src/encodings/variable/ArrayReal.h index 87c5b35..d66316c 100644 --- a/src/encodings/variable/ArrayReal.h +++ b/src/encodings/variable/ArrayReal.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/encodings/variable/Binary.cpp b/src/encodings/variable/Binary.cpp index ee41073..c1af27e 100644 --- a/src/encodings/variable/Binary.cpp +++ b/src/encodings/variable/Binary.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/encodings/variable/Binary.h b/src/encodings/variable/Binary.h index e955354..b7c5b37 100644 --- a/src/encodings/variable/Binary.h +++ b/src/encodings/variable/Binary.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/encodings/variable/BinaryReal.cpp b/src/encodings/variable/BinaryReal.cpp index c6c5aba..687d201 100644 --- a/src/encodings/variable/BinaryReal.cpp +++ b/src/encodings/variable/BinaryReal.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/encodings/variable/BinaryReal.h b/src/encodings/variable/BinaryReal.h index c8aa5a9..e2e07e3 100644 --- a/src/encodings/variable/BinaryReal.h +++ b/src/encodings/variable/BinaryReal.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/Experiment.cpp b/src/experiments/Experiment.cpp index cc1c6c2..559f080 100644 --- a/src/experiments/Experiment.cpp +++ b/src/experiments/Experiment.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/Experiment.h b/src/experiments/Experiment.h index e1d415b..7aeaeea 100644 --- a/src/experiments/Experiment.h +++ b/src/experiments/Experiment.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/ExperimentExecution.cpp b/src/experiments/ExperimentExecution.cpp index 1cfea78..681b98f 100644 --- a/src/experiments/ExperimentExecution.cpp +++ b/src/experiments/ExperimentExecution.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/ExperimentExecution.h b/src/experiments/ExperimentExecution.h index 879675b..488e2f3 100644 --- a/src/experiments/ExperimentExecution.h +++ b/src/experiments/ExperimentExecution.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/ExperimentIndividual.cpp b/src/experiments/ExperimentIndividual.cpp index 22f29a8..dac87bd 100644 --- a/src/experiments/ExperimentIndividual.cpp +++ b/src/experiments/ExperimentIndividual.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/ExperimentIndividual.h b/src/experiments/ExperimentIndividual.h index 13c9879..0304437 100644 --- a/src/experiments/ExperimentIndividual.h +++ b/src/experiments/ExperimentIndividual.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/ExperimentReport.cpp b/src/experiments/ExperimentReport.cpp index ba9a8f3..b083bf5 100644 --- a/src/experiments/ExperimentReport.cpp +++ b/src/experiments/ExperimentReport.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/ExperimentReport.h b/src/experiments/ExperimentReport.h index 7d5d126..70f21b1 100644 --- a/src/experiments/ExperimentReport.h +++ b/src/experiments/ExperimentReport.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/main/StandardStudyExecution.cpp b/src/experiments/main/StandardStudyExecution.cpp index 26edbb9..64e21f5 100644 --- a/src/experiments/main/StandardStudyExecution.cpp +++ b/src/experiments/main/StandardStudyExecution.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/main/StandardStudyExecution.h b/src/experiments/main/StandardStudyExecution.h index c69fe70..e535aa3 100644 --- a/src/experiments/main/StandardStudyExecution.h +++ b/src/experiments/main/StandardStudyExecution.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/main/StandardStudyExecutionSO.cpp b/src/experiments/main/StandardStudyExecutionSO.cpp index 450e9fc..d50d2cd 100644 --- a/src/experiments/main/StandardStudyExecutionSO.cpp +++ b/src/experiments/main/StandardStudyExecutionSO.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/main/StandardStudyExecutionSO.h b/src/experiments/main/StandardStudyExecutionSO.h index f5cd012..8f19baf 100644 --- a/src/experiments/main/StandardStudyExecutionSO.h +++ b/src/experiments/main/StandardStudyExecutionSO.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/main/StandardStudyReportPF.cpp b/src/experiments/main/StandardStudyReportPF.cpp index 6cd00a6..60964e5 100644 --- a/src/experiments/main/StandardStudyReportPF.cpp +++ b/src/experiments/main/StandardStudyReportPF.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/main/StandardStudyReportPF.h b/src/experiments/main/StandardStudyReportPF.h index 6a2a043..9d88ac2 100644 --- a/src/experiments/main/StandardStudyReportPF.h +++ b/src/experiments/main/StandardStudyReportPF.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/main/StandardStudyReportRF.cpp b/src/experiments/main/StandardStudyReportRF.cpp index 1b4e566..e4719b2 100644 --- a/src/experiments/main/StandardStudyReportRF.cpp +++ b/src/experiments/main/StandardStudyReportRF.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/main/StandardStudyReportRF.h b/src/experiments/main/StandardStudyReportRF.h index 9c02d16..239173d 100644 --- a/src/experiments/main/StandardStudyReportRF.h +++ b/src/experiments/main/StandardStudyReportRF.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/main/StandardStudyReportSO.cpp b/src/experiments/main/StandardStudyReportSO.cpp index bd2c343..5c79fab 100644 --- a/src/experiments/main/StandardStudyReportSO.cpp +++ b/src/experiments/main/StandardStudyReportSO.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/main/StandardStudyReportSO.h b/src/experiments/main/StandardStudyReportSO.h index ab64ce9..d6ba028 100644 --- a/src/experiments/main/StandardStudyReportSO.h +++ b/src/experiments/main/StandardStudyReportSO.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/settings/DE_Settings.cpp b/src/experiments/settings/DE_Settings.cpp index 9a61715..c667b3d 100644 --- a/src/experiments/settings/DE_Settings.cpp +++ b/src/experiments/settings/DE_Settings.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/settings/DE_Settings.h b/src/experiments/settings/DE_Settings.h index a0eec58..06ed24c 100644 --- a/src/experiments/settings/DE_Settings.h +++ b/src/experiments/settings/DE_Settings.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/settings/GDE3_Settings.cpp b/src/experiments/settings/GDE3_Settings.cpp index 639540d..d2cfc47 100644 --- a/src/experiments/settings/GDE3_Settings.cpp +++ b/src/experiments/settings/GDE3_Settings.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/settings/GDE3_Settings.h b/src/experiments/settings/GDE3_Settings.h index c06c62b..2c02637 100644 --- a/src/experiments/settings/GDE3_Settings.h +++ b/src/experiments/settings/GDE3_Settings.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/settings/PSO_Settings.cpp b/src/experiments/settings/PSO_Settings.cpp index e6438f5..e3c6fa0 100644 --- a/src/experiments/settings/PSO_Settings.cpp +++ b/src/experiments/settings/PSO_Settings.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/settings/PSO_Settings.h b/src/experiments/settings/PSO_Settings.h index 5f70482..cfb2ea1 100644 --- a/src/experiments/settings/PSO_Settings.h +++ b/src/experiments/settings/PSO_Settings.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/settings/SMPSO_Settings.cpp b/src/experiments/settings/SMPSO_Settings.cpp index b9f2662..c012d80 100644 --- a/src/experiments/settings/SMPSO_Settings.cpp +++ b/src/experiments/settings/SMPSO_Settings.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/settings/SMPSO_Settings.h b/src/experiments/settings/SMPSO_Settings.h index a803b37..2eded47 100644 --- a/src/experiments/settings/SMPSO_Settings.h +++ b/src/experiments/settings/SMPSO_Settings.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/settings/gGA_Settings.cpp b/src/experiments/settings/gGA_Settings.cpp index 71d4139..3a100f8 100644 --- a/src/experiments/settings/gGA_Settings.cpp +++ b/src/experiments/settings/gGA_Settings.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/settings/gGA_Settings.h b/src/experiments/settings/gGA_Settings.h index 5ba385f..5cb35bc 100644 --- a/src/experiments/settings/gGA_Settings.h +++ b/src/experiments/settings/gGA_Settings.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/settings/ssGA_Settings.cpp b/src/experiments/settings/ssGA_Settings.cpp index 8956718..572fa30 100644 --- a/src/experiments/settings/ssGA_Settings.cpp +++ b/src/experiments/settings/ssGA_Settings.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/settings/ssGA_Settings.h b/src/experiments/settings/ssGA_Settings.h index ff2cc4a..fb0fc1b 100644 --- a/src/experiments/settings/ssGA_Settings.h +++ b/src/experiments/settings/ssGA_Settings.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/util/FileUtils.cpp b/src/experiments/util/FileUtils.cpp index fa44032..8614264 100644 --- a/src/experiments/util/FileUtils.cpp +++ b/src/experiments/util/FileUtils.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/util/FileUtils.h b/src/experiments/util/FileUtils.h index 270c7f8..24843b2 100644 --- a/src/experiments/util/FileUtils.h +++ b/src/experiments/util/FileUtils.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/util/RBoxplot.cpp b/src/experiments/util/RBoxplot.cpp index ed1c8e5..fb879cb 100644 --- a/src/experiments/util/RBoxplot.cpp +++ b/src/experiments/util/RBoxplot.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/util/RBoxplot.h b/src/experiments/util/RBoxplot.h index 9aa1e0b..5f9c74c 100644 --- a/src/experiments/util/RBoxplot.h +++ b/src/experiments/util/RBoxplot.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/util/RWilcoxon.cpp b/src/experiments/util/RWilcoxon.cpp index 3ad707f..e714663 100644 --- a/src/experiments/util/RWilcoxon.cpp +++ b/src/experiments/util/RWilcoxon.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/util/RWilcoxon.h b/src/experiments/util/RWilcoxon.h index 4bc64c3..69d7b4a 100644 --- a/src/experiments/util/RWilcoxon.h +++ b/src/experiments/util/RWilcoxon.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/util/RunExperiment.cpp b/src/experiments/util/RunExperiment.cpp index b38c3ee..69220b1 100644 --- a/src/experiments/util/RunExperiment.cpp +++ b/src/experiments/util/RunExperiment.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/util/RunExperiment.h b/src/experiments/util/RunExperiment.h index bdb89f8..bc1e1dd 100644 --- a/src/experiments/util/RunExperiment.h +++ b/src/experiments/util/RunExperiment.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/util/Statistics.cpp b/src/experiments/util/Statistics.cpp index 6d8c816..829c2ba 100644 --- a/src/experiments/util/Statistics.cpp +++ b/src/experiments/util/Statistics.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/experiments/util/Statistics.h b/src/experiments/util/Statistics.h index d682a53..159cfc8 100644 --- a/src/experiments/util/Statistics.h +++ b/src/experiments/util/Statistics.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/main/CMAES_main.cpp b/src/main/CMAES_main.cpp index 275fc04..fd36aa5 100644 --- a/src/main/CMAES_main.cpp +++ b/src/main/CMAES_main.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/main/DE_main.cpp b/src/main/DE_main.cpp index 6689a78..a96b431 100644 --- a/src/main/DE_main.cpp +++ b/src/main/DE_main.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/main/GDE3_main.cpp b/src/main/GDE3_main.cpp index 4873199..8ba2a5a 100644 --- a/src/main/GDE3_main.cpp +++ b/src/main/GDE3_main.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/main/MOEAD_main.cpp b/src/main/MOEAD_main.cpp index 0aaed16..db9c9d9 100644 --- a/src/main/MOEAD_main.cpp +++ b/src/main/MOEAD_main.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/main/NSGAII_main.cpp b/src/main/NSGAII_main.cpp index f672ef7..fcf5764 100644 --- a/src/main/NSGAII_main.cpp +++ b/src/main/NSGAII_main.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/main/OMOPSO_main.cpp b/src/main/OMOPSO_main.cpp index 571bbd9..ab93283 100644 --- a/src/main/OMOPSO_main.cpp +++ b/src/main/OMOPSO_main.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2014 Antonio J. Nebro // diff --git a/src/main/PSO_main.cpp b/src/main/PSO_main.cpp index 3123611..dd78c7d 100644 --- a/src/main/PSO_main.cpp +++ b/src/main/PSO_main.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/main/SMPSO_main.cpp b/src/main/SMPSO_main.cpp index 61835a0..a667b48 100644 --- a/src/main/SMPSO_main.cpp +++ b/src/main/SMPSO_main.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/main/SMPSOhv_main.cpp b/src/main/SMPSOhv_main.cpp index 7cd2999..aee4b86 100644 --- a/src/main/SMPSOhv_main.cpp +++ b/src/main/SMPSOhv_main.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2014 Antonio J. Nebro // diff --git a/src/main/StandardPSO2007_main.cpp b/src/main/StandardPSO2007_main.cpp index 84c8242..dcd53c8 100644 --- a/src/main/StandardPSO2007_main.cpp +++ b/src/main/StandardPSO2007_main.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // Antonio J. Nebro // // Copyright (c) 2014 Antonio J. Nebro diff --git a/src/main/StandardPSO2011_main.cpp b/src/main/StandardPSO2011_main.cpp index 2d202ab..58e1e3a 100644 --- a/src/main/StandardPSO2011_main.cpp +++ b/src/main/StandardPSO2011_main.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // Antonio J. Nebro // // Copyright (c) 2014 Antonio J. Nebro diff --git a/src/main/ssGA_main.cpp b/src/main/ssGA_main.cpp index f401170..4a3d180 100644 --- a/src/main/ssGA_main.cpp +++ b/src/main/ssGA_main.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/main/ssNSGAII_main.cpp b/src/main/ssNSGAII_main.cpp index 6163019..63f5bbd 100644 --- a/src/main/ssNSGAII_main.cpp +++ b/src/main/ssNSGAII_main.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/metaheuristics/gde3/GDE3.cpp b/src/metaheuristics/gde3/GDE3.cpp index 3c54d7d..b84d84a 100644 --- a/src/metaheuristics/gde3/GDE3.cpp +++ b/src/metaheuristics/gde3/GDE3.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/metaheuristics/gde3/GDE3.h b/src/metaheuristics/gde3/GDE3.h index 2119f27..d379d1b 100644 --- a/src/metaheuristics/gde3/GDE3.h +++ b/src/metaheuristics/gde3/GDE3.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/metaheuristics/moead/MOEAD.cpp b/src/metaheuristics/moead/MOEAD.cpp index afe0e24..771478d 100644 --- a/src/metaheuristics/moead/MOEAD.cpp +++ b/src/metaheuristics/moead/MOEAD.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/metaheuristics/moead/MOEAD.h b/src/metaheuristics/moead/MOEAD.h index 0ee5c39..3794a19 100644 --- a/src/metaheuristics/moead/MOEAD.h +++ b/src/metaheuristics/moead/MOEAD.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/metaheuristics/moead/UtilsMOEAD.cpp b/src/metaheuristics/moead/UtilsMOEAD.cpp index d00486f..e064ecc 100644 --- a/src/metaheuristics/moead/UtilsMOEAD.cpp +++ b/src/metaheuristics/moead/UtilsMOEAD.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/metaheuristics/moead/UtilsMOEAD.h b/src/metaheuristics/moead/UtilsMOEAD.h index f1afd52..b56fd67 100644 --- a/src/metaheuristics/moead/UtilsMOEAD.h +++ b/src/metaheuristics/moead/UtilsMOEAD.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/metaheuristics/nsgaII/NSGAII.cpp b/src/metaheuristics/nsgaII/NSGAII.cpp index d2c3bde..972446b 100644 --- a/src/metaheuristics/nsgaII/NSGAII.cpp +++ b/src/metaheuristics/nsgaII/NSGAII.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/metaheuristics/nsgaII/NSGAII.h b/src/metaheuristics/nsgaII/NSGAII.h index 017e165..cff502e 100644 --- a/src/metaheuristics/nsgaII/NSGAII.h +++ b/src/metaheuristics/nsgaII/NSGAII.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/metaheuristics/nsgaII/ssNSGAII.cpp b/src/metaheuristics/nsgaII/ssNSGAII.cpp index 0fdc7d2..9604911 100644 --- a/src/metaheuristics/nsgaII/ssNSGAII.cpp +++ b/src/metaheuristics/nsgaII/ssNSGAII.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/metaheuristics/nsgaII/ssNSGAII.h b/src/metaheuristics/nsgaII/ssNSGAII.h index 9756090..d56f8ea 100644 --- a/src/metaheuristics/nsgaII/ssNSGAII.h +++ b/src/metaheuristics/nsgaII/ssNSGAII.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/metaheuristics/omopso/OMOPSO.cpp b/src/metaheuristics/omopso/OMOPSO.cpp index 762630b..09eabd7 100644 --- a/src/metaheuristics/omopso/OMOPSO.cpp +++ b/src/metaheuristics/omopso/OMOPSO.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2014 Antonio J. Nebro // diff --git a/src/metaheuristics/omopso/OMOPSO.h b/src/metaheuristics/omopso/OMOPSO.h index 33e1c57..ab6acd8 100644 --- a/src/metaheuristics/omopso/OMOPSO.h +++ b/src/metaheuristics/omopso/OMOPSO.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2014 Antonio J. Nebro // diff --git a/src/metaheuristics/singleObjective/cmaes/CMAES.cpp b/src/metaheuristics/singleObjective/cmaes/CMAES.cpp index 0d8203f..e3f6aa8 100644 --- a/src/metaheuristics/singleObjective/cmaes/CMAES.cpp +++ b/src/metaheuristics/singleObjective/cmaes/CMAES.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/metaheuristics/singleObjective/cmaes/CMAES.h b/src/metaheuristics/singleObjective/cmaes/CMAES.h index e9e7f8d..2150a7c 100644 --- a/src/metaheuristics/singleObjective/cmaes/CMAES.h +++ b/src/metaheuristics/singleObjective/cmaes/CMAES.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/metaheuristics/singleObjective/cmaes/utils/UtilsCMAES.cpp b/src/metaheuristics/singleObjective/cmaes/utils/UtilsCMAES.cpp index e523976..e5d733c 100644 --- a/src/metaheuristics/singleObjective/cmaes/utils/UtilsCMAES.cpp +++ b/src/metaheuristics/singleObjective/cmaes/utils/UtilsCMAES.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/metaheuristics/singleObjective/cmaes/utils/UtilsCMAES.h b/src/metaheuristics/singleObjective/cmaes/utils/UtilsCMAES.h index 8f744ce..66e8854 100644 --- a/src/metaheuristics/singleObjective/cmaes/utils/UtilsCMAES.h +++ b/src/metaheuristics/singleObjective/cmaes/utils/UtilsCMAES.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/metaheuristics/singleObjective/differentialEvolution/DE.cpp b/src/metaheuristics/singleObjective/differentialEvolution/DE.cpp index 9b6a9b9..e81dda0 100644 --- a/src/metaheuristics/singleObjective/differentialEvolution/DE.cpp +++ b/src/metaheuristics/singleObjective/differentialEvolution/DE.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/metaheuristics/singleObjective/differentialEvolution/DE.h b/src/metaheuristics/singleObjective/differentialEvolution/DE.h index 3e78742..03e0f66 100644 --- a/src/metaheuristics/singleObjective/differentialEvolution/DE.h +++ b/src/metaheuristics/singleObjective/differentialEvolution/DE.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.cpp b/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.cpp index 761913d..c228da7 100644 --- a/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.cpp +++ b/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.h b/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.h index ffca3ff..460ac98 100644 --- a/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.h +++ b/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp b/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp index e89093a..6a24fef 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.h b/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.h index a12936a..78d4864 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.h +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp index 34af3b8..2bfcf2c 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // Antonio J. Nebro // // Copyright (c) 2014 Antonio J. Nebro diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.h b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.h index 9b17fdb..e76568f 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.h +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // Antonio J. Nebro // // Copyright (c) 2014 Antonio J. Nebro diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp index ba33f4f..69ff193 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // Antonio J. Nebro // // Copyright (c) 2014 Antonio J. Nebro diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.h b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.h index 5c41dd4..fbe584e 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.h +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // Antonio J. Nebro // // Copyright (c) 2014 Antonio J. Nebro diff --git a/src/metaheuristics/smpso/SMPSO.cpp b/src/metaheuristics/smpso/SMPSO.cpp index 31efdf5..5de1ad5 100644 --- a/src/metaheuristics/smpso/SMPSO.cpp +++ b/src/metaheuristics/smpso/SMPSO.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/metaheuristics/smpso/SMPSO.h b/src/metaheuristics/smpso/SMPSO.h index 4ec17d4..a015f77 100644 --- a/src/metaheuristics/smpso/SMPSO.h +++ b/src/metaheuristics/smpso/SMPSO.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/metaheuristics/smpso/SMPSOhv.cpp b/src/metaheuristics/smpso/SMPSOhv.cpp index b9bd39b..30fc87d 100644 --- a/src/metaheuristics/smpso/SMPSOhv.cpp +++ b/src/metaheuristics/smpso/SMPSOhv.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2014 Antonio J. Nebro // diff --git a/src/metaheuristics/smpso/SMPSOhv.h b/src/metaheuristics/smpso/SMPSOhv.h index 1233382..a71882f 100644 --- a/src/metaheuristics/smpso/SMPSOhv.h +++ b/src/metaheuristics/smpso/SMPSOhv.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2014 Antonio J. Nebro // diff --git a/src/metaheuristics/smsemoa/FastSMSEMOA.cpp b/src/metaheuristics/smsemoa/FastSMSEMOA.cpp index 16f5f77..be620c2 100644 --- a/src/metaheuristics/smsemoa/FastSMSEMOA.cpp +++ b/src/metaheuristics/smsemoa/FastSMSEMOA.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2014 Antonio J. Nebro // diff --git a/src/metaheuristics/smsemoa/FastSMSEMOA.h b/src/metaheuristics/smsemoa/FastSMSEMOA.h index b07e9bf..309aa7d 100644 --- a/src/metaheuristics/smsemoa/FastSMSEMOA.h +++ b/src/metaheuristics/smsemoa/FastSMSEMOA.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2014 Antonio J. Nebro // diff --git a/src/operators/crossover/DifferentialEvolutionCrossover.cpp b/src/operators/crossover/DifferentialEvolutionCrossover.cpp index 9bd82da..a13fa5b 100644 --- a/src/operators/crossover/DifferentialEvolutionCrossover.cpp +++ b/src/operators/crossover/DifferentialEvolutionCrossover.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/operators/crossover/DifferentialEvolutionCrossover.h b/src/operators/crossover/DifferentialEvolutionCrossover.h index 0aa708f..a5344b0 100644 --- a/src/operators/crossover/DifferentialEvolutionCrossover.h +++ b/src/operators/crossover/DifferentialEvolutionCrossover.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // diff --git a/src/operators/mutation/NonUniformMutation.cpp b/src/operators/mutation/NonUniformMutation.cpp index 338bc0a..ff00f17 100644 --- a/src/operators/mutation/NonUniformMutation.cpp +++ b/src/operators/mutation/NonUniformMutation.cpp @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2014 Antonio J. Nebro // diff --git a/src/operators/mutation/NonUniformMutation.h b/src/operators/mutation/NonUniformMutation.h index b08f409..30cf6e5 100644 --- a/src/operators/mutation/NonUniformMutation.h +++ b/src/operators/mutation/NonUniformMutation.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // // Copyright (c) 2014 Antonio J. Nebro // diff --git a/src/util/PseudoRandom.h b/src/util/PseudoRandom.h index ba08966..3cbe031 100644 --- a/src/util/PseudoRandom.h +++ b/src/util/PseudoRandom.h @@ -2,6 +2,7 @@ // // Author: // Esteban López-Camacho +// Sérgio Vieira // Antonio J. Nebro // Juan J. Durillo // From 74cafac42aa095168f074754959652e34498cb41 Mon Sep 17 00:00:00 2001 From: Sergio Vieira Date: Fri, 28 Jul 2017 11:21:45 -0300 Subject: [PATCH 09/29] - Adds define to check memory leaks on visual studio --- src/core/Algorithm.h | 1 + src/core/JMetalHeader.h | 12 ++++ src/core/Problem.h | 1 + src/core/Solution.cpp | 8 +-- src/core/SolutionSet.cpp | 2 +- .../solutionType/ArrayRealSolutionType.cpp | 6 +- .../solutionType/BinaryRealSolutionType.cpp | 6 +- .../solutionType/BinarySolutionType.cpp | 6 +- src/encodings/variable/ArrayReal.cpp | 6 +- src/encodings/variable/Binary.cpp | 6 +- src/encodings/variable/BinaryReal.cpp | 2 +- src/experiments/ExperimentExecution.cpp | 8 +-- src/experiments/ExperimentReport.cpp | 62 +++++++++---------- src/experiments/settings/DE_Settings.cpp | 6 +- src/experiments/settings/GDE3_Settings.cpp | 6 +- src/experiments/settings/gGA_Settings.cpp | 8 +-- src/main/OMOPSO_main.cpp | 6 +- src/metaheuristics/gde3/GDE3.cpp | 32 +++++----- src/metaheuristics/mochc/MOCHC.cpp | 28 ++++----- src/metaheuristics/moead/MOEAD.cpp | 30 ++++----- src/metaheuristics/moead/UtilsMOEAD.cpp | 3 +- src/metaheuristics/omopso/OMOPSO.cpp | 4 +- .../singleObjective/cmaes/CMAES.cpp | 54 ++++++++-------- .../differentialEvolution/DE.cpp | 18 +++--- .../singleObjective/geneticAlgorithm/gGA.cpp | 18 +++--- .../particleSwarmOptimization/PSO.cpp | 8 +-- .../StandardPSO2007.cpp | 4 +- .../StandardPSO2011.cpp | 4 +- src/metaheuristics/smpso/SMPSO.cpp | 10 +-- src/metaheuristics/smpso/SMPSOhv.cpp | 8 +-- src/metaheuristics/smsemoa/FastSMSEMOA.cpp | 26 ++++---- src/metaheuristics/smsemoa/SMSEMOA.cpp | 8 +-- .../DifferentialEvolutionCrossover.cpp | 12 ++-- src/operators/crossover/HUXCrossover.cpp | 6 +- .../selection/BestSolutionSelection.cpp | 2 +- src/operators/selection/BinaryTournament.cpp | 2 +- src/operators/selection/BinaryTournament2.cpp | 6 +- .../DifferentialEvolutionSelection.cpp | 2 +- .../selection/WorstSolutionSelection.cpp | 2 +- src/problems/DTLZ/DTLZ1.cpp | 16 ++--- src/problems/DTLZ/DTLZ2.cpp | 16 ++--- src/problems/DTLZ/DTLZ3.cpp | 16 ++--- src/problems/DTLZ/DTLZ4.cpp | 16 ++--- src/problems/DTLZ/DTLZ5.cpp | 18 +++--- src/problems/DTLZ/DTLZ6.cpp | 18 +++--- src/problems/DTLZ/DTLZ7.cpp | 16 ++--- src/problems/Fonseca.cpp | 14 ++--- src/problems/Kursawe.cpp | 16 ++--- src/problems/LZ09/LZ09.cpp | 4 +- src/problems/LZ09/LZ09_F1.cpp | 22 +++---- src/problems/LZ09/LZ09_F2.cpp | 22 +++---- src/problems/LZ09/LZ09_F3.cpp | 22 +++---- src/problems/LZ09/LZ09_F4.cpp | 22 +++---- src/problems/LZ09/LZ09_F5.cpp | 22 +++---- src/problems/LZ09/LZ09_F6.cpp | 22 +++---- src/problems/LZ09/LZ09_F7.cpp | 22 +++---- src/problems/LZ09/LZ09_F8.cpp | 22 +++---- src/problems/LZ09/LZ09_F9.cpp | 22 +++---- src/problems/Schaffer.cpp | 6 +- src/problems/Srinivas.cpp | 10 +-- src/problems/Tanaka.cpp | 8 +-- src/problems/ZDT/ZDT1.cpp | 6 +- src/problems/ZDT/ZDT2.cpp | 6 +- src/problems/ZDT/ZDT3.cpp | 6 +- src/problems/ZDT/ZDT4.cpp | 8 +-- src/problems/ZDT/ZDT5.cpp | 4 +- src/problems/ZDT/ZDT6.cpp | 6 +- .../singleObjective/CEC2005Problem.cpp | 12 ++-- src/problems/singleObjective/Griewank.cpp | 8 +-- src/problems/singleObjective/OneMax.cpp | 2 +- src/problems/singleObjective/Rastrigin.cpp | 8 +-- src/problems/singleObjective/Rosenbrock.cpp | 8 +-- src/problems/singleObjective/Sphere.cpp | 8 +-- .../cec2005Competition/Benchmark.cpp | 52 ++++++++-------- .../cec2005Competition/Benchmark.h | 1 + .../cec2005Competition/F01ShiftedSphere.cpp | 4 +- .../cec2005Competition/F02ShiftedSchwefel.cpp | 4 +- .../F03ShiftedRotatedHighCondElliptic.cpp | 11 ++-- .../F04ShiftedSchwefelNoise.cpp | 4 +- .../F05SchwefelGlobalOptBound.cpp | 15 ++--- .../F06ShiftedRosenbrock.cpp | 4 +- .../F07ShiftedRotatedGriewank.cpp | 11 ++-- .../F08ShiftedRotatedAckleyGlobalOptBound.cpp | 11 ++-- .../F09ShiftedRastrigin.cpp | 4 +- .../F10ShiftedRotatedRastrigin.cpp | 11 ++-- .../F11ShiftedRotatedWeierstrass.cpp | 11 ++-- .../cec2005Competition/F12Schwefel.cpp | 19 +++--- .../F13ShiftedExpandedGriewankRosenbrock.cpp | 4 +- .../F14ShiftedRotatedExpandedScaffer.cpp | 11 ++-- .../F15HybridComposition1.cpp | 29 ++++----- .../F16RotatedHybridComposition1.cpp | 29 ++++----- .../F17RotatedHybridComposition1Noise.cpp | 29 ++++----- .../F18RotatedHybridComposition2.cpp | 29 ++++----- ...HybridComposition2NarrowBasinGlobalOpt.cpp | 29 ++++----- ...otatedHybridComposition2GlobalOptBound.cpp | 29 ++++----- .../F21RotatedHybridComposition3.cpp | 29 ++++----- ...tedHybridComposition3HighCondNumMatrix.cpp | 29 ++++----- ...NoncontinuousRotatedHybridComposition3.cpp | 29 ++++----- .../F24RotatedHybridComposition4.cpp | 29 ++++----- .../F25RotatedHybridComposition4Bound.cpp | 29 ++++----- .../cec2005Competition/HCJob.cpp | 7 ++- src/qualityIndicator/Epsilon.cpp | 4 +- src/qualityIndicator/Fitness.cpp | 2 +- src/qualityIndicator/GenerationalDistance.cpp | 2 +- src/qualityIndicator/Hypervolume.cpp | 10 +-- .../InvertedGenerationalDistance.cpp | 2 +- .../fastHypervolume/FastHypervolume.cpp | 8 +-- .../FastHypervolumeArchive.cpp | 10 +-- src/qualityIndicator/main/Epsilon_main.cpp | 2 +- .../main/GenerationalDistance_main.cpp | 2 +- .../main/Hypervolume_main.cpp | 2 +- .../InvertedGenerationalDistance_main.cpp | 2 +- src/qualityIndicator/util/MetricsUtil.cpp | 6 +- src/util/AdaptiveGrid.cpp | 12 ++-- src/util/AdaptiveRandomNeighborhood.cpp | 8 +-- src/util/Distance.cpp | 8 +-- src/util/NonDominatedSolutionList.cpp | 4 +- src/util/PermutationUtility.cpp | 5 +- src/util/PseudoRandom.cpp | 2 +- src/util/PseudoRandom.h | 1 + src/util/Ranking.cpp | 2 +- src/util/archive/AdaptiveGridArchive.cpp | 4 +- src/util/archive/CrowdingArchive.cpp | 8 +-- src/util/comparators/CrowdingComparator.cpp | 2 +- src/util/comparators/DominanceComparator.cpp | 2 +- .../EpsilonDominanceComparator.cpp | 2 +- src/util/comparators/EqualSolutions.cpp | 2 +- 127 files changed, 774 insertions(+), 736 deletions(-) create mode 100644 src/core/JMetalHeader.h diff --git a/src/core/Algorithm.h b/src/core/Algorithm.h index c8ef331..8e28ef3 100644 --- a/src/core/Algorithm.h +++ b/src/core/Algorithm.h @@ -23,6 +23,7 @@ #ifndef __ALGORITHM__ #define __ALGORITHM__ +#include "JMetalHeader.h" #include #include #include diff --git a/src/core/JMetalHeader.h b/src/core/JMetalHeader.h new file mode 100644 index 0000000..ffaeefb --- /dev/null +++ b/src/core/JMetalHeader.h @@ -0,0 +1,12 @@ +#ifndef __JMETAL_HEADER__ +#define __JMETAL_HEADER__ + +#ifdef MSVC + #ifdef _DEBUG + #define snew new ( _NORMAL_BLOCK , __FILE__ , __LINE__ ) + #endif +#else + #define snew new +#endif + +#endif \ No newline at end of file diff --git a/src/core/Problem.h b/src/core/Problem.h index 1c9e44f..cf970e9 100644 --- a/src/core/Problem.h +++ b/src/core/Problem.h @@ -23,6 +23,7 @@ #ifndef __PROBLEM__ #define __PROBLEM__ +#include "JMetalHeader.h" #include #include #include diff --git a/src/core/Solution.cpp b/src/core/Solution.cpp index 3e2aeee..318790a 100644 --- a/src/core/Solution.cpp +++ b/src/core/Solution.cpp @@ -55,7 +55,7 @@ Solution::Solution (int numberOfObjectives) numberOfObjectives_ = numberOfObjectives; numberOfVariables_ = 0; variable_ = nullptr; - objective_ = new double[numberOfObjectives_]; + objective_ = snew double[numberOfObjectives_]; if (objective_ == nullptr) { cout << "ERROR GRAVE: Impossible to reserve memory for storing objectives in class Solution" << endl; @@ -79,7 +79,7 @@ Solution::Solution (Problem *problem) numberOfVariables_ = problem_->getNumberOfVariables(); // creating the objective vector - objective_ = new double[numberOfObjectives_]; + objective_ = snew double[numberOfObjectives_]; if (objective_ == nullptr) { cout << "ERROR GRAVE: Impossible to reserve memory for storing objectives in class Solution" << endl; @@ -107,7 +107,7 @@ Solution::Solution (Problem * problem, Variable ** variables) type_ = problem->getSolutionType(); numberOfObjectives_ = problem->getNumberOfObjectives(); numberOfVariables_ = problem_->getNumberOfVariables(); - objective_ = new double[numberOfObjectives_] ; + objective_ = snew double[numberOfObjectives_] ; // Setting initial values fitness_ = 0.0; @@ -131,7 +131,7 @@ Solution::Solution (Solution *solution) numberOfVariables_ = solution->getNumberOfVariables(); // creating the objective vector - objective_ = new double[numberOfObjectives_]; + objective_ = snew double[numberOfObjectives_]; if (objective_ == nullptr) { cout << "ERROR GRAVE: Impossible to reserve memory for storing objectives in class Solution" << endl; diff --git a/src/core/SolutionSet.cpp b/src/core/SolutionSet.cpp index 186681a..1ba39ac 100644 --- a/src/core/SolutionSet.cpp +++ b/src/core/SolutionSet.cpp @@ -418,7 +418,7 @@ void SolutionSet::replace(int position, Solution *solution) vector > SolutionSet::writeObjectivesToMatrix() { vector > objectives; - //objectives = new double[size()][get(0).numberOfObjectives()]; + //objectives = snew double[size()][get(0).numberOfObjectives()]; for (int i = 0; i < size(); i++) { vector list; diff --git a/src/encodings/solutionType/ArrayRealSolutionType.cpp b/src/encodings/solutionType/ArrayRealSolutionType.cpp index b84d34f..61868e7 100644 --- a/src/encodings/solutionType/ArrayRealSolutionType.cpp +++ b/src/encodings/solutionType/ArrayRealSolutionType.cpp @@ -38,14 +38,14 @@ Variable ** ArrayRealSolutionType::createVariables() { int i; - Variable **variables = new Variable*[1]; //malloc(sizeof(Real) * problem->getNumberOfVariables()); + Variable **variables = snew Variable*[1]; //malloc(sizeof(Real) * problem->getNumberOfVariables()); if (problem_->getSolutionType() == nullptr) { cout << "Error grave: Impossible to reserve memory for variable type" << endl; exit(-1); } - variables[0] = new ArrayReal(problem_->getNumberOfVariables(),problem_); + variables[0] = snew ArrayReal(problem_->getNumberOfVariables(),problem_); return variables; } // createVariables @@ -58,7 +58,7 @@ Variable ** ArrayRealSolutionType::createVariables() */ Variable ** ArrayRealSolutionType::copyVariables(Variable ** vars) { - Variable **variables = new Variable*[1]; + Variable **variables = snew Variable*[1]; variables[0] = vars[0]->deepCopy(); return variables ; } // copyVariables diff --git a/src/encodings/solutionType/BinaryRealSolutionType.cpp b/src/encodings/solutionType/BinaryRealSolutionType.cpp index a06feeb..5c79f9b 100644 --- a/src/encodings/solutionType/BinaryRealSolutionType.cpp +++ b/src/encodings/solutionType/BinaryRealSolutionType.cpp @@ -38,18 +38,18 @@ BinaryRealSolutionType::BinaryRealSolutionType(Problem *problem) Variable ** BinaryRealSolutionType::createVariables() { - Variable **variables = new Variable*[problem_->getNumberOfVariables()]; //malloc(sizeof(Real) * problem->getNumberOfVariables()); + Variable **variables = snew Variable*[problem_->getNumberOfVariables()]; //malloc(sizeof(Real) * problem->getNumberOfVariables()); for (int var = 0; var < problem_->getNumberOfVariables(); var++) { if (problem_->getPrecision() == nullptr) { - int * precision = new int[problem_->getNumberOfVariables()] ; + int * precision = snew int[problem_->getNumberOfVariables()] ; for (int i = 0; i < problem_->getNumberOfVariables(); i++) precision[i] = BinaryReal::DEFAULT_PRECISION ; problem_->setPrecision(precision) ; } // if - variables[var] = new BinaryReal(problem_->getPrecision(var), + variables[var] = snew BinaryReal(problem_->getPrecision(var), problem_->getLowerLimit(var), problem_->getUpperLimit(var)); } // for diff --git a/src/encodings/solutionType/BinarySolutionType.cpp b/src/encodings/solutionType/BinarySolutionType.cpp index 6548645..a25c970 100644 --- a/src/encodings/solutionType/BinarySolutionType.cpp +++ b/src/encodings/solutionType/BinarySolutionType.cpp @@ -39,18 +39,18 @@ Variable **BinarySolutionType::createVariables() { //BinaryReal * binaryReal; - Variable **variables = new Variable*[problem_->getNumberOfVariables()]; //malloc(sizeof(Real) * problem->getNumberOfVariables()); + Variable **variables = snew Variable*[problem_->getNumberOfVariables()]; //malloc(sizeof(Real) * problem->getNumberOfVariables()); // if (problem_->variableType_ == nullptr) { // cout << "Error grave: Impossible to reserve memory for variable type" << endl; // exit(-1); // } for (int var = 0; var < problem_->getNumberOfVariables(); var++) - variables[var] = new Binary(problem_->getLength(var)); + variables[var] = snew Binary(problem_->getLength(var)); /* for (int var = 0; var < problem_->getNumberOfVariables(); var++) { if (problem_->getPrecision() == nullptr) { - int * precision = new int[problem_->getNumberOfVariables()] ; + int * precision = snew int[problem_->getNumberOfVariables()] ; for (int i = 0; i < problem_->getNumberOfVariables(); i++) precision[i] = BinaryReal::DEFAULT_PRECISION ; problem_->setPrecision(precision) ; diff --git a/src/encodings/variable/ArrayReal.cpp b/src/encodings/variable/ArrayReal.cpp index df9dd4c..e4b9c90 100644 --- a/src/encodings/variable/ArrayReal.cpp +++ b/src/encodings/variable/ArrayReal.cpp @@ -42,7 +42,7 @@ ArrayReal::ArrayReal(int size, Problem * problem) { problem_ = problem; size_ = size; - array_ = new double[size_]; + array_ = snew double[size_]; for (int i = 0; i < size_ ; i++) { @@ -61,7 +61,7 @@ ArrayReal::ArrayReal(ArrayReal * arrayReal) { problem_ = arrayReal->problem_ ; size_ = arrayReal->size_; - array_ = new double[size_]; + array_ = snew double[size_]; for (int i = 0; i < size_; i++) { @@ -85,7 +85,7 @@ ArrayReal::~ArrayReal() */ Variable * ArrayReal::deepCopy() { - return new ArrayReal(this); + return snew ArrayReal(this); } // deepCopy diff --git a/src/encodings/variable/Binary.cpp b/src/encodings/variable/Binary.cpp index c1af27e..c33d147 100644 --- a/src/encodings/variable/Binary.cpp +++ b/src/encodings/variable/Binary.cpp @@ -41,7 +41,7 @@ Binary::Binary(int numberOfBits) { numberOfBits_ = numberOfBits; - bits_ = new vector(numberOfBits_, false) ; + bits_ = snew vector(numberOfBits_, false) ; for (int i = 0; i < numberOfBits_; i++) { @@ -64,7 +64,7 @@ Binary::Binary(int numberOfBits) Binary::Binary(Binary * variable) { numberOfBits_ = variable->getNumberOfBits(); - bits_ = new vector(numberOfBits_, false) ; + bits_ = snew vector(numberOfBits_, false) ; for (int i = 0; i < numberOfBits_; i++) { (*bits_)[i] = (*variable->bits_)[i] ; @@ -100,7 +100,7 @@ void Binary::decode() **/ Variable * Binary::deepCopy() { - return new Binary(this); + return snew Binary(this); } //deepCopy diff --git a/src/encodings/variable/BinaryReal.cpp b/src/encodings/variable/BinaryReal.cpp index 687d201..3ddd493 100644 --- a/src/encodings/variable/BinaryReal.cpp +++ b/src/encodings/variable/BinaryReal.cpp @@ -112,7 +112,7 @@ void BinaryReal::setValue(double value) */ Variable * BinaryReal::deepCopy() { - return new BinaryReal(this); + return snew BinaryReal(this); } //deepCopy diff --git a/src/experiments/ExperimentExecution.cpp b/src/experiments/ExperimentExecution.cpp index 681b98f..1c2c9fe 100644 --- a/src/experiments/ExperimentExecution.cpp +++ b/src/experiments/ExperimentExecution.cpp @@ -84,13 +84,13 @@ void ExperimentExecution::runExperiment(int numberOfThreads) { for (int k=0; k threads; - RunExperiment ** experiments_ = new RunExperiment*[numberOfThreads]; + RunExperiment ** experiments_ = snew RunExperiment*[numberOfThreads]; for (int i = 0; i < numberOfThreads; i++) { - experiments_[i] = new RunExperiment(this, map_, i, numberOfThreads, + experiments_[i] = snew RunExperiment(this, map_, i, numberOfThreads, problemList_.size(), i, &mtx); // result = pthread_create(&p[i], nullptr, executeRun, experiments_[i]); // if (result != 0) { diff --git a/src/experiments/ExperimentReport.cpp b/src/experiments/ExperimentReport.cpp index b083bf5..71a72b2 100644 --- a/src/experiments/ExperimentReport.cpp +++ b/src/experiments/ExperimentReport.cpp @@ -109,7 +109,7 @@ void ExperimentReport::generateQualityIndicators() string solutionFrontFile = problemDirectory + "/FUN"; string qualityIndicatorFile = problemDirectory; - Fitness * indicators = new Fitness(); + Fitness * indicators = snew Fitness(); vector< vector > solutionFront = indicators->utils_->readFront(solutionFrontFile); qualityIndicatorFile = qualityIndicatorFile + "/FIT"; @@ -134,7 +134,7 @@ void ExperimentReport::generateQualityIndicators() if (indicatorList_[indicatorIndex].compare("HV")==0) { - Hypervolume * indicators = new Hypervolume(); + Hypervolume * indicators = snew Hypervolume(); vector< vector > solutionFront = indicators->utils_->readFront(solutionFrontFile); vector< vector > trueFront = @@ -145,7 +145,7 @@ void ExperimentReport::generateQualityIndicators() } if (indicatorList_[indicatorIndex].compare("SPREAD")==0) { - Spread * indicators = new Spread(); + Spread * indicators = snew Spread(); vector< vector > solutionFront = indicators->utils_->readFront(solutionFrontFile); vector< vector > trueFront = @@ -156,7 +156,7 @@ void ExperimentReport::generateQualityIndicators() } if (indicatorList_[indicatorIndex].compare("IGD")==0) { - InvertedGenerationalDistance * indicators = new InvertedGenerationalDistance(); + InvertedGenerationalDistance * indicators = snew InvertedGenerationalDistance(); vector< vector > solutionFront = indicators->utils_->readFront(solutionFrontFile); vector< vector > trueFront = @@ -167,7 +167,7 @@ void ExperimentReport::generateQualityIndicators() } if (indicatorList_[indicatorIndex].compare("EPSILON")==0) { - Epsilon * indicators = new Epsilon(); + Epsilon * indicators = snew Epsilon(); vector< vector > solutionFront = indicators->utils_->readFront(solutionFrontFile); vector< vector > trueFront = @@ -213,8 +213,8 @@ void ExperimentReport::generateReferenceFronts() string paretoFrontPath = referenceFrontDirectory + "/" + problemList_[problemIndex] + ".rf"; - MetricsUtil * metricsUtils = new MetricsUtil(); - NonDominatedSolutionList * solutionSet = new NonDominatedSolutionList(); + MetricsUtil * metricsUtils = snew MetricsUtil(); + NonDominatedSolutionList * solutionSet = snew NonDominatedSolutionList(); for (int algorithmIndex=0; algorithmIndex *** data = new vector**[indicatorList_.size()]; + vector *** data = snew vector**[indicatorList_.size()]; for (int indicator = 0; indicator < indicatorList_.size(); indicator++) { // A data vector per problem - data[indicator] = new vector*[problemList_.size()]; + data[indicator] = snew vector*[problemList_.size()]; for (int problem = 0; problem < problemList_.size(); problem++) { - data[indicator][problem] = new vector[algorithmNameList_.size()]; + data[indicator][problem] = snew vector[algorithmNameList_.size()]; for (int algorithm = 0; algorithm < algorithmNameList_.size(); algorithm++) { @@ -303,34 +303,34 @@ void ExperimentReport::generateLatexTables() statValues["max"] = 0.0; statValues["min"] = 0.0; - mean = new double**[indicatorList_.size()]; - median = new double**[indicatorList_.size()]; - stdDeviation = new double**[indicatorList_.size()]; - iqr = new double**[indicatorList_.size()]; - min = new double**[indicatorList_.size()]; - max = new double**[indicatorList_.size()]; - numberOfValues = new int**[indicatorList_.size()]; + mean = snew double**[indicatorList_.size()]; + median = snew double**[indicatorList_.size()]; + stdDeviation = snew double**[indicatorList_.size()]; + iqr = snew double**[indicatorList_.size()]; + min = snew double**[indicatorList_.size()]; + max = snew double**[indicatorList_.size()]; + numberOfValues = snew int**[indicatorList_.size()]; for (int indicator = 0; indicator < indicatorList_.size(); indicator++) { // A data vector per problem - mean[indicator] = new double*[problemList_.size()]; - median[indicator] = new double*[problemList_.size()]; - stdDeviation[indicator] = new double*[problemList_.size()]; - iqr[indicator] = new double*[problemList_.size()]; - min[indicator] = new double*[problemList_.size()]; - max[indicator] = new double*[problemList_.size()]; - numberOfValues[indicator] = new int*[problemList_.size()]; + mean[indicator] = snew double*[problemList_.size()]; + median[indicator] = snew double*[problemList_.size()]; + stdDeviation[indicator] = snew double*[problemList_.size()]; + iqr[indicator] = snew double*[problemList_.size()]; + min[indicator] = snew double*[problemList_.size()]; + max[indicator] = snew double*[problemList_.size()]; + numberOfValues[indicator] = snew int*[problemList_.size()]; for (int problem = 0; problem < problemList_.size(); problem++) { - mean[indicator][problem] = new double[algorithmNameList_.size()]; - median[indicator][problem] = new double[algorithmNameList_.size()]; - stdDeviation[indicator][problem] = new double[algorithmNameList_.size()]; - iqr[indicator][problem] = new double[algorithmNameList_.size()]; - min[indicator][problem] = new double[algorithmNameList_.size()]; - max[indicator][problem] = new double[algorithmNameList_.size()]; - numberOfValues[indicator][problem] = new int[algorithmNameList_.size()]; + mean[indicator][problem] = snew double[algorithmNameList_.size()]; + median[indicator][problem] = snew double[algorithmNameList_.size()]; + stdDeviation[indicator][problem] = snew double[algorithmNameList_.size()]; + iqr[indicator][problem] = snew double[algorithmNameList_.size()]; + min[indicator][problem] = snew double[algorithmNameList_.size()]; + max[indicator][problem] = snew double[algorithmNameList_.size()]; + numberOfValues[indicator][problem] = snew int[algorithmNameList_.size()]; for (int algorithm = 0; algorithm < algorithmNameList_.size(); algorithm++) { diff --git a/src/experiments/settings/DE_Settings.cpp b/src/experiments/settings/DE_Settings.cpp index c667b3d..a53b58a 100644 --- a/src/experiments/settings/DE_Settings.cpp +++ b/src/experiments/settings/DE_Settings.cpp @@ -62,7 +62,7 @@ DE_Settings::DE_Settings(string problemName) Algorithm * DE_Settings::configure() { - algorithm = new DE(problem_); + algorithm = snew DE(problem_); algorithm->setInputParameter("populationSize",&populationSize_); algorithm->setInputParameter("maxEvaluations",&maxEvaluations_); @@ -75,11 +75,11 @@ Algorithm * DE_Settings::configure() parameters["F"] = &fParameter; string deVariantParameter = deVariantParameter_; parameters["DE_VARIANT"] = &deVariantParameter; - crossover = new DifferentialEvolutionCrossover(parameters); + crossover = snew DifferentialEvolutionCrossover(parameters); // Selection operator parameters.clear(); - selection = new DifferentialEvolutionSelection(parameters) ; + selection = snew DifferentialEvolutionSelection(parameters) ; // Add the operators to the algorithm algorithm->addOperator("crossover",crossover); diff --git a/src/experiments/settings/GDE3_Settings.cpp b/src/experiments/settings/GDE3_Settings.cpp index d2cfc47..92dee99 100644 --- a/src/experiments/settings/GDE3_Settings.cpp +++ b/src/experiments/settings/GDE3_Settings.cpp @@ -67,7 +67,7 @@ GDE3_Settings::GDE3_Settings(string problemName) Algorithm * GDE3_Settings::configure() { - algorithm = new GDE3(problem_); + algorithm = snew GDE3(problem_); algorithm->setInputParameter("populationSize",&populationSize_); algorithm->setInputParameter("maxIterations",&maxIterations_); @@ -78,11 +78,11 @@ Algorithm * GDE3_Settings::configure() double F = F_; parameters["CR"] = &CR; parameters["F"] = &F; - crossover = new DifferentialEvolutionCrossover(parameters); + crossover = snew DifferentialEvolutionCrossover(parameters); // Selection Operator parameters.clear(); - selection = new DifferentialEvolutionSelection(parameters); + selection = snew DifferentialEvolutionSelection(parameters); // Add the operators to the algorithm algorithm->addOperator("crossover",crossover); diff --git a/src/experiments/settings/gGA_Settings.cpp b/src/experiments/settings/gGA_Settings.cpp index 3a100f8..7899d75 100644 --- a/src/experiments/settings/gGA_Settings.cpp +++ b/src/experiments/settings/gGA_Settings.cpp @@ -63,7 +63,7 @@ gGA_Settings::gGA_Settings(string problemName) Algorithm * gGA_Settings::configure() { - algorithm = new gGA(problem_); + algorithm = snew gGA(problem_); algorithm->setInputParameter("populationSize",&populationSize_); algorithm->setInputParameter("maxEvaluations",&maxEvaluations_); @@ -74,18 +74,18 @@ Algorithm * gGA_Settings::configure() double crossoverDistributionIndex = crossoverDistributionIndex_ ; parameters["probability"] = &crossoverProbability; parameters["distributionIndex"] = &crossoverDistributionIndex; - crossover = new SBXCrossover(parameters); + crossover = snew SBXCrossover(parameters); parameters.clear(); double mutationProbability = mutationProbability_; double mutationDistributionIndex = mutationDistributionIndex_; parameters["probability"] = &mutationProbability; parameters["distributionIndex"] = &mutationDistributionIndex; - mutation = new PolynomialMutation(parameters); + mutation = snew PolynomialMutation(parameters); // Selection Operator parameters.clear(); - selection = new BinaryTournament2(parameters); + selection = snew BinaryTournament2(parameters); // Add the operators to the algorithm algorithm->addOperator("crossover",crossover); diff --git a/src/main/OMOPSO_main.cpp b/src/main/OMOPSO_main.cpp index ab93283..0af77df 100644 --- a/src/main/OMOPSO_main.cpp +++ b/src/main/OMOPSO_main.cpp @@ -65,7 +65,7 @@ int main(int argc, char ** argv) problem = ProblemFactory::getProblem(const_cast("Kursawe")); } - algorithm = new OMOPSO(problem); + algorithm = snew OMOPSO(problem); int maxIterations = 250; double perturbationIndex = 0.5; @@ -80,13 +80,13 @@ int main(int argc, char ** argv) parameters["probability"] = &mutationProbability; parameters["perturbation"] = &perturbationIndex; - uniformMutation = new UniformMutation(parameters); + uniformMutation = snew UniformMutation(parameters); parameters.clear(); parameters["probability"] = &mutationProbability; parameters["perturbation"] = &perturbationIndex; parameters["maxIterations"] = &maxIterations; - nonUniformMutation = new NonUniformMutation(parameters); + nonUniformMutation = snew NonUniformMutation(parameters); // Add the operators to the algorithm diff --git a/src/metaheuristics/gde3/GDE3.cpp b/src/metaheuristics/gde3/GDE3.cpp index b84d84a..b99063a 100644 --- a/src/metaheuristics/gde3/GDE3.cpp +++ b/src/metaheuristics/gde3/GDE3.cpp @@ -59,8 +59,8 @@ SolutionSet * GDE3::execute() Operator * crossoverOperator; Operator * selectionOperator; - distance = new Distance(); - dominance = new DominanceComparator(); + distance = snew Distance(); + dominance = snew DominanceComparator(); Solution ** parent; @@ -69,7 +69,7 @@ SolutionSet * GDE3::execute() maxIterations = *(int *) getInputParameter("maxIterations"); //Initialize the variables - population = new SolutionSet(populationSize); + population = snew SolutionSet(populationSize); evaluations = 0; iterations = 0; @@ -81,7 +81,7 @@ SolutionSet * GDE3::execute() Solution * newSolution; for (int i = 0; i < populationSize; i++) { - newSolution = new Solution(problem_); + newSolution = snew Solution(problem_); problem_->evaluate(newSolution); problem_->evaluateConstraints(newSolution); evaluations++; @@ -92,13 +92,13 @@ SolutionSet * GDE3::execute() while (iterations < maxIterations) { // Create the offSpring solutionSet - offspringPopulation = new SolutionSet(populationSize * 2); + offspringPopulation = snew SolutionSet(populationSize * 2); for (int i = 0; i < populationSize; i++) { // Obtain parents. Two parameters are required: the population and the // index of the current individual - void ** object1 = new void*[2]; + void ** object1 = snew void*[2]; object1[0] = population; object1[1] = &i; parent = (Solution **) (selectionOperator->execute(object1)); @@ -107,7 +107,7 @@ SolutionSet * GDE3::execute() Solution * child ; // Crossover. Two parameters are required: the current individual and the // array of parents - void ** object2 = new void*[2]; + void ** object2 = snew void*[2]; object2[0] = population->get(i); object2[1] = parent; child = (Solution *) (crossoverOperator->execute(object2)); @@ -123,7 +123,7 @@ SolutionSet * GDE3::execute() result = dominance->compare(population->get(i), child) ; if (result == -1) // Solution i dominates child { - offspringPopulation->add(new Solution(population->get(i))); + offspringPopulation->add(snew Solution(population->get(i))); delete child; } // if else if (result == 1) // child dominates @@ -133,12 +133,12 @@ SolutionSet * GDE3::execute() else // the two solutions are non-dominated { offspringPopulation->add(child) ; - offspringPopulation->add(new Solution(population->get(i))); + offspringPopulation->add(snew Solution(population->get(i))); } // else } // for // Ranking the offspring population - Ranking * ranking = new Ranking(offspringPopulation); + Ranking * ranking = snew Ranking(offspringPopulation); int remain = populationSize; int index = 0; @@ -159,7 +159,7 @@ SolutionSet * GDE3::execute() //Add the individuals of this front for (int k = 0; k < front->size(); k++ ) { - population->add(new Solution(front->get(k))); + population->add(snew Solution(front->get(k))); } // for //Decrement remain @@ -179,7 +179,7 @@ SolutionSet * GDE3::execute() while (front->size() > remain) { distance->crowdingDistanceAssignment(front,problem_->getNumberOfObjectives()); - Comparator * crowdingComparator = new CrowdingComparator(); + Comparator * crowdingComparator = snew CrowdingComparator(); int indexWorst = front->indexWorst(crowdingComparator); delete crowdingComparator; delete front->get(indexWorst); @@ -187,7 +187,7 @@ SolutionSet * GDE3::execute() } for (int k = 0; k < front->size(); k++) { - population->add(new Solution(front->get(k))); + population->add(snew Solution(front->get(k))); } remain = 0; @@ -203,11 +203,11 @@ SolutionSet * GDE3::execute() delete distance; // Return the first non-dominated front - Ranking * ranking = new Ranking(population); - SolutionSet * result = new SolutionSet(ranking->getSubfront(0)->size()); + Ranking * ranking = snew Ranking(population); + SolutionSet * result = snew SolutionSet(ranking->getSubfront(0)->size()); for (int i=0; igetSubfront(0)->size(); i++) { - result->add(new Solution(ranking->getSubfront(0)->get(i))); + result->add(snew Solution(ranking->getSubfront(0)->get(i))); } delete ranking; delete population; diff --git a/src/metaheuristics/mochc/MOCHC.cpp b/src/metaheuristics/mochc/MOCHC.cpp index c03357e..2851ed5 100644 --- a/src/metaheuristics/mochc/MOCHC.cpp +++ b/src/metaheuristics/mochc/MOCHC.cpp @@ -85,10 +85,10 @@ SolutionSet *MOCHC::rankingAndCrowdingSelection(SolutionSet * pop, int size) { - SolutionSet *result = new SolutionSet(size); + SolutionSet *result = snew SolutionSet(size); // Ranking the union - Ranking * ranking = new Ranking(pop); - Distance * distance = new Distance(); + Ranking * ranking = snew Ranking(pop); + Distance * distance = snew Distance(); int remain = size; int index = 0; SolutionSet * front = nullptr; @@ -104,7 +104,7 @@ SolutionSet *MOCHC::rankingAndCrowdingSelection(SolutionSet * pop, int size) //Add the individuals of this front for (int k = 0; k < front->size(); k++) { - result->add(new Solution(front->get(k))); + result->add(snew Solution(front->get(k))); } // for //Decrement remain @@ -123,12 +123,12 @@ SolutionSet *MOCHC::rankingAndCrowdingSelection(SolutionSet * pop, int size) if (remain > 0) // front contains individuals to insert { distance->crowdingDistanceAssignment(front, problem_->getNumberOfObjectives()); - Comparator * c = new CrowdingComparator(); + Comparator * c = snew CrowdingComparator(); front->sort(c); delete c; for (int k = 0; k < remain; k++) { - result->add(new Solution(front->get(k))); + result->add(snew Solution(front->get(k))); } // for remain = 0; @@ -156,7 +156,7 @@ SolutionSet *MOCHC::execute() bool condition = false; SolutionSet *solutionSet, *offSpringPopulation, *newPopulation; - Comparator * crowdingComparator = new CrowdingComparator(); + Comparator * crowdingComparator = snew CrowdingComparator(); SolutionSet * population; SolutionSet * offspringPopulation; @@ -184,7 +184,7 @@ SolutionSet *MOCHC::execute() evaluations = 0; // calculating the maximum problem sizes .... - Solution * sol = new Solution(problem_); + Solution * sol = snew Solution(problem_); int size = 0; for (int var = 0; var < problem_->getNumberOfVariables(); var++) { @@ -198,10 +198,10 @@ SolutionSet *MOCHC::execute() // Create the initial solutionSet Solution * newSolution; - population = new SolutionSet(populationSize); + population = snew SolutionSet(populationSize); for (int i = 0; i < populationSize; i++) { - newSolution = new Solution(problem_); + newSolution = snew Solution(problem_); problem_->evaluate(newSolution); problem_->evaluateConstraints(newSolution); evaluations++; @@ -211,8 +211,8 @@ SolutionSet *MOCHC::execute() while (!condition) { - offSpringPopulation = new SolutionSet(populationSize); - Solution **parents = new Solution*[2]; + offSpringPopulation = snew SolutionSet(populationSize); + Solution **parents = snew Solution*[2]; for (int i = 0; i < population->size()/2; i++) { @@ -250,11 +250,11 @@ SolutionSet *MOCHC::execute() population->sort(crowdingComparator); for (int i = 0; i < preserve; i++) { - newPopulation->add(new Solution(population->get(i))); + newPopulation->add(snew Solution(population->get(i))); } for (int i = preserve; i < populationSize; i++) { - Solution * solution = new Solution(population->get(i)); + Solution * solution = snew Solution(population->get(i)); cataclysmicMutation->execute(solution); problem_->evaluate(solution); problem_->evaluateConstraints(solution); diff --git a/src/metaheuristics/moead/MOEAD.cpp b/src/metaheuristics/moead/MOEAD.cpp index 771478d..8f811f9 100644 --- a/src/metaheuristics/moead/MOEAD.cpp +++ b/src/metaheuristics/moead/MOEAD.cpp @@ -47,7 +47,7 @@ SolutionSet * MOEAD::execute() populationSize_ = *(int *) getInputParameter("populationSize"); dataDirectory_ = * (string *) getInputParameter("dataDirectory"); - population_ = new SolutionSet(populationSize_); + population_ = snew SolutionSet(populationSize_); //indArray_ = new Solution*[problem_->getNumberOfObjectives()]; T_ = 20; @@ -58,11 +58,11 @@ SolutionSet * MOEAD::execute() delta_ = 0.9; nr_ = * (int *) (0.01 * populationSize_); */ - neighborhood_ = new int*[populationSize_]; + neighborhood_ = snew int*[populationSize_]; - z_ = new double[problem_->getNumberOfObjectives()]; + z_ = snew double[problem_->getNumberOfObjectives()]; //lambda_ = new Vector(problem_->getNumberOfObjectives()) ; - lambda_ = new double*[populationSize_]; + lambda_ = snew double*[populationSize_]; crossover_ = operators_["crossover"]; // default: DE crossover mutation_ = operators_["mutation"]; // default: polynomial mutation @@ -84,7 +84,7 @@ SolutionSet * MOEAD::execute() // STEP 2. Update do { - int * permutation = new int[populationSize_]; + int * permutation = snew int[populationSize_]; UtilsMOEAD::randomPermutation(permutation, populationSize_); for (int i = 0; i < populationSize_; i++) { @@ -107,14 +107,14 @@ SolutionSet * MOEAD::execute() // STEP 2.2. Reproduction Solution * child; - Solution ** parents = new Solution*[3]; + Solution ** parents = snew Solution*[3]; parents[0] = population_->get(p[0]); parents[1] = population_->get(p[1]); parents[2] = population_->get(n); // Apply DE crossover - void ** object = new void*[2]; + void ** object = snew void*[2]; object[0] = population_->get(n); object[1] = parents; child = (Solution *) (crossover_->execute(object)); @@ -159,7 +159,7 @@ void MOEAD::initUniformWeight() { for (int n = 0; n < populationSize_; n++) { - lambda_[n] = new double[problem_->getNumberOfObjectives()]; + lambda_[n] = snew double[problem_->getNumberOfObjectives()]; double a = 1.0 * n / (populationSize_ - 1); lambda_[n][0] = a; lambda_[n][1] = 1 - a; @@ -192,7 +192,7 @@ void MOEAD::initUniformWeight() j = 0; // TODO: Check if number of tokens per line is equal to number of // objectives - lambda_[i] = new double[problem_->getNumberOfObjectives()]; + lambda_[i] = snew double[problem_->getNumberOfObjectives()]; while (iss) { string token; @@ -217,8 +217,8 @@ void MOEAD::initUniformWeight() */ void MOEAD::initNeighborhood() { - double * x = new double[populationSize_]; - int * idx = new int[populationSize_]; + double * x = snew double[populationSize_]; + int * idx = snew int[populationSize_]; for (int i = 0; i < populationSize_; i++) { @@ -237,7 +237,7 @@ void MOEAD::initNeighborhood() UtilsMOEAD::minFastSort(x, idx, populationSize_, T_); //minfastsort(x,idx,population.size(),niche); - neighborhood_[i] = new int[T_]; + neighborhood_[i] = snew int[T_]; for (int k = 0; k < T_; k++) { neighborhood_[i][k] = idx[k]; @@ -258,7 +258,7 @@ void MOEAD::initPopulation() { for (int i = 0; i < populationSize_; i++) { - Solution * newSolution = new Solution(problem_); + Solution * newSolution = snew Solution(problem_); problem_->evaluate(newSolution); evaluations_++; @@ -376,7 +376,7 @@ void MOEAD::updateProblem(Solution * indiv, int id, int type) //size = population_.size(); size = populationSize_; } - int * perm = new int[size]; + int * perm = snew int[size]; UtilsMOEAD::randomPermutation(perm, size); @@ -403,7 +403,7 @@ void MOEAD::updateProblem(Solution * indiv, int id, int type) if (f2 < f1) { delete population_->get(k); - population_->replace(k, new Solution(indiv)); + population_->replace(k, snew Solution(indiv)); //population[k].indiv = indiv; time++; } diff --git a/src/metaheuristics/moead/UtilsMOEAD.cpp b/src/metaheuristics/moead/UtilsMOEAD.cpp index e064ecc..d900950 100644 --- a/src/metaheuristics/moead/UtilsMOEAD.cpp +++ b/src/metaheuristics/moead/UtilsMOEAD.cpp @@ -20,6 +20,7 @@ // along with this program. If not, see . #include +#include "JMetalHeader.h" /** * Utilities methods to used by MOEA/D @@ -62,7 +63,7 @@ void UtilsMOEAD::minFastSort(double * x, int * idx, int n, int m) void UtilsMOEAD::randomPermutation(int * perm, int size) { - int * index = new int[size]; + int * index = snew int[size]; bool * flag = new bool[size]; for (int n = 0; n < size; n++) diff --git a/src/metaheuristics/omopso/OMOPSO.cpp b/src/metaheuristics/omopso/OMOPSO.cpp index 09eabd7..d5536d2 100644 --- a/src/metaheuristics/omopso/OMOPSO.cpp +++ b/src/metaheuristics/omopso/OMOPSO.cpp @@ -63,7 +63,7 @@ void OMOPSO::initParams() distance = new Distance(); // Create the speed_ vector - speed = new double*[particlesSize]; + speed = snew double*[particlesSize]; } // initParams @@ -228,7 +228,7 @@ SolutionSet *OMOPSO::execute() //-> Step2. Initialize the speed of each particle to 0 for (int i = 0; i < particlesSize; i++) { - speed[i] = new double[problem_->getNumberOfVariables()]; + speed[i] = snew double[problem_->getNumberOfVariables()]; for (int j = 0; j < problem_->getNumberOfVariables(); j++) { speed[i][j] = 0.0; diff --git a/src/metaheuristics/singleObjective/cmaes/CMAES.cpp b/src/metaheuristics/singleObjective/cmaes/CMAES.cpp index e3f6aa8..d958600 100644 --- a/src/metaheuristics/singleObjective/cmaes/CMAES.cpp +++ b/src/metaheuristics/singleObjective/cmaes/CMAES.cpp @@ -49,7 +49,7 @@ SolutionSet * CMAES::execute() //Initialize the variables counteval = 0; - Comparator * comparator = new ObjectiveComparator(0); + Comparator * comparator = snew ObjectiveComparator(0); init(); @@ -83,7 +83,7 @@ SolutionSet * CMAES::execute() delete comparator ; - SolutionSet * resultPopulation = new SolutionSet(1) ; + SolutionSet * resultPopulation = snew SolutionSet(1) ; resultPopulation->add(bestSolutionEver) ; return resultPopulation ; @@ -101,7 +101,7 @@ void CMAES::init() // objective variables initial point default_random_engine generator; - xmean = new double[N]; + xmean = snew double[N]; for (int i = 0; i < N; i++) { double stddev = (problem_->getUpperLimit(i) - problem_->getLowerLimit(i)) /2; @@ -125,7 +125,7 @@ void CMAES::init() mu = (int) floor(lambda/2); // muXone array for weighted recombination - weights = new double[mu]; + weights = snew double[mu]; double sum = 0; for (int i=0; i distribution(0.0,1.0); int N = problem_->getNumberOfVariables(); - double * artmp = new double[N]; + double * artmp = snew double[N]; double sum; for (int iNk = 0; iNk < populationSize; iNk++) @@ -263,10 +263,10 @@ SolutionSet * CMAES::samplePopulation() SolutionSet * CMAES::genoPhenoTransformation(double ** popx) { - SolutionSet * population_ = new SolutionSet(populationSize); + SolutionSet * population_ = snew SolutionSet(populationSize); for (int i = 0; i < populationSize; i++) { - Solution * solution = new Solution(problem_); + Solution * solution = snew Solution(problem_); for (int j = 0; j < problem_->getNumberOfVariables(); j++) { solution->getDecisionVariables()[j]->setValue(popx[i][j]); @@ -320,7 +320,7 @@ Solution * CMAES::resampleSingle(int iNk) Solution * CMAES::genoPhenoTransformation(double * x) { - Solution * solution = new Solution(problem_); + Solution * solution = snew Solution(problem_); for (int i = 0; i < problem_->getNumberOfVariables(); i++) { solution->getDecisionVariables()[i]->setValue(x[i]); @@ -333,7 +333,7 @@ Solution * CMAES::genoPhenoTransformation(double * x) void CMAES::storeBest(Comparator * comparator) { - Solution * bestInPopulation = new Solution(population_->best(comparator)); + Solution * bestInPopulation = snew Solution(population_->best(comparator)); if ((bestSolutionEver == nullptr) || (bestSolutionEver->getObjective(0) > bestInPopulation->getObjective(0))) @@ -358,8 +358,8 @@ void CMAES::updateDistribution() int N = problem_->getNumberOfVariables(); int lambda = populationSize; - double * arfitness = new double[lambda]; - int * arindex = new int[lambda]; + double * arfitness = snew double[lambda]; + int * arindex = snew int[lambda]; /* Sort by fitness and compute weighted mean into xmean */ @@ -385,7 +385,7 @@ void CMAES::updateDistribution() /* Cumulation: Update evolution paths */ - double * artmp = new double[N]; + double * artmp = snew double[N]; for (int i = 0; i < N; i++) { artmp[i] = 0; @@ -471,7 +471,7 @@ void CMAES::updateDistribution() } // eigen decomposition, B==normalized eigenvectors - double * offdiag = new double[N]; + double * offdiag = snew double[N]; UtilsCMAES::tred2(N, B, diagD, offdiag); UtilsCMAES::tql2(N, diagD, offdiag, B); if (UtilsCMAES::checkEigenSystem(N, C, diagD, B) > 0) // for debugging @@ -492,10 +492,10 @@ void CMAES::updateDistribution() // diagD is a vector of standard deviations now //invsqrtC = B * diag(D.^-1) * B'; - double ** artmp2 = new double*[N]; + double ** artmp2 = snew double*[N]; for (int i = 0; i < N; i++) { - artmp2[i] = new double[N]; + artmp2[i] = snew double[N]; //double value = (xmean[i] - xold[i]) / sigma; for (int j = 0; j < N; j++) { diff --git a/src/metaheuristics/singleObjective/differentialEvolution/DE.cpp b/src/metaheuristics/singleObjective/differentialEvolution/DE.cpp index e81dda0..8c94ecc 100644 --- a/src/metaheuristics/singleObjective/differentialEvolution/DE.cpp +++ b/src/metaheuristics/singleObjective/differentialEvolution/DE.cpp @@ -56,7 +56,7 @@ SolutionSet * DE::execute() Operator * crossoverOperator; Comparator * comparator; - comparator = new ObjectiveComparator(0); // Single objective comparator + comparator = snew ObjectiveComparator(0); // Single objective comparator // Differential evolution parameters int r1; @@ -74,14 +74,14 @@ SolutionSet * DE::execute() crossoverOperator = operators_["crossover"]; //Initialize the variables - population = new SolutionSet(populationSize); + population = snew SolutionSet(populationSize); evaluations = 0; // Create the initial solutionSet Solution * newSolution; for (int i = 0; i < populationSize; i++) { - newSolution = new Solution(problem_); + newSolution = snew Solution(problem_); problem_->evaluate(newSolution); problem_->evaluateConstraints(newSolution); evaluations++; @@ -94,7 +94,7 @@ SolutionSet * DE::execute() { // Create the offSpring solutionSet - offspringPopulation = new SolutionSet(populationSize); + offspringPopulation = snew SolutionSet(populationSize); //offspringPopulation.add(new Solution(population.get(0))) ; @@ -102,7 +102,7 @@ SolutionSet * DE::execute() { // Obtain parents. Two parameters are required: the population and the // index of the current individual - void ** object1 = new void*[2]; + void ** object1 = snew void*[2]; object1[0] = population; object1[1] = &i; parent = (Solution **) (selectionOperator->execute(object1)); @@ -112,7 +112,7 @@ SolutionSet * DE::execute() // Crossover. Two parameters are required: the current individual and the // array of parents - void ** object2 = new void*[2]; + void ** object2 = snew void*[2]; object2[0] = population->get(i); object2[1] = parent; child = (Solution *) (crossoverOperator->execute(object2)); @@ -125,7 +125,7 @@ SolutionSet * DE::execute() if (comparator->compare(population->get(i), child) < 0) { - offspringPopulation->add(new Solution(population->get(i))); + offspringPopulation->add(snew Solution(population->get(i))); delete child; } else @@ -152,8 +152,8 @@ SolutionSet * DE::execute() delete comparator; // Return a population with the best individual - SolutionSet * resultPopulation = new SolutionSet(1); - resultPopulation->add(new Solution(population->get(0))); + SolutionSet * resultPopulation = snew SolutionSet(1); + resultPopulation->add(snew Solution(population->get(0))); delete population; return resultPopulation; diff --git a/src/metaheuristics/singleObjective/geneticAlgorithm/gGA.cpp b/src/metaheuristics/singleObjective/geneticAlgorithm/gGA.cpp index 6b94511..0eefcfb 100644 --- a/src/metaheuristics/singleObjective/geneticAlgorithm/gGA.cpp +++ b/src/metaheuristics/singleObjective/geneticAlgorithm/gGA.cpp @@ -53,7 +53,7 @@ SolutionSet * gGA::execute() Operator * crossoverOperator; Operator * selectionOperator; - Comparator * comparator = new ObjectiveComparator(0) ; + Comparator * comparator = snew ObjectiveComparator(0) ; //Read the parameters populationSize = *(int *) getInputParameter("populationSize"); @@ -63,7 +63,7 @@ SolutionSet * gGA::execute() // cout << "maxEvaluations = " << maxEvaluations << endl; //Initialize the variables - population = new SolutionSet(populationSize); + population = snew SolutionSet(populationSize); evaluations = 0; // cout << "Poblacion inicializada con maxsize = " << population->getMaxSize() << endl; @@ -81,7 +81,7 @@ SolutionSet * gGA::execute() Solution * newSolution; for (int i = 0; i < populationSize; i++) { - newSolution = new Solution(problem_); + newSolution = snew Solution(problem_); problem_->evaluate(newSolution); problem_->evaluateConstraints(newSolution); evaluations++; @@ -96,8 +96,8 @@ SolutionSet * gGA::execute() { // Create the offSpring solutionSet - offspringPopulation = new SolutionSet(populationSize); - Solution ** parents = new Solution*[2]; + offspringPopulation = snew SolutionSet(populationSize); + Solution ** parents = snew Solution*[2]; for (int i = 0; i < (populationSize / 2); i++) { @@ -127,8 +127,8 @@ SolutionSet * gGA::execute() delete offspringPopulation->get(offspringPopulation->size()-1); delete offspringPopulation->get(offspringPopulation->size()-2); - offspringPopulation->replace(offspringPopulation->size()-1, new Solution(population->get(0))) ; - offspringPopulation->replace(offspringPopulation->size()-2, new Solution(population->get(1))) ; + offspringPopulation->replace(offspringPopulation->size()-1, snew Solution(population->get(0))) ; + offspringPopulation->replace(offspringPopulation->size()-2, snew Solution(population->get(1))) ; for (int i=0; isize(); i++) { @@ -144,8 +144,8 @@ SolutionSet * gGA::execute() delete comparator; - SolutionSet * resultPopulation = new SolutionSet(1) ; - resultPopulation->add(new Solution(population->get(0))) ; + SolutionSet * resultPopulation = snew SolutionSet(1) ; + resultPopulation->add(snew Solution(population->get(0))) ; delete population; return resultPopulation ; diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp b/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp index 6a24fef..b81401e 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp @@ -77,10 +77,10 @@ void PSO::initParams() localBest_ = new Solution*[particlesSize_]; // Create the speed_ vector - speed_ = new double*[particlesSize_]; + speed_ = snew double*[particlesSize_]; - deltaMax_ = new double[problem_->getNumberOfVariables()]; - deltaMin_ = new double[problem_->getNumberOfVariables()]; + deltaMax_ = snew double[problem_->getNumberOfVariables()]; + deltaMin_ = snew double[problem_->getNumberOfVariables()]; for (int i = 0; i < problem_->getNumberOfVariables(); i++) { deltaMax_[i] = (problem_->getUpperLimit(i) - @@ -310,7 +310,7 @@ SolutionSet * PSO::execute() //-> Step2. Initialize the speed_ of each particle to 0 for (int i = 0; i < particlesSize_; i++) { - speed_[i] = new double[problem_->getNumberOfVariables()]; + speed_[i] = snew double[problem_->getNumberOfVariables()]; for (int j = 0; j < problem_->getNumberOfVariables(); j++) { speed_[i][j] = 0.0; diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp index 2bfcf2c..dcbec27 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp @@ -89,7 +89,7 @@ void StandardPSO2007::initParams() neighborhoodBest_ = new Solution*[swarmSize_]; // Create the speed_ vector - speed_ = new double*[swarmSize_]; + speed_ = snew double*[swarmSize_]; } // initParams @@ -220,7 +220,7 @@ SolutionSet * StandardPSO2007::execute() for (int i = 0; i < swarmSize_; i++) { XReal * particle = new XReal(swarm_->get(i)) ; - speed_[i] = new double[problem_->getNumberOfVariables()]; + speed_[i] = snew double[problem_->getNumberOfVariables()]; for (int j = 0; j < problem_->getNumberOfVariables(); j++) { speed_[i][j] = (PseudoRandom::randDouble(particle->getLowerBound(j),particle->getUpperBound(j)) diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp index 69ff193..a6732f1 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp @@ -90,7 +90,7 @@ void StandardPSO2011::initParams() neighborhoodBest_ = new Solution*[swarmSize_]; // Create the speed_ vector - speed_ = new double*[swarmSize_]; + speed_ = snew double*[swarmSize_]; } // initParams @@ -246,7 +246,7 @@ SolutionSet * StandardPSO2011::execute() for (int i = 0; i < swarmSize_; i++) { XReal * particle = new XReal(swarm_->get(i)) ; - speed_[i] = new double[problem_->getNumberOfVariables()]; + speed_[i] = snew double[problem_->getNumberOfVariables()]; for (int j = 0; j < problem_->getNumberOfVariables(); j++) { speed_[i][j] = (PseudoRandom::randDouble( diff --git a/src/metaheuristics/smpso/SMPSO.cpp b/src/metaheuristics/smpso/SMPSO.cpp index 5de1ad5..156e634 100644 --- a/src/metaheuristics/smpso/SMPSO.cpp +++ b/src/metaheuristics/smpso/SMPSO.cpp @@ -79,12 +79,12 @@ void SMPSO::initParams() // Create the speed_ vector int numberOfVariables = problem_->getNumberOfVariables(); - //speed_ = new double[swarmSize_][numberOfVariables]; - speed_ = new double*[swarmSize_]; + //speed_ = snew double[swarmSize_][numberOfVariables]; + speed_ = snew double*[swarmSize_]; // TODO: Liberar memoria al finalizar - deltaMax_ = new double[problem_->getNumberOfVariables()]; - deltaMin_ = new double[problem_->getNumberOfVariables()]; + deltaMax_ = snew double[problem_->getNumberOfVariables()]; + deltaMin_ = snew double[problem_->getNumberOfVariables()]; for (int i = 0; i < problem_->getNumberOfVariables(); i++) { deltaMax_[i] = (problem_->getUpperLimit(i) - @@ -341,7 +341,7 @@ SolutionSet * SMPSO::execute() //-> Step2. Initialize the speed_ of each particle to 0 for (int i = 0; i < swarmSize_; i++) { - speed_[i] = new double[problem_->getNumberOfVariables()]; + speed_[i] = snew double[problem_->getNumberOfVariables()]; for (int j = 0; j < problem_->getNumberOfVariables(); j++) { speed_[i][j] = 0.0; diff --git a/src/metaheuristics/smpso/SMPSOhv.cpp b/src/metaheuristics/smpso/SMPSOhv.cpp index 30fc87d..323d5f2 100644 --- a/src/metaheuristics/smpso/SMPSOhv.cpp +++ b/src/metaheuristics/smpso/SMPSOhv.cpp @@ -74,10 +74,10 @@ void SMPSOhv::initParams() distance = new Distance(); // Create the speed_ vector - speed = new double*[swarmSize]; + speed = snew double*[swarmSize]; - deltaMax = new double[problem_->getNumberOfVariables()]; - deltaMin = new double[problem_->getNumberOfVariables()]; + deltaMax = snew double[problem_->getNumberOfVariables()]; + deltaMin = snew double[problem_->getNumberOfVariables()]; for (int i = 0; i < problem_->getNumberOfVariables(); i++) { deltaMax[i] = (problem_->getUpperLimit(i) - @@ -300,7 +300,7 @@ SolutionSet *SMPSOhv::execute() //-> Step2. Initialize the speed of each particle to 0 for (int i = 0; i < swarmSize; i++) { - speed[i] = new double[problem_->getNumberOfVariables()]; + speed[i] = snew double[problem_->getNumberOfVariables()]; for (int j = 0; j < problem_->getNumberOfVariables(); j++) { speed[i][j] = 0.0; diff --git a/src/metaheuristics/smsemoa/FastSMSEMOA.cpp b/src/metaheuristics/smsemoa/FastSMSEMOA.cpp index be620c2..a6b1700 100644 --- a/src/metaheuristics/smsemoa/FastSMSEMOA.cpp +++ b/src/metaheuristics/smsemoa/FastSMSEMOA.cpp @@ -34,8 +34,8 @@ */ FastSMSEMOA::FastSMSEMOA(Problem *problem) : Algorithm(problem) { - utils_ = new MetricsUtil(); - hv_ = new Hypervolume(); + utils_ = snew MetricsUtil(); + hv_ = snew Hypervolume(); } // FastSMSEMOA /** @@ -79,12 +79,12 @@ SolutionSet * FastSMSEMOA::execute() offset = *(double *) getInputParameter("offset"); //Initialize the variables - population = new SolutionSet(populationSize); + population = snew SolutionSet(populationSize); evaluations = 0; requiredEvaluations = 0; - fastHypervolume = new FastHypervolume(offset); + fastHypervolume = snew FastHypervolume(offset); //Read the operator mutationOperator = operators_["mutation"]; @@ -95,7 +95,7 @@ SolutionSet * FastSMSEMOA::execute() Solution * newSolution; for (int i = 0; i < populationSize; i++) { - newSolution = new Solution(problem_); + newSolution = snew Solution(problem_); problem_->evaluate(newSolution); problem_->evaluateConstraints(newSolution); evaluations++; @@ -107,7 +107,7 @@ SolutionSet * FastSMSEMOA::execute() { // select parents - offspringPopulation = new SolutionSet(1); + offspringPopulation = snew SolutionSet(1); /* LinkedList selectedParents = new LinkedList(); Solution[] parents = new Solution[0]; @@ -150,7 +150,7 @@ SolutionSet * FastSMSEMOA::execute() delete offspringPopulation; // Ranking the union (non-dominated sorting) - Ranking * ranking = new Ranking(unionSolution); + Ranking * ranking = snew Ranking(unionSolution); // ensure crowding distance values are up to date // (may be important for parent selection) @@ -163,7 +163,7 @@ SolutionSet * FastSMSEMOA::execute() //FastHypervolume fastHypervolume = new FastHypervolume() ; fastHypervolume->computeHVContributions(lastFront); - CrowdingDistanceComparator * cd = new CrowdingDistanceComparator(); + CrowdingDistanceComparator * cd = snew CrowdingDistanceComparator(); lastFront->sort(cd); delete cd; @@ -179,12 +179,12 @@ SolutionSet * FastSMSEMOA::execute() front = ranking->getSubfront(i); for (int j = 0; j < front->size(); j++) { - population->add(new Solution(front->get(j))); + population->add(snew Solution(front->get(j))); } } for (int i = 0; i < lastFront->size() - 1; i++) { - population->add(new Solution(lastFront->get(i))); + population->add(snew Solution(lastFront->get(i))); } delete unionSolution; @@ -208,12 +208,12 @@ SolutionSet * FastSMSEMOA::execute() //setOutputParameter("evaluations", requiredEvaluations); // Return the first non-dominated front - Ranking * ranking = new Ranking(population); + Ranking * ranking = snew Ranking(population); - SolutionSet * result = new SolutionSet(ranking->getSubfront(0)->size()); + SolutionSet * result = snew SolutionSet(ranking->getSubfront(0)->size()); for (int i=0; igetSubfront(0)->size(); i++) { - result->add(new Solution(ranking->getSubfront(0)->get(i))); + result->add(snew Solution(ranking->getSubfront(0)->get(i))); } delete ranking; delete population; diff --git a/src/metaheuristics/smsemoa/SMSEMOA.cpp b/src/metaheuristics/smsemoa/SMSEMOA.cpp index 5129fbd..bf68d5b 100644 --- a/src/metaheuristics/smsemoa/SMSEMOA.cpp +++ b/src/metaheuristics/smsemoa/SMSEMOA.cpp @@ -249,12 +249,12 @@ vector SMSEMOA::hvContributions(vector< vector > front) vector< vector > frontCopy; - double** totalFront = new double*[front.size()]; + double** totalFront = snew double*[front.size()]; for (int i = 0; i < front.size(); i++) { frontCopy.push_back(vector()); - totalFront[i] = new double[front[i].size()]; + totalFront[i] = snew double[front[i].size()]; for (int j = 0; j < front[i].size(); j++) { frontCopy[i].push_back(front[i][j]); @@ -275,10 +275,10 @@ vector SMSEMOA::hvContributions(vector< vector > front) frontCopy.erase(frontCopy.begin() + i); /*Makes a copy in pointer of pointer format*/ - frontSubset = new double*[frontCopy.size()]; + frontSubset = snew double*[frontCopy.size()]; for (int f = 0; f < frontCopy.size(); f++) { - frontSubset[f] = new double[frontCopy[f].size()]; + frontSubset[f] = snew double[frontCopy[f].size()]; for (int c = 0; c < frontCopy[f].size(); c++) { frontSubset[f][c]=frontCopy[f][c]; diff --git a/src/operators/crossover/DifferentialEvolutionCrossover.cpp b/src/operators/crossover/DifferentialEvolutionCrossover.cpp index a13fa5b..86b9080 100644 --- a/src/operators/crossover/DifferentialEvolutionCrossover.cpp +++ b/src/operators/crossover/DifferentialEvolutionCrossover.cpp @@ -128,13 +128,13 @@ void * DifferentialEvolutionCrossover::execute(void *object) int jrand; - child = new Solution(current); + child = snew Solution(current); - XReal * xParent0 = new XReal(parent[0]); - XReal * xParent1 = new XReal(parent[1]); - XReal * xParent2 = new XReal(parent[2]); - XReal * xCurrent = new XReal(current); - XReal * xChild = new XReal(child); + XReal * xParent0 = snew XReal(parent[0]); + XReal * xParent1 = snew XReal(parent[1]); + XReal * xParent2 = snew XReal(parent[2]); + XReal * xCurrent = snew XReal(current); + XReal * xChild = snew XReal(child); int numberOfVariables = xParent0->getNumberOfDecisionVariables(); jrand = PseudoRandom::randInt(0, numberOfVariables - 1); diff --git a/src/operators/crossover/HUXCrossover.cpp b/src/operators/crossover/HUXCrossover.cpp index f3b632f..11b48f4 100644 --- a/src/operators/crossover/HUXCrossover.cpp +++ b/src/operators/crossover/HUXCrossover.cpp @@ -47,7 +47,7 @@ HUXCrossover::HUXCrossover(map parameters) Solution ** HUXCrossover::doCrossover(double probability, Solution *parent1, Solution *parent2) { - Solution** offSpring = new Solution*[2]; + Solution** offSpring = snew Solution*[2]; if (offSpring == nullptr) { @@ -55,8 +55,8 @@ Solution ** HUXCrossover::doCrossover(double probability, Solution *parent1, Sol exit(-1); } - offSpring[0] = new Solution(parent1); - offSpring[1] = new Solution(parent2); + offSpring[0] = snew Solution(parent1); + offSpring[1] = snew Solution(parent2); if (PseudoRandom::randDouble() < probability) { diff --git a/src/operators/selection/BestSolutionSelection.cpp b/src/operators/selection/BestSolutionSelection.cpp index e35ba94..be4990d 100644 --- a/src/operators/selection/BestSolutionSelection.cpp +++ b/src/operators/selection/BestSolutionSelection.cpp @@ -67,7 +67,7 @@ void * BestSolutionSelection::execute(void * object) } } // for - int * intPtr = new int(bestSolution); + int * intPtr = snew int(bestSolution); return intPtr; } // execute diff --git a/src/operators/selection/BinaryTournament.cpp b/src/operators/selection/BinaryTournament.cpp index 141ce1a..30f21b2 100644 --- a/src/operators/selection/BinaryTournament.cpp +++ b/src/operators/selection/BinaryTournament.cpp @@ -38,7 +38,7 @@ BinaryTournament::BinaryTournament(map parameters) if (parameters["comparator"] != nullptr) comparator_ = (Comparator *) parameters["comparator"]; else - comparator_ = new DominanceComparator(); + comparator_ = snew DominanceComparator(); } // BinaryTournament diff --git a/src/operators/selection/BinaryTournament2.cpp b/src/operators/selection/BinaryTournament2.cpp index bb5305e..0636502 100644 --- a/src/operators/selection/BinaryTournament2.cpp +++ b/src/operators/selection/BinaryTournament2.cpp @@ -39,8 +39,8 @@ BinaryTournament2::BinaryTournament2(map parameters) : Selection(parameters) { index_ = 0; - a_ = new int[1]; // Initialized as dummy - dominance_ = new DominanceComparator(); + a_ = snew int[1]; // Initialized as dummy + dominance_ = snew DominanceComparator(); if (dominance_ == nullptr) { cout << "BinaryTournament::BinaryTournament: error creating comparator" ; @@ -72,7 +72,7 @@ void * BinaryTournament2::execute(void * object) if (index_ == 0) //Create the permutation { - PermutationUtility * permutationUtility = new PermutationUtility(); + PermutationUtility * permutationUtility = snew PermutationUtility(); delete [] a_; a_= permutationUtility->intPermutation(population->size()); delete permutationUtility; diff --git a/src/operators/selection/DifferentialEvolutionSelection.cpp b/src/operators/selection/DifferentialEvolutionSelection.cpp index 9550da8..2015b78 100644 --- a/src/operators/selection/DifferentialEvolutionSelection.cpp +++ b/src/operators/selection/DifferentialEvolutionSelection.cpp @@ -49,7 +49,7 @@ void * DifferentialEvolutionSelection::execute(void * object) SolutionSet * population = (SolutionSet *) parameters[0]; int index = *(int *) parameters[1] ; - Solution ** parents = new Solution*[3]; + Solution ** parents = snew Solution*[3]; int r1, r2, r3; if (population->size() < 4) diff --git a/src/operators/selection/WorstSolutionSelection.cpp b/src/operators/selection/WorstSolutionSelection.cpp index 733c7a6..75f3256 100644 --- a/src/operators/selection/WorstSolutionSelection.cpp +++ b/src/operators/selection/WorstSolutionSelection.cpp @@ -67,7 +67,7 @@ void * WorstSolutionSelection::execute(void * object) } } // for - int * intPtr = new int(worstSolution); + int * intPtr = snew int(worstSolution); return intPtr; } // execute diff --git a/src/problems/DTLZ/DTLZ1.cpp b/src/problems/DTLZ/DTLZ1.cpp index bcceb0e..0ae7cbf 100644 --- a/src/problems/DTLZ/DTLZ1.cpp +++ b/src/problems/DTLZ/DTLZ1.cpp @@ -29,14 +29,14 @@ DTLZ1::DTLZ1(string solutionType, int numberOfVariables, int numberOfObjectives) numberOfConstraints_ = 0; problemName_ = "DTLZ1"; - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; @@ -50,22 +50,22 @@ DTLZ1::DTLZ1(string solutionType, int numberOfVariables, int numberOfObjectives) } if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; + solutionType_ = snew BinaryRealSolutionType(this) ; else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; + solutionType_ = snew RealSolutionType(this) ; //cout << "Tipo seleccionado Real" << endl; } else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; + solutionType_ = snew ArrayRealSolutionType(this) ; else { cout << "Error: solution type " << solutionType << " invalid" << endl; exit(-1) ; } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; + fx_ = snew double[numberOfObjectives_] ; + x_ = snew double[numberOfVariables_]; } DTLZ1::~DTLZ1() @@ -83,7 +83,7 @@ DTLZ1::~DTLZ1() */ void DTLZ1::evaluate(Solution *solution) { - XReal * vars = new XReal(solution); + XReal * vars = snew XReal(solution); int k = numberOfVariables_ - numberOfObjectives_ + 1; diff --git a/src/problems/DTLZ/DTLZ2.cpp b/src/problems/DTLZ/DTLZ2.cpp index 18c844f..5fee5d8 100644 --- a/src/problems/DTLZ/DTLZ2.cpp +++ b/src/problems/DTLZ/DTLZ2.cpp @@ -29,14 +29,14 @@ DTLZ2::DTLZ2(string solutionType, int numberOfVariables, int numberOfObjectives) numberOfConstraints_ = 0; problemName_ = "DTLZ2"; - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; @@ -50,22 +50,22 @@ DTLZ2::DTLZ2(string solutionType, int numberOfVariables, int numberOfObjectives) } if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; + solutionType_ = snew BinaryRealSolutionType(this) ; else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; + solutionType_ = snew RealSolutionType(this) ; //cout << "Tipo seleccionado Real" << endl; } else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; + solutionType_ = snew ArrayRealSolutionType(this) ; else { cout << "Error: solution type " << solutionType << " invalid" << endl; exit(-1) ; } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; + fx_ = snew double[numberOfObjectives_] ; + x_ = snew double[numberOfVariables_]; } DTLZ2::~DTLZ2() @@ -83,7 +83,7 @@ DTLZ2::~DTLZ2() */ void DTLZ2::evaluate(Solution *solution) { - XReal * vars = new XReal(solution); + XReal * vars = snew XReal(solution); int k = numberOfVariables_ - numberOfObjectives_ + 1; diff --git a/src/problems/DTLZ/DTLZ3.cpp b/src/problems/DTLZ/DTLZ3.cpp index 32c551f..f22ae56 100644 --- a/src/problems/DTLZ/DTLZ3.cpp +++ b/src/problems/DTLZ/DTLZ3.cpp @@ -29,14 +29,14 @@ DTLZ3::DTLZ3(string solutionType, int numberOfVariables, int numberOfObjectives) numberOfConstraints_ = 0; problemName_ = "DTLZ3"; - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; @@ -50,21 +50,21 @@ DTLZ3::DTLZ3(string solutionType, int numberOfVariables, int numberOfObjectives) } if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; + solutionType_ = snew BinaryRealSolutionType(this) ; else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; + solutionType_ = snew RealSolutionType(this) ; // cout << "Tipo seleccionado Real" << endl; } else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; + solutionType_ = snew ArrayRealSolutionType(this) ; else { cout << "Error: solution type " << solutionType << " invalid" << endl; exit(-1) ; } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; + fx_ = snew double[numberOfObjectives_] ; + x_ = snew double[numberOfVariables_]; } DTLZ3::~DTLZ3() @@ -80,7 +80,7 @@ DTLZ3::~DTLZ3() */ void DTLZ3::evaluate(Solution *solution) { - XReal * vars = new XReal(solution); + XReal * vars = snew XReal(solution); int k = numberOfVariables_ - numberOfObjectives_ + 1; diff --git a/src/problems/DTLZ/DTLZ4.cpp b/src/problems/DTLZ/DTLZ4.cpp index 8287414..86a8287 100644 --- a/src/problems/DTLZ/DTLZ4.cpp +++ b/src/problems/DTLZ/DTLZ4.cpp @@ -29,14 +29,14 @@ DTLZ4::DTLZ4(string solutionType, int numberOfVariables, int numberOfObjectives) numberOfConstraints_ = 0; problemName_ = "DTLZ4"; - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; @@ -50,22 +50,22 @@ DTLZ4::DTLZ4(string solutionType, int numberOfVariables, int numberOfObjectives) } if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; + solutionType_ = snew BinaryRealSolutionType(this) ; else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; + solutionType_ = snew RealSolutionType(this) ; // cout << "Tipo seleccionado Real" << endl; } else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; + solutionType_ = snew ArrayRealSolutionType(this) ; else { cout << "Error: solution type " << solutionType << " invalid" << endl; exit(-1) ; } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; + fx_ = snew double[numberOfObjectives_] ; + x_ = snew double[numberOfVariables_]; } DTLZ4::~DTLZ4() @@ -81,7 +81,7 @@ DTLZ4::~DTLZ4() */ void DTLZ4::evaluate(Solution *solution) { - XReal * vars = new XReal(solution); + XReal * vars = snew XReal(solution); int k = numberOfVariables_ - numberOfObjectives_ + 1; double alpha = 100.0; diff --git a/src/problems/DTLZ/DTLZ5.cpp b/src/problems/DTLZ/DTLZ5.cpp index 4e80e87..cd1f768 100644 --- a/src/problems/DTLZ/DTLZ5.cpp +++ b/src/problems/DTLZ/DTLZ5.cpp @@ -29,14 +29,14 @@ DTLZ5::DTLZ5(string solutionType, int numberOfVariables, int numberOfObjectives) numberOfConstraints_ = 0; problemName_ = "DTLZ5"; - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; @@ -50,23 +50,23 @@ DTLZ5::DTLZ5(string solutionType, int numberOfVariables, int numberOfObjectives) } if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; + solutionType_ = snew BinaryRealSolutionType(this) ; else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; + solutionType_ = snew RealSolutionType(this) ; //cout << "Tipo seleccionado Real" << endl; } else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; + solutionType_ = snew ArrayRealSolutionType(this) ; else { cout << "Error: solution type " << solutionType << " invalid" << endl; exit(-1) ; } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; - theta_ = new double[numberOfObjectives_-1]; + fx_ = snew double[numberOfObjectives_] ; + x_ = snew double[numberOfVariables_]; + theta_ = snew double[numberOfObjectives_-1]; } DTLZ5::~DTLZ5() @@ -83,7 +83,7 @@ DTLZ5::~DTLZ5() */ void DTLZ5::evaluate(Solution *solution) { - XReal * vars = new XReal(solution); + XReal * vars = snew XReal(solution); double g = 0.0; int k = numberOfVariables_ - numberOfObjectives_ + 1; diff --git a/src/problems/DTLZ/DTLZ6.cpp b/src/problems/DTLZ/DTLZ6.cpp index cff8b5a..eab58bb 100644 --- a/src/problems/DTLZ/DTLZ6.cpp +++ b/src/problems/DTLZ/DTLZ6.cpp @@ -29,14 +29,14 @@ DTLZ6::DTLZ6(string solutionType, int numberOfVariables, int numberOfObjectives) numberOfConstraints_ = 0; problemName_ = "DTLZ6"; - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; @@ -50,23 +50,23 @@ DTLZ6::DTLZ6(string solutionType, int numberOfVariables, int numberOfObjectives) } if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; + solutionType_ = snew BinaryRealSolutionType(this) ; else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; + solutionType_ = snew RealSolutionType(this) ; //cout << "Tipo seleccionado Real" << endl; } else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; + solutionType_ = snew ArrayRealSolutionType(this) ; else { cout << "Error: solution type " << solutionType << " invalid" << endl; exit(-1) ; } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; - theta_ = new double[numberOfObjectives_-1]; + fx_ = snew double[numberOfObjectives_] ; + x_ = snew double[numberOfVariables_]; + theta_ = snew double[numberOfObjectives_-1]; } DTLZ6::~DTLZ6() @@ -83,7 +83,7 @@ DTLZ6::~DTLZ6() */ void DTLZ6::evaluate(Solution *solution) { - XReal * vars = new XReal(solution); + XReal * vars = snew XReal(solution); double g = 0.0; int k = numberOfVariables_ - numberOfObjectives_ + 1; diff --git a/src/problems/DTLZ/DTLZ7.cpp b/src/problems/DTLZ/DTLZ7.cpp index ced2b4d..6f66bfa 100644 --- a/src/problems/DTLZ/DTLZ7.cpp +++ b/src/problems/DTLZ/DTLZ7.cpp @@ -29,14 +29,14 @@ DTLZ7::DTLZ7(string solutionType, int numberOfVariables, int numberOfObjectives) numberOfConstraints_ = 0; problemName_ = "DTLZ7"; - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; @@ -50,22 +50,22 @@ DTLZ7::DTLZ7(string solutionType, int numberOfVariables, int numberOfObjectives) } if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; + solutionType_ = snew BinaryRealSolutionType(this) ; else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; + solutionType_ = snew RealSolutionType(this) ; //cout << "Tipo seleccionado Real" << endl; } else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; + solutionType_ = snew ArrayRealSolutionType(this) ; else { cout << "Error: solution type " << solutionType << " invalid" << endl; exit(-1) ; } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; + fx_ = snew double[numberOfObjectives_] ; + x_ = snew double[numberOfVariables_]; } DTLZ7::~DTLZ7() @@ -81,7 +81,7 @@ DTLZ7::~DTLZ7() */ void DTLZ7::evaluate(Solution *solution) { - XReal * vars = new XReal(solution); + XReal * vars = snew XReal(solution); double g = 0.0; int k = numberOfVariables_ - numberOfObjectives_ + 1; diff --git a/src/problems/Fonseca.cpp b/src/problems/Fonseca.cpp index 90a5f07..a64b017 100644 --- a/src/problems/Fonseca.cpp +++ b/src/problems/Fonseca.cpp @@ -31,13 +31,13 @@ Fonseca::Fonseca(string solutionType) numberOfConstraints_ = 0; problemName_ = "Fonseca"; - lowerLimit_ = new double[numberOfVariables_]; + lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { cout << "Fonseca::Fonseca. Error reserving memory for storing the array of lower limits" << endl; } // if - upperLimit_ = new double[numberOfVariables_]; + upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { cout << "Fonseca::Fonseca. Error reserving memory for storing the array of upper limits" << endl; @@ -53,16 +53,16 @@ Fonseca::Fonseca(string solutionType) if (solutionType.compare("BinaryReal") == 0) { //cout << "Selected solution type: BinaryReal" << endl; - solutionType_ = new BinaryRealSolutionType(this) ; + solutionType_ = snew BinaryRealSolutionType(this) ; } else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; + solutionType_ = snew RealSolutionType(this) ; //cout << "Selected solution type: Real" << endl; } else if (solutionType.compare("ArrayReal") == 0) { - solutionType_ = new ArrayRealSolutionType(this) ; + solutionType_ = snew ArrayRealSolutionType(this) ; } else { @@ -92,14 +92,14 @@ void Fonseca::evaluate(Solution *solution) double *x ; Variable **variables = solution->getDecisionVariables(); - fx = new double[numberOfObjectives_]; + fx = snew double[numberOfObjectives_]; if (fx == nullptr) { cout << "Fonseca::evaluate: Error reserving memory for the function values array" << endl; exit(-1); } // if - x = new double[numberOfVariables_]; + x = snew double[numberOfVariables_]; if (x == nullptr) { cout << "Fonseca::evaluate: Error reserving memory for the variable values array" << endl; diff --git a/src/problems/Kursawe.cpp b/src/problems/Kursawe.cpp index 1b14cf9..04b8976 100644 --- a/src/problems/Kursawe.cpp +++ b/src/problems/Kursawe.cpp @@ -43,14 +43,14 @@ Kursawe::Kursawe(string solutionType, int numberOfVariables) numberOfConstraints_ = 0; problemName_ = "Kursawe"; - lowerLimit_ = new double[numberOfVariables_]; + lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } - upperLimit_ = new double[numberOfVariables_]; + upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; @@ -64,14 +64,14 @@ Kursawe::Kursawe(string solutionType, int numberOfVariables) } if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; + solutionType_ = snew BinaryRealSolutionType(this) ; else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; + solutionType_ = snew RealSolutionType(this) ; //cout << "Tipo seleccionado Real" << endl; } else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; + solutionType_ = snew ArrayRealSolutionType(this) ; else { cout << "Error: solution type " << solutionType << " invalid" << endl; @@ -98,17 +98,17 @@ Kursawe::~Kursawe() void Kursawe::evaluate(Solution *solution) { - XReal * vars = new XReal(solution); + XReal * vars = snew XReal(solution); double aux, xi, xj; // auxiliary variables - double * fx = new double[2]; // function values + double * fx = snew double[2]; // function values if (fx == nullptr) { cout << "Error grave: Impossible to reserve memory while evaluating the problem" << endl; exit(-1); } - double * x = new double[numberOfVariables_]; + double * x = snew double[numberOfVariables_]; for (int i = 0 ; i < numberOfVariables_; i++) { x[i] = vars->getValue(i) ; diff --git a/src/problems/LZ09/LZ09.cpp b/src/problems/LZ09/LZ09.cpp index ae6b720..1ae5e05 100644 --- a/src/problems/LZ09/LZ09.cpp +++ b/src/problems/LZ09/LZ09.cpp @@ -328,7 +328,7 @@ void LZ09::objective(vector *x_var, vector *y_obj) g = betaFunction(&aa,dtype_); // distance function h = betaFunction(&bb,dtype_); - //double * alpha = new double[2]; + //double * alpha = snew double[2]; double alpha[2] ; alphaFunction(alpha,x_var,2,ptype_); // shape function y_obj->at(0) = alpha[0] + h; @@ -360,7 +360,7 @@ void LZ09::objective(vector *x_var, vector *y_obj) h = betaFunction(&bb,dtype_); e = betaFunction(&cc,dtype_); - //double * alpha = new double[3]; + //double * alpha = snew double[3]; double alpha[3] ; alphaFunction(alpha,x_var,3,ptype_); // shape function y_obj->at(0) = alpha[0] + h; diff --git a/src/problems/LZ09/LZ09_F1.cpp b/src/problems/LZ09/LZ09_F1.cpp index 1d74674..1106de8 100644 --- a/src/problems/LZ09/LZ09_F1.cpp +++ b/src/problems/LZ09/LZ09_F1.cpp @@ -30,13 +30,13 @@ LZ09_F1::LZ09_F1(string solutionType, int ptype, int dtype, int ltype) numberOfConstraints_= 0; problemName_ = "LZ09_F1"; - LZ09_ = new LZ09(numberOfVariables_, + LZ09_ = snew LZ09(numberOfVariables_, numberOfObjectives_, ptype, dtype, ltype) ; - lowerLimit_ = new double[numberOfVariables_]; + lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { cout << "LZ09_F1::LZ09_F1: Error reserving memory for storing the " @@ -44,7 +44,7 @@ LZ09_F1::LZ09_F1(string solutionType, int ptype, int dtype, int ltype) exit(-1); } - upperLimit_ = new double[numberOfVariables_]; + upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { cout << "LZ09_F1::LZ09_F1: Error reserving memory for storing the " @@ -59,21 +59,21 @@ LZ09_F1::LZ09_F1(string solutionType, int ptype, int dtype, int ltype) } if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; + solutionType_ = snew BinaryRealSolutionType(this) ; else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; + solutionType_ = snew RealSolutionType(this) ; } else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; + solutionType_ = snew ArrayRealSolutionType(this) ; else { cout << "LZ09_F1::LZ09_F1: solution type " << solutionType << " invalid" << endl; exit(-1) ; } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; + fx_ = snew double[numberOfObjectives_] ; + x_ = snew double[numberOfVariables_]; } // LZ09_F1::LZ09_F1 /** @@ -89,10 +89,10 @@ LZ09_F1::~LZ09_F1 () void LZ09_F1::evaluate(Solution * solution) { - XReal * vars = new XReal(solution); + XReal * vars = snew XReal(solution); - vector * x = new vector(numberOfVariables_) ; - vector * y = new vector(numberOfObjectives_); + vector * x = snew vector(numberOfVariables_) ; + vector * y = snew vector(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F2.cpp b/src/problems/LZ09/LZ09_F2.cpp index 001bb13..5d14f86 100644 --- a/src/problems/LZ09/LZ09_F2.cpp +++ b/src/problems/LZ09/LZ09_F2.cpp @@ -30,13 +30,13 @@ LZ09_F2::LZ09_F2(string solutionType, int ptype, int dtype, int ltype) numberOfConstraints_= 0; problemName_ = "LZ09_F2"; - LZ09_ = new LZ09(numberOfVariables_, + LZ09_ = snew LZ09(numberOfVariables_, numberOfObjectives_, ptype, dtype, ltype) ; - lowerLimit_ = new double[numberOfVariables_]; + lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { cout << "LZ09_F2::LZ09_F2: Error reserving memory for storing the " @@ -44,7 +44,7 @@ LZ09_F2::LZ09_F2(string solutionType, int ptype, int dtype, int ltype) exit(-1); } - upperLimit_ = new double[numberOfVariables_]; + upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { cout << "LZ09_F2::LZ09_F2: Error reserving memory for storing the " @@ -61,21 +61,21 @@ LZ09_F2::LZ09_F2(string solutionType, int ptype, int dtype, int ltype) } if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; + solutionType_ = snew BinaryRealSolutionType(this) ; else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; + solutionType_ = snew RealSolutionType(this) ; } else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; + solutionType_ = snew ArrayRealSolutionType(this) ; else { cout << "LZ09_F2::LZ09_F2: solution type " << solutionType << " invalid" << endl; exit(-1) ; } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; + fx_ = snew double[numberOfObjectives_] ; + x_ = snew double[numberOfVariables_]; } // LZ09_F2::LZ09_F2 /** @@ -91,10 +91,10 @@ LZ09_F2::~LZ09_F2 () void LZ09_F2::evaluate(Solution * solution) { - XReal * vars = new XReal(solution); + XReal * vars = snew XReal(solution); - vector * x = new vector(numberOfVariables_) ; - vector * y = new vector(numberOfObjectives_); + vector * x = snew vector(numberOfVariables_) ; + vector * y = snew vector(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F3.cpp b/src/problems/LZ09/LZ09_F3.cpp index d922f7d..eb32679 100644 --- a/src/problems/LZ09/LZ09_F3.cpp +++ b/src/problems/LZ09/LZ09_F3.cpp @@ -30,13 +30,13 @@ LZ09_F3::LZ09_F3(string solutionType, int ptype, int dtype, int ltype) numberOfConstraints_= 0; problemName_ = "LZ09_F3"; - LZ09_ = new LZ09(numberOfVariables_, + LZ09_ = snew LZ09(numberOfVariables_, numberOfObjectives_, ptype, dtype, ltype) ; - lowerLimit_ = new double[numberOfVariables_]; + lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { cout << "LZ09_F3::LZ09_F3: Error reserving memory for storing the " @@ -44,7 +44,7 @@ LZ09_F3::LZ09_F3(string solutionType, int ptype, int dtype, int ltype) exit(-1); } - upperLimit_ = new double[numberOfVariables_]; + upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { cout << "LZ09_F3::LZ09_F3: Error reserving memory for storing the " @@ -61,21 +61,21 @@ LZ09_F3::LZ09_F3(string solutionType, int ptype, int dtype, int ltype) } if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; + solutionType_ = snew BinaryRealSolutionType(this) ; else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; + solutionType_ = snew RealSolutionType(this) ; } else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; + solutionType_ = snew ArrayRealSolutionType(this) ; else { cout << "LZ09_F3::LZ09_F3: solution type " << solutionType << " invalid" << endl; exit(-1) ; } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; + fx_ = snew double[numberOfObjectives_] ; + x_ = snew double[numberOfVariables_]; } // LZ09_F3::LZ09_F3 /** @@ -91,10 +91,10 @@ LZ09_F3::~LZ09_F3 () void LZ09_F3::evaluate(Solution * solution) { - XReal * vars = new XReal(solution); + XReal * vars = snew XReal(solution); - vector * x = new vector(numberOfVariables_) ; - vector * y = new vector(numberOfObjectives_); + vector * x = snew vector(numberOfVariables_) ; + vector * y = snew vector(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F4.cpp b/src/problems/LZ09/LZ09_F4.cpp index 2dc6f8d..37d0262 100644 --- a/src/problems/LZ09/LZ09_F4.cpp +++ b/src/problems/LZ09/LZ09_F4.cpp @@ -30,13 +30,13 @@ LZ09_F4::LZ09_F4(string solutionType, int ptype, int dtype, int ltype) numberOfConstraints_= 0; problemName_ = "LZ09_F4"; - LZ09_ = new LZ09(numberOfVariables_, + LZ09_ = snew LZ09(numberOfVariables_, numberOfObjectives_, ptype, dtype, ltype) ; - lowerLimit_ = new double[numberOfVariables_]; + lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { cout << "LZ09_F4::LZ09_F4: Error reserving memory for storing the " @@ -44,7 +44,7 @@ LZ09_F4::LZ09_F4(string solutionType, int ptype, int dtype, int ltype) exit(-1); } - upperLimit_ = new double[numberOfVariables_]; + upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { cout << "LZ09_F4::LZ09_F4: Error reserving memory for storing the " @@ -61,21 +61,21 @@ LZ09_F4::LZ09_F4(string solutionType, int ptype, int dtype, int ltype) } if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; + solutionType_ = snew BinaryRealSolutionType(this) ; else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; + solutionType_ = snew RealSolutionType(this) ; } else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; + solutionType_ = snew ArrayRealSolutionType(this) ; else { cout << "LZ09_F4::LZ09_F4: solution type " << solutionType << " invalid" << endl; exit(-1) ; } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; + fx_ = snew double[numberOfObjectives_] ; + x_ = snew double[numberOfVariables_]; } // LZ09_F4::LZ09_F4 /** @@ -91,10 +91,10 @@ LZ09_F4::~LZ09_F4 () void LZ09_F4::evaluate(Solution * solution) { - XReal * vars = new XReal(solution); + XReal * vars = snew XReal(solution); - vector * x = new vector(numberOfVariables_) ; - vector * y = new vector(numberOfObjectives_); + vector * x = snew vector(numberOfVariables_) ; + vector * y = snew vector(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F5.cpp b/src/problems/LZ09/LZ09_F5.cpp index 9091f51..299271d 100644 --- a/src/problems/LZ09/LZ09_F5.cpp +++ b/src/problems/LZ09/LZ09_F5.cpp @@ -30,13 +30,13 @@ LZ09_F5::LZ09_F5(string solutionType, int ptype, int dtype, int ltype) numberOfConstraints_= 0; problemName_ = "LZ09_F5"; - LZ09_ = new LZ09(numberOfVariables_, + LZ09_ = snew LZ09(numberOfVariables_, numberOfObjectives_, ptype, dtype, ltype) ; - lowerLimit_ = new double[numberOfVariables_]; + lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { cout << "LZ09_F5::LZ09_F5: Error reserving memory for storing the " @@ -44,7 +44,7 @@ LZ09_F5::LZ09_F5(string solutionType, int ptype, int dtype, int ltype) exit(-1); } - upperLimit_ = new double[numberOfVariables_]; + upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { cout << "LZ09_F5::LZ09_F5: Error reserving memory for storing the " @@ -61,21 +61,21 @@ LZ09_F5::LZ09_F5(string solutionType, int ptype, int dtype, int ltype) } if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; + solutionType_ = snew BinaryRealSolutionType(this) ; else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; + solutionType_ = snew RealSolutionType(this) ; } else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; + solutionType_ = snew ArrayRealSolutionType(this) ; else { cout << "LZ09_F5::LZ09_F5: solution type " << solutionType << " invalid" << endl; exit(-1) ; } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; + fx_ = snew double[numberOfObjectives_] ; + x_ = snew double[numberOfVariables_]; } // LZ09_F5::LZ09_F5 /** @@ -91,10 +91,10 @@ LZ09_F5::~LZ09_F5 () void LZ09_F5::evaluate(Solution * solution) { - XReal * vars = new XReal(solution); + XReal * vars = snew XReal(solution); - vector * x = new vector(numberOfVariables_) ; - vector * y = new vector(numberOfObjectives_); + vector * x = snew vector(numberOfVariables_) ; + vector * y = snew vector(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F6.cpp b/src/problems/LZ09/LZ09_F6.cpp index 1da2db6..096dbcf 100644 --- a/src/problems/LZ09/LZ09_F6.cpp +++ b/src/problems/LZ09/LZ09_F6.cpp @@ -30,13 +30,13 @@ LZ09_F6::LZ09_F6(string solutionType, int ptype, int dtype, int ltype) numberOfConstraints_= 0; problemName_ = "LZ09_F6"; - LZ09_ = new LZ09(numberOfVariables_, + LZ09_ = snew LZ09(numberOfVariables_, numberOfObjectives_, ptype, dtype, ltype) ; - lowerLimit_ = new double[numberOfVariables_]; + lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { cout << "LZ09_F6::LZ09_F6: Error reserving memory for storing the " @@ -44,7 +44,7 @@ LZ09_F6::LZ09_F6(string solutionType, int ptype, int dtype, int ltype) exit(-1); } - upperLimit_ = new double[numberOfVariables_]; + upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { cout << "LZ09_F6::LZ09_F6: Error reserving memory for storing the " @@ -61,21 +61,21 @@ LZ09_F6::LZ09_F6(string solutionType, int ptype, int dtype, int ltype) } if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; + solutionType_ = snew BinaryRealSolutionType(this) ; else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; + solutionType_ = snew RealSolutionType(this) ; } else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; + solutionType_ = snew ArrayRealSolutionType(this) ; else { cout << "LZ09_F6::LZ09_F6: solution type " << solutionType << " invalid" << endl; exit(-1) ; } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; + fx_ = snew double[numberOfObjectives_] ; + x_ = snew double[numberOfVariables_]; } // LZ09_F6::LZ09_F6 /** @@ -91,10 +91,10 @@ LZ09_F6::~LZ09_F6 () void LZ09_F6::evaluate(Solution * solution) { - XReal * vars = new XReal(solution); + XReal * vars = snew XReal(solution); - vector * x = new vector(numberOfVariables_) ; - vector * y = new vector(numberOfObjectives_); + vector * x = snew vector(numberOfVariables_) ; + vector * y = snew vector(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F7.cpp b/src/problems/LZ09/LZ09_F7.cpp index b339c7c..332423e 100644 --- a/src/problems/LZ09/LZ09_F7.cpp +++ b/src/problems/LZ09/LZ09_F7.cpp @@ -30,13 +30,13 @@ LZ09_F7::LZ09_F7(string solutionType, int ptype, int dtype, int ltype) numberOfConstraints_= 0; problemName_ = "LZ09_F7"; - LZ09_ = new LZ09(numberOfVariables_, + LZ09_ = snew LZ09(numberOfVariables_, numberOfObjectives_, ptype, dtype, ltype) ; - lowerLimit_ = new double[numberOfVariables_]; + lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { cout << "LZ09_F7::LZ09_F7: Error reserving memory for storing the " @@ -44,7 +44,7 @@ LZ09_F7::LZ09_F7(string solutionType, int ptype, int dtype, int ltype) exit(-1); } - upperLimit_ = new double[numberOfVariables_]; + upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { cout << "LZ09_F7::LZ09_F7: Error reserving memory for storing the " @@ -61,21 +61,21 @@ LZ09_F7::LZ09_F7(string solutionType, int ptype, int dtype, int ltype) } if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; + solutionType_ = snew BinaryRealSolutionType(this) ; else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; + solutionType_ = snew RealSolutionType(this) ; } else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; + solutionType_ = snew ArrayRealSolutionType(this) ; else { cout << "LZ09_F7::LZ09_F7: solution type " << solutionType << " invalid" << endl; exit(-1) ; } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; + fx_ = snew double[numberOfObjectives_] ; + x_ = snew double[numberOfVariables_]; } // LZ09_F7::LZ09_F7 /** @@ -91,10 +91,10 @@ LZ09_F7::~LZ09_F7 () void LZ09_F7::evaluate(Solution * solution) { - XReal * vars = new XReal(solution); + XReal * vars = snew XReal(solution); - vector * x = new vector(numberOfVariables_) ; - vector * y = new vector(numberOfObjectives_); + vector * x = snew vector(numberOfVariables_) ; + vector * y = snew vector(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F8.cpp b/src/problems/LZ09/LZ09_F8.cpp index c9e8641..5744daf 100644 --- a/src/problems/LZ09/LZ09_F8.cpp +++ b/src/problems/LZ09/LZ09_F8.cpp @@ -30,13 +30,13 @@ LZ09_F8::LZ09_F8(string solutionType, int ptype, int dtype, int ltype) numberOfConstraints_= 0; problemName_ = "LZ09_F8"; - LZ09_ = new LZ09(numberOfVariables_, + LZ09_ = snew LZ09(numberOfVariables_, numberOfObjectives_, ptype, dtype, ltype) ; - lowerLimit_ = new double[numberOfVariables_]; + lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { cout << "LZ09_F8::LZ09_F8: Error reserving memory for storing the " @@ -44,7 +44,7 @@ LZ09_F8::LZ09_F8(string solutionType, int ptype, int dtype, int ltype) exit(-1); } - upperLimit_ = new double[numberOfVariables_]; + upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { cout << "LZ09_F8::LZ09_F8: Error reserving memory for storing the " @@ -61,21 +61,21 @@ LZ09_F8::LZ09_F8(string solutionType, int ptype, int dtype, int ltype) } if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; + solutionType_ = snew BinaryRealSolutionType(this) ; else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; + solutionType_ = snew RealSolutionType(this) ; } else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; + solutionType_ = snew ArrayRealSolutionType(this) ; else { cout << "LZ09_F8::LZ09_F8: solution type " << solutionType << " invalid" << endl; exit(-1) ; } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; + fx_ = snew double[numberOfObjectives_] ; + x_ = snew double[numberOfVariables_]; } // LZ09_F8::LZ09_F8 /** @@ -91,10 +91,10 @@ LZ09_F8::~LZ09_F8 () void LZ09_F8::evaluate(Solution * solution) { - XReal * vars = new XReal(solution); + XReal * vars = snew XReal(solution); - vector * x = new vector(numberOfVariables_) ; - vector * y = new vector(numberOfObjectives_); + vector * x = snew vector(numberOfVariables_) ; + vector * y = snew vector(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F9.cpp b/src/problems/LZ09/LZ09_F9.cpp index 7e4c84e..52f3982 100644 --- a/src/problems/LZ09/LZ09_F9.cpp +++ b/src/problems/LZ09/LZ09_F9.cpp @@ -30,13 +30,13 @@ LZ09_F9::LZ09_F9(string solutionType, int ptype, int dtype, int ltype) numberOfConstraints_= 0; problemName_ = "LZ09_F9"; - LZ09_ = new LZ09(numberOfVariables_, + LZ09_ = snew LZ09(numberOfVariables_, numberOfObjectives_, ptype, dtype, ltype) ; - lowerLimit_ = new double[numberOfVariables_]; + lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { cout << "LZ09_F9::LZ09_F9: Error reserving memory for storing the " @@ -44,7 +44,7 @@ LZ09_F9::LZ09_F9(string solutionType, int ptype, int dtype, int ltype) exit(-1); } - upperLimit_ = new double[numberOfVariables_]; + upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { cout << "LZ09_F9::LZ09_F9: Error reserving memory for storing the " @@ -61,21 +61,21 @@ LZ09_F9::LZ09_F9(string solutionType, int ptype, int dtype, int ltype) } if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; + solutionType_ = snew BinaryRealSolutionType(this) ; else if (solutionType.compare("Real") == 0) { - solutionType_ = new RealSolutionType(this) ; + solutionType_ = snew RealSolutionType(this) ; } else if (solutionType.compare("ArrayReal") == 0) - solutionType_ = new ArrayRealSolutionType(this) ; + solutionType_ = snew ArrayRealSolutionType(this) ; else { cout << "LZ09_F9::LZ09_F9: solution type " << solutionType << " invalid" << endl; exit(-1) ; } - fx_ = new double[numberOfObjectives_] ; - x_ = new double[numberOfVariables_]; + fx_ = snew double[numberOfObjectives_] ; + x_ = snew double[numberOfVariables_]; } // LZ09_F9::LZ09_F9 /** @@ -91,10 +91,10 @@ LZ09_F9::~LZ09_F9 () void LZ09_F9::evaluate(Solution * solution) { - XReal * vars = new XReal(solution); + XReal * vars = snew XReal(solution); - vector * x = new vector(numberOfVariables_) ; - vector * y = new vector(numberOfObjectives_); + vector * x = snew vector(numberOfVariables_) ; + vector * y = snew vector(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/Schaffer.cpp b/src/problems/Schaffer.cpp index 9d4d9f5..bb9690f 100644 --- a/src/problems/Schaffer.cpp +++ b/src/problems/Schaffer.cpp @@ -32,14 +32,14 @@ Schaffer::Schaffer(string solutionType) numberOfObjectives_ = 2; numberOfConstraints_ = 0; - lowerLimit_ = new double[numberOfVariables_]; + lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { cout << "Schaffer::Schaffer. Error reserving memory for storing the array of lower limits" << endl; exit(-1) ; } - upperLimit_ = new double[numberOfVariables_]; + upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { cout << "Schaffer::Schaffer. Error reserving memory for storing the array of upper limits" << endl; @@ -79,7 +79,7 @@ void Schaffer::evaluate(Solution *solution) double *fx; Variable **variables = solution->getDecisionVariables(); - fx = new double[numberOfObjectives_]; + fx = snew double[numberOfObjectives_]; if (fx == nullptr) { cout << "Schaffer::evaluate: Error reserving memory while evaluating the problem" << endl; diff --git a/src/problems/Srinivas.cpp b/src/problems/Srinivas.cpp index 3098c9f..51dde68 100644 --- a/src/problems/Srinivas.cpp +++ b/src/problems/Srinivas.cpp @@ -33,14 +33,14 @@ Srinivas::Srinivas(string solutionType) numberOfConstraints_ = 2; problemName_ = "Srinivas"; - lowerLimit_ = new double[numberOfVariables_]; + lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { cout << "Srinivas::Srinivas. Error reserving memory for storing the array of lower limits" << endl; exit(-1) ; } - upperLimit_ = new double[numberOfVariables_]; + upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { cout << "Srinivas::Srinivas. Error reserving memory for storing the array of upper limits" << endl; @@ -89,14 +89,14 @@ void Srinivas::evaluate(Solution *solution) Variable **variables = solution->getDecisionVariables(); - double * fx = new double[numberOfObjectives_]; + double * fx = snew double[numberOfObjectives_]; if (fx == nullptr) { cout << "Srinivas::evaluate: Error reserving memory while evaluating the problem" << endl; exit(-1); } - double * x = new double[numberOfVariables_]; + double * x = snew double[numberOfVariables_]; if (x == nullptr) { cout << "Srinivas::evaluate: Error reserving memory for the variable values array" << endl; @@ -124,7 +124,7 @@ void Srinivas::evaluate(Solution *solution) void Srinivas::evaluateConstraints(Solution *solution) { - double * constraint = new double[this->getNumberOfConstraints()]; + double * constraint = snew double[this->getNumberOfConstraints()]; double x1 = solution->getDecisionVariables()[0]->getValue(); double x2 = solution->getDecisionVariables()[1]->getValue(); diff --git a/src/problems/Tanaka.cpp b/src/problems/Tanaka.cpp index f9e80f4..5407dda 100644 --- a/src/problems/Tanaka.cpp +++ b/src/problems/Tanaka.cpp @@ -35,14 +35,14 @@ Tanaka::Tanaka(string solutionType) numberOfConstraints_ = 2; problemName_ = "Tanaka"; - lowerLimit_ = new double[numberOfVariables_]; + lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { cout << "Tanaka::Tanaka. Error reserving memory for storing the array of lower limits" << endl; exit(-1) ; } - upperLimit_ = new double[numberOfVariables_]; + upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { cout << "Tanaka::Tanaka. Error reserving memory for storing the array of upper limits" << endl; @@ -91,7 +91,7 @@ void Tanaka::evaluate(Solution *solution) Variable **variables = solution->getDecisionVariables(); - double * fx = new double[numberOfObjectives_]; + double * fx = snew double[numberOfObjectives_]; if (fx == nullptr) { cout << "Tanaka::evaluate: Error reserving memory while evaluating the problem" << endl; @@ -115,7 +115,7 @@ void Tanaka::evaluate(Solution *solution) void Tanaka::evaluateConstraints(Solution *solution) { - double * constraint = new double[this->getNumberOfConstraints()]; + double * constraint = snew double[this->getNumberOfConstraints()]; double x1 = solution->getDecisionVariables()[0]->getValue(); double x2 = solution->getDecisionVariables()[1]->getValue(); diff --git a/src/problems/ZDT/ZDT1.cpp b/src/problems/ZDT/ZDT1.cpp index e3fc233..392c280 100644 --- a/src/problems/ZDT/ZDT1.cpp +++ b/src/problems/ZDT/ZDT1.cpp @@ -27,14 +27,14 @@ ZDT1::ZDT1(string solutionType, int numberOfVariables) numberOfConstraints_ = 0; problemName_ = "ZDT1"; - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; @@ -61,7 +61,7 @@ ZDT1::ZDT1(string solutionType, int numberOfVariables) cout << "Error: solution type " << solutionType << " invalid" << endl; exit(-1) ; } - fx_ = new double[numberOfObjectives_] ; + fx_ = snew double[numberOfObjectives_] ; } ZDT1::~ZDT1() diff --git a/src/problems/ZDT/ZDT2.cpp b/src/problems/ZDT/ZDT2.cpp index c8d9f9c..b22fcdf 100644 --- a/src/problems/ZDT/ZDT2.cpp +++ b/src/problems/ZDT/ZDT2.cpp @@ -27,14 +27,14 @@ ZDT2::ZDT2(string solutionType, int numberOfVariables) numberOfConstraints_ = 0; problemName_ = "ZDT2"; - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; @@ -61,7 +61,7 @@ ZDT2::ZDT2(string solutionType, int numberOfVariables) cout << "Error: solution type " << solutionType << " invalid" << endl; exit(-1) ; } - fx_ = new double[numberOfObjectives_] ; + fx_ = snew double[numberOfObjectives_] ; } diff --git a/src/problems/ZDT/ZDT3.cpp b/src/problems/ZDT/ZDT3.cpp index 40014d2..53a6316 100644 --- a/src/problems/ZDT/ZDT3.cpp +++ b/src/problems/ZDT/ZDT3.cpp @@ -29,14 +29,14 @@ ZDT3::ZDT3(string solutionType, int numberOfVariables) numberOfConstraints_ = 0; problemName_ = "ZDT3"; - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; @@ -63,7 +63,7 @@ ZDT3::ZDT3(string solutionType, int numberOfVariables) cout << "Error: solution type " << solutionType << " invalid" << endl; exit(-1) ; } - fx_ = new double[numberOfObjectives_] ; + fx_ = snew double[numberOfObjectives_] ; } diff --git a/src/problems/ZDT/ZDT4.cpp b/src/problems/ZDT/ZDT4.cpp index a453425..9f1e177 100644 --- a/src/problems/ZDT/ZDT4.cpp +++ b/src/problems/ZDT/ZDT4.cpp @@ -29,14 +29,14 @@ ZDT4::ZDT4(string solutionType, int numberOfVariables) numberOfConstraints_ = 0; problemName_ = "ZDT4"; - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; @@ -65,7 +65,7 @@ ZDT4::ZDT4(string solutionType, int numberOfVariables) cout << "Error: solution type " << solutionType << " invalid" << endl; exit(-1) ; } - fx_ = new double[numberOfObjectives_] ; + fx_ = snew double[numberOfObjectives_] ; } @@ -84,7 +84,7 @@ ZDT4::~ZDT4() void ZDT4::evaluate(Solution *solution) { XReal * x = new XReal(solution); - double * fx = new double[numberOfObjectives_] ; + double * fx = snew double[numberOfObjectives_] ; fx_[0] = x->getValue(0) ; double g = evalG(x) ; diff --git a/src/problems/ZDT/ZDT5.cpp b/src/problems/ZDT/ZDT5.cpp index 16cc6f3..0d6e35d 100644 --- a/src/problems/ZDT/ZDT5.cpp +++ b/src/problems/ZDT/ZDT5.cpp @@ -30,7 +30,7 @@ ZDT5::ZDT5(string solutionType, int numberOfVariables) cout << "Problem: " << problemName_ << endl ; - length_ = new int[numberOfVariables_]; + length_ = snew int[numberOfVariables_]; length_[0] = 30; for (int var = 1; var < numberOfVariables_; var++) { @@ -44,7 +44,7 @@ ZDT5::ZDT5(string solutionType, int numberOfVariables) cout << "Error: solution type " << solutionType << " invalid" << endl; exit(-1) ; } - fx_ = new double[numberOfObjectives_] ; + fx_ = snew double[numberOfObjectives_] ; } // ZDT5::ZDT5 ZDT5::~ZDT5() diff --git a/src/problems/ZDT/ZDT6.cpp b/src/problems/ZDT/ZDT6.cpp index 4b0576c..f76bef2 100644 --- a/src/problems/ZDT/ZDT6.cpp +++ b/src/problems/ZDT/ZDT6.cpp @@ -29,14 +29,14 @@ ZDT6::ZDT6(string solutionType, int numberOfVariables) numberOfConstraints_ = 0; problemName_ = "ZDT6"; - lowerLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; exit(-1); } - upperLimit_ = new double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { cout << "Impossible to reserve memory for storing the variable lower limits" << endl; @@ -63,7 +63,7 @@ ZDT6::ZDT6(string solutionType, int numberOfVariables) cout << "Error: solution type " << solutionType << " invalid" << endl; exit(-1) ; } - fx_ = new double[numberOfObjectives_] ; + fx_ = snew double[numberOfObjectives_] ; } diff --git a/src/problems/singleObjective/CEC2005Problem.cpp b/src/problems/singleObjective/CEC2005Problem.cpp index a53af21..d46c7bc 100644 --- a/src/problems/singleObjective/CEC2005Problem.cpp +++ b/src/problems/singleObjective/CEC2005Problem.cpp @@ -37,15 +37,15 @@ CEC2005Problem::CEC2005Problem(string solutionType, int problemID, int numberOfV numberOfObjectives_ = 1; numberOfConstraints_ = 0; - Benchmark * cec2005ProblemFactory = new Benchmark() ; + Benchmark * cec2005ProblemFactory = snew Benchmark() ; testFunction_ = cec2005ProblemFactory->testFunctionFactory(problemID, numberOfVariables) ; delete cec2005ProblemFactory; problemName_ = "CEC2005: " + testFunction_->name(); - upperLimit_ = new double[numberOfVariables_]; - lowerLimit_ = new double[numberOfVariables_]; + upperLimit_ = snew double[numberOfVariables_]; + lowerLimit_ = snew double[numberOfVariables_]; double ulimit = 0 ; double llimit = 0 ; @@ -107,9 +107,9 @@ CEC2005Problem::CEC2005Problem(string solutionType, int problemID, int numberOfV } // for if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; + solutionType_ = snew BinaryRealSolutionType(this) ; else if (solutionType.compare("Real") == 0) - solutionType_ = new RealSolutionType(this) ; + solutionType_ = snew RealSolutionType(this) ; else { cout << "Error: solution type " << solutionType << " invalid" << endl; @@ -138,7 +138,7 @@ CEC2005Problem::~CEC2005Problem() void CEC2005Problem::evaluate(Solution *solution) { Variable ** decisionVariables = solution->getDecisionVariables(); - double * x = new double[numberOfVariables_] ; + double * x = snew double[numberOfVariables_] ; for (int i = 0 ; i < numberOfVariables_; i++) { diff --git a/src/problems/singleObjective/Griewank.cpp b/src/problems/singleObjective/Griewank.cpp index 1461ab1..9f87895 100644 --- a/src/problems/singleObjective/Griewank.cpp +++ b/src/problems/singleObjective/Griewank.cpp @@ -35,14 +35,14 @@ Griewank::Griewank(string solutionType, int numberOfVariables) numberOfConstraints_ = 0; problemName_ = "Griewank"; - lowerLimit_ = new double[numberOfVariables_]; + lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { cout << "Griewank::Griewank. Error reserving memory for storing the array of lower limits" << endl; exit(-1) ; } // if - upperLimit_ = new double[numberOfVariables_]; + upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { cout << "Griewank::Griewank. Error reserving memory for storing the array of upper limits" << endl; @@ -56,9 +56,9 @@ Griewank::Griewank(string solutionType, int numberOfVariables) } // for if (solutionType.compare("BinaryReal") == 0) - solutionType_ = new BinaryRealSolutionType(this) ; + solutionType_ = snew BinaryRealSolutionType(this) ; else if (solutionType.compare("Real") == 0) - solutionType_ = new RealSolutionType(this) ; + solutionType_ = snew RealSolutionType(this) ; else { cout << "Error: solution type " << solutionType << " invalid" << endl; diff --git a/src/problems/singleObjective/OneMax.cpp b/src/problems/singleObjective/OneMax.cpp index da04b82..39b01b0 100644 --- a/src/problems/singleObjective/OneMax.cpp +++ b/src/problems/singleObjective/OneMax.cpp @@ -31,7 +31,7 @@ OneMax::OneMax(int numberOfBits, int numberOfStrings) problemName_ = "OneMax"; solutionType_ = new BinarySolutionType(this) ; - length_ = new int[numberOfVariables_]; + length_ = snew int[numberOfVariables_]; for (int i = 0; i < numberOfVariables_; i++) length_ [i] = numberOfBits ; } // OneMax diff --git a/src/problems/singleObjective/Rastrigin.cpp b/src/problems/singleObjective/Rastrigin.cpp index d07f86f..451057f 100644 --- a/src/problems/singleObjective/Rastrigin.cpp +++ b/src/problems/singleObjective/Rastrigin.cpp @@ -36,14 +36,14 @@ Rastrigin::Rastrigin(string solutionType, int numberOfVariables) numberOfConstraints_ = 0; problemName_ = "Rastrigin"; - lowerLimit_ = new double[numberOfVariables_]; + lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { cout << "Rastrigin::Rastrigin. Error reserving memory for storing the array of lower limits" << endl; exit(-1) ; } - upperLimit_ = new double[numberOfVariables_]; + upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { cout << "Rastrigin::Rastrigin. Error reserving memory for storing the array of upper limits" << endl; @@ -82,14 +82,14 @@ void Rastrigin::evaluate(Solution *solution) //double x [numberOfVariables_]; Variable **variables = solution->getDecisionVariables(); - double * fx = new double[numberOfObjectives_]; //(double *)malloc(sizeof(double) * numberOfObjectives_); + double * fx = snew double[numberOfObjectives_]; //(double *)malloc(sizeof(double) * numberOfObjectives_); if (fx == nullptr) { cout << "Rastrigin::evaluate: Error reserving memory while evaluating the problem" << endl; exit(-1); } - double * x = new double[numberOfVariables_]; + double * x = snew double[numberOfVariables_]; if (x == nullptr) { cout << "Rastrigin::evaluate: Error reserving memory for the variable values array" << endl; diff --git a/src/problems/singleObjective/Rosenbrock.cpp b/src/problems/singleObjective/Rosenbrock.cpp index 5b9125d..66338bf 100644 --- a/src/problems/singleObjective/Rosenbrock.cpp +++ b/src/problems/singleObjective/Rosenbrock.cpp @@ -34,14 +34,14 @@ Rosenbrock::Rosenbrock(string solutionType, int numberOfVariables) numberOfConstraints_ = 0; problemName_ = "Rosenbrock"; - lowerLimit_ = new double[numberOfVariables_]; + lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { cout << "Rosenbrock::Rosenbrock. Error reserving memory for storing the array of lower limits" << endl; exit(-1) ; } - upperLimit_ = new double[numberOfVariables_]; + upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { cout << "Rosenbrock::Rosenbrock. Error reserving memory for storing the array of upper limits" << endl; @@ -81,14 +81,14 @@ void Rosenbrock::evaluate(Solution *solution) //double x [numberOfVariables_]; Variable **variables = solution->getDecisionVariables(); - double * fx = new double[numberOfObjectives_]; //(double *)malloc(sizeof(double) * numberOfObjectives_); + double * fx = snew double[numberOfObjectives_]; //(double *)malloc(sizeof(double) * numberOfObjectives_); if (fx == nullptr) { cout << "Rosenbrock::evaluate: Error reserving memory while evaluating the problem" << endl; exit(-1); } - double * x = new double[numberOfVariables_]; + double * x = snew double[numberOfVariables_]; if (x == nullptr) { cout << "Rosenbrock::evaluate: Error reserving memory for the variable values array" << endl; diff --git a/src/problems/singleObjective/Sphere.cpp b/src/problems/singleObjective/Sphere.cpp index a4fc8e7..798e968 100644 --- a/src/problems/singleObjective/Sphere.cpp +++ b/src/problems/singleObjective/Sphere.cpp @@ -34,14 +34,14 @@ Sphere::Sphere(string solutionType, int numberOfVariables) numberOfConstraints_ = 0; problemName_ = "Sphere"; - lowerLimit_ = new double[numberOfVariables_]; + lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { cout << "Sphere::Sphere. Error reserving memory for storing the array of lower limits" << endl; exit(-1) ; } - upperLimit_ = new double[numberOfVariables_]; + upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { cout << "Sphere::Sphere. Error reserving memory for storing the array of upper limits" << endl; @@ -81,14 +81,14 @@ void Sphere::evaluate(Solution *solution) //double x [numberOfVariables_]; Variable **variables = solution->getDecisionVariables(); - double * fx = new double[numberOfObjectives_]; //(double *)malloc(sizeof(double) * numberOfObjectives_); + double * fx = snew double[numberOfObjectives_]; //(double *)malloc(sizeof(double) * numberOfObjectives_); if (fx == nullptr) { cout << "Sphere::evaluate: Error reserving memory while evaluating the problem" << endl; exit(-1); } - double * x = new double[numberOfVariables_]; + double * x = snew double[numberOfVariables_]; if (x == nullptr) { cout << "Sphere::evaluate: Error reserving memory for the variable values array" << endl; diff --git a/src/problems/singleObjective/cec2005Competition/Benchmark.cpp b/src/problems/singleObjective/cec2005Competition/Benchmark.cpp index 331f6b6..539948d 100644 --- a/src/problems/singleObjective/cec2005Competition/Benchmark.cpp +++ b/src/problems/singleObjective/cec2005Competition/Benchmark.cpp @@ -44,7 +44,7 @@ Benchmark::Benchmark() : Benchmark(DEFAULT_FILE_BIAS) {} */ Benchmark::Benchmark(string file_bias) { - m_biases = new double[NUM_TEST_FUNC]; + m_biases = snew double[NUM_TEST_FUNC]; loadRowVectorFromFile(file_bias, NUM_TEST_FUNC, m_biases); } @@ -71,79 +71,79 @@ TestFunc * Benchmark::testFunctionFactory(int func_num, int dimension) switch (func_num) { case 1: - return new F01ShiftedSphere(dimension, m_biases[func_num-1]); + return snew F01ShiftedSphere(dimension, m_biases[func_num-1]); break; case 2: - return new F02ShiftedSchwefel(dimension, m_biases[func_num-1]); + return snew F02ShiftedSchwefel(dimension, m_biases[func_num-1]); break; case 3: - return new F03ShiftedRotatedHighCondElliptic(dimension, m_biases[func_num-1]); + return snew F03ShiftedRotatedHighCondElliptic(dimension, m_biases[func_num-1]); break; case 4: - return new F04ShiftedSchwefelNoise(dimension, m_biases[func_num-1]); + return snew F04ShiftedSchwefelNoise(dimension, m_biases[func_num-1]); break; case 5: - return new F05SchwefelGlobalOptBound(dimension, m_biases[func_num-1]); + return snew F05SchwefelGlobalOptBound(dimension, m_biases[func_num-1]); break; case 6: - return new F06ShiftedRosenbrock(dimension, m_biases[func_num-1]); + return snew F06ShiftedRosenbrock(dimension, m_biases[func_num-1]); break; case 7: - return new F07ShiftedRotatedGriewank(dimension, m_biases[func_num-1]); + return snew F07ShiftedRotatedGriewank(dimension, m_biases[func_num-1]); break; case 8: - return new F08ShiftedRotatedAckleyGlobalOptBound(dimension, m_biases[func_num-1]); + return snew F08ShiftedRotatedAckleyGlobalOptBound(dimension, m_biases[func_num-1]); break; case 9: - return new F09ShiftedRastrigin(dimension, m_biases[func_num-1]); + return snew F09ShiftedRastrigin(dimension, m_biases[func_num-1]); break; case 10: - return new F10ShiftedRotatedRastrigin(dimension, m_biases[func_num-1]); + return snew F10ShiftedRotatedRastrigin(dimension, m_biases[func_num-1]); break; case 11: - return new F11ShiftedRotatedWeierstrass(dimension, m_biases[func_num-1]); + return snew F11ShiftedRotatedWeierstrass(dimension, m_biases[func_num-1]); break; case 12: - return new F12Schwefel(dimension, m_biases[func_num-1]); + return snew F12Schwefel(dimension, m_biases[func_num-1]); break; case 13: - return new F13ShiftedExpandedGriewankRosenbrock(dimension, m_biases[func_num-1]); + return snew F13ShiftedExpandedGriewankRosenbrock(dimension, m_biases[func_num-1]); break; case 14: - return new F14ShiftedRotatedExpandedScaffer(dimension, m_biases[func_num-1]); + return snew F14ShiftedRotatedExpandedScaffer(dimension, m_biases[func_num-1]); break; case 15: - return new F15HybridComposition1(dimension, m_biases[func_num-1]); + return snew F15HybridComposition1(dimension, m_biases[func_num-1]); break; case 16: - return new F16RotatedHybridComposition1(dimension, m_biases[func_num-1]); + return snew F16RotatedHybridComposition1(dimension, m_biases[func_num-1]); break; case 17: - return new F17RotatedHybridComposition1Noise(dimension, m_biases[func_num-1]); + return snew F17RotatedHybridComposition1Noise(dimension, m_biases[func_num-1]); break; case 18: - return new F18RotatedHybridComposition2(dimension, m_biases[func_num-1]); + return snew F18RotatedHybridComposition2(dimension, m_biases[func_num-1]); break; case 19: - return new F19RotatedHybridComposition2NarrowBasinGlobalOpt(dimension, m_biases[func_num-1]); + return snew F19RotatedHybridComposition2NarrowBasinGlobalOpt(dimension, m_biases[func_num-1]); break; case 20: - return new F20RotatedHybridComposition2GlobalOptBound(dimension, m_biases[func_num-1]); + return snew F20RotatedHybridComposition2GlobalOptBound(dimension, m_biases[func_num-1]); break; case 21: - return new F21RotatedHybridComposition3(dimension, m_biases[func_num-1]); + return snew F21RotatedHybridComposition3(dimension, m_biases[func_num-1]); break; case 22: - return new F22RotatedHybridComposition3HighCondNumMatrix(dimension, m_biases[func_num-1]); + return snew F22RotatedHybridComposition3HighCondNumMatrix(dimension, m_biases[func_num-1]); break; case 23: - return new F23NoncontinuousRotatedHybridComposition3(dimension, m_biases[func_num-1]); + return snew F23NoncontinuousRotatedHybridComposition3(dimension, m_biases[func_num-1]); break; case 24: - return new F24RotatedHybridComposition4(dimension, m_biases[func_num-1]); + return snew F24RotatedHybridComposition4(dimension, m_biases[func_num-1]); break; case 25: - return new F25RotatedHybridComposition4Bound(dimension, m_biases[func_num-1]); + return snew F25RotatedHybridComposition4Bound(dimension, m_biases[func_num-1]); break; default: diff --git a/src/problems/singleObjective/cec2005Competition/Benchmark.h b/src/problems/singleObjective/cec2005Competition/Benchmark.h index 182e580..49971cf 100644 --- a/src/problems/singleObjective/cec2005Competition/Benchmark.h +++ b/src/problems/singleObjective/cec2005Competition/Benchmark.h @@ -29,6 +29,7 @@ #include #include +#include "JMetalHeader.h" #include #include #include diff --git a/src/problems/singleObjective/cec2005Competition/F01ShiftedSphere.cpp b/src/problems/singleObjective/cec2005Competition/F01ShiftedSphere.cpp index 737bb5c..a4b9386 100644 --- a/src/problems/singleObjective/cec2005Competition/F01ShiftedSphere.cpp +++ b/src/problems/singleObjective/cec2005Competition/F01ShiftedSphere.cpp @@ -45,8 +45,8 @@ F01ShiftedSphere::F01ShiftedSphere(int dimension, double bias, string file_data) { // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_z = new double[m_dimension]; + m_o = snew double[m_dimension]; + m_z = snew double[m_dimension]; // Load the shifted global optimum Benchmark::loadRowVectorFromFile(file_data, m_dimension, m_o); diff --git a/src/problems/singleObjective/cec2005Competition/F02ShiftedSchwefel.cpp b/src/problems/singleObjective/cec2005Competition/F02ShiftedSchwefel.cpp index 2c56ba9..a70fb8e 100644 --- a/src/problems/singleObjective/cec2005Competition/F02ShiftedSchwefel.cpp +++ b/src/problems/singleObjective/cec2005Competition/F02ShiftedSchwefel.cpp @@ -45,8 +45,8 @@ F02ShiftedSchwefel::F02ShiftedSchwefel(int dimension, double bias, string file_d { // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_z = new double[m_dimension]; + m_o = snew double[m_dimension]; + m_z = snew double[m_dimension]; // Load the shifted global optimum Benchmark::loadRowVectorFromFile(file_data, m_dimension, m_o); diff --git a/src/problems/singleObjective/cec2005Competition/F03ShiftedRotatedHighCondElliptic.cpp b/src/problems/singleObjective/cec2005Competition/F03ShiftedRotatedHighCondElliptic.cpp index a4e762d..585c5b7 100644 --- a/src/problems/singleObjective/cec2005Competition/F03ShiftedRotatedHighCondElliptic.cpp +++ b/src/problems/singleObjective/cec2005Competition/F03ShiftedRotatedHighCondElliptic.cpp @@ -21,6 +21,7 @@ #include +#include "JMetalHeader.h" // Fixed (class) parameters const string F03ShiftedRotatedHighCondElliptic::FUNCTION_NAME = "Shifted Rotated High Conditioned Elliptic Function"; @@ -47,14 +48,14 @@ F03ShiftedRotatedHighCondElliptic::F03ShiftedRotatedHighCondElliptic(int dimensi { // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_matrix = new double*[m_dimension]; + m_o = snew double[m_dimension]; + m_matrix = snew double*[m_dimension]; for (int i=0; i +#include "JMetalHeader.h" // Fixed (class) parameters const string F05SchwefelGlobalOptBound::FUNCTION_NAME = "Schwefel's Problem 2.6 with Global Optimum on Bounds"; @@ -45,19 +46,19 @@ F05SchwefelGlobalOptBound::F05SchwefelGlobalOptBound(int dimension, double bias, { // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_A = new double*[m_dimension]; + m_o = snew double[m_dimension]; + m_A = snew double*[m_dimension]; for (int i=0; i +#include "JMetalHeader.h" // Fixed (class) parameters const string F07ShiftedRotatedGriewank::FUNCTION_NAME = "Shifted Rotated Griewank's Function without Bounds"; @@ -47,14 +48,14 @@ F07ShiftedRotatedGriewank::F07ShiftedRotatedGriewank(int dimension, double bias, { // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_matrix = new double*[m_dimension]; + m_o = snew double[m_dimension]; + m_matrix = snew double*[m_dimension]; for (int i=0; i +#include "JMetalHeader.h" // Fixed (class) parameters const string F08ShiftedRotatedAckleyGlobalOptBound::FUNCTION_NAME = "Shifted Rotated Ackley's Function with Global Optimum on Bounds"; @@ -47,14 +48,14 @@ F08ShiftedRotatedAckleyGlobalOptBound::F08ShiftedRotatedAckleyGlobalOptBound(int { // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_matrix = new double*[m_dimension]; + m_o = snew double[m_dimension]; + m_matrix = snew double*[m_dimension]; for (int i=0; i +#include "JMetalHeader.h" // Fixed (class) parameters const string F10ShiftedRotatedRastrigin::FUNCTION_NAME = "Shifted Rotated Rastrigin's Function"; @@ -47,14 +48,14 @@ F10ShiftedRotatedRastrigin::F10ShiftedRotatedRastrigin(int dimension, double bia { // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_matrix = new double*[m_dimension]; + m_o = snew double[m_dimension]; + m_matrix = snew double*[m_dimension]; for (int i=0; i +#include "JMetalHeader.h" // Fixed (class) parameters const string F11ShiftedRotatedWeierstrass::FUNCTION_NAME = "Shifted Rotated Weierstrass Function"; @@ -51,14 +52,14 @@ F11ShiftedRotatedWeierstrass::F11ShiftedRotatedWeierstrass(int dimension, double { // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_matrix = new double*[m_dimension]; + m_o = snew double[m_dimension]; + m_matrix = snew double*[m_dimension]; for (int i=0; i +#include "JMetalHeader.h" // Fixed (class) parameters const string F12Schwefel::FUNCTION_NAME = "Schwefel's Problem 2.13"; @@ -45,29 +46,29 @@ F12Schwefel::F12Schwefel(int dimension, double bias, string file_data) { // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_a = new double*[m_dimension]; + m_o = snew double[m_dimension]; + m_a = snew double*[m_dimension]; for (int i = 0; i < m_dimension; i++) { - m_a[i] = new double[m_dimension]; + m_a[i] = snew double[m_dimension]; } - m_b = new double*[m_dimension]; + m_b = snew double*[m_dimension]; for (int i = 0; i < m_dimension; i++) { - m_b[i] = new double[m_dimension]; + m_b[i] = snew double[m_dimension]; } - m_A = new double[m_dimension]; - m_B = new double[m_dimension]; + m_A = snew double[m_dimension]; + m_B = snew double[m_dimension]; // Data: // 1. a 100x100 // 2. b 100x100 // 3. alpha 1x100 - double ** m_data = new double*[100+100+1]; + double ** m_data = snew double*[100+100+1]; for (int i = 0; i < (100+100+1); i++) { - m_data[i] = new double[m_dimension]; + m_data[i] = snew double[m_dimension]; } // Load the shifted global optimum diff --git a/src/problems/singleObjective/cec2005Competition/F13ShiftedExpandedGriewankRosenbrock.cpp b/src/problems/singleObjective/cec2005Competition/F13ShiftedExpandedGriewankRosenbrock.cpp index 7c34af4..64fb886 100644 --- a/src/problems/singleObjective/cec2005Competition/F13ShiftedExpandedGriewankRosenbrock.cpp +++ b/src/problems/singleObjective/cec2005Competition/F13ShiftedExpandedGriewankRosenbrock.cpp @@ -45,8 +45,8 @@ F13ShiftedExpandedGriewankRosenbrock::F13ShiftedExpandedGriewankRosenbrock(int d { // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_z = new double[m_dimension]; + m_o = snew double[m_dimension]; + m_z = snew double[m_dimension]; // Load the shifted global optimum Benchmark::loadRowVectorFromFile(file_data, m_dimension, m_o); diff --git a/src/problems/singleObjective/cec2005Competition/F14ShiftedRotatedExpandedScaffer.cpp b/src/problems/singleObjective/cec2005Competition/F14ShiftedRotatedExpandedScaffer.cpp index af40250..cabcd4b 100644 --- a/src/problems/singleObjective/cec2005Competition/F14ShiftedRotatedExpandedScaffer.cpp +++ b/src/problems/singleObjective/cec2005Competition/F14ShiftedRotatedExpandedScaffer.cpp @@ -21,6 +21,7 @@ #include +#include "JMetalHeader.h" // Fixed (class) parameters const string F14ShiftedRotatedExpandedScaffer::FUNCTION_NAME = "Shifted Rotated Expanded Scaffer's F6 Function"; @@ -47,14 +48,14 @@ F14ShiftedRotatedExpandedScaffer::F14ShiftedRotatedExpandedScaffer(int dimension { // Note: dimension starts from 0 - m_o = new double[m_dimension]; - m_matrix = new double*[m_dimension]; + m_o = snew double[m_dimension]; + m_matrix = snew double*[m_dimension]; for (int i=0; i +#include "JMetalHeader.h" // Fixed (class) parameters const string F15HybridComposition1::FUNCTION_NAME = "Hybrid Composition Function 1"; @@ -65,22 +66,22 @@ F15HybridComposition1::F15HybridComposition1(int dimension, double bias, string { // Note: dimension starts from 0 - m_o = new double*[NUM_FUNC]; - m_M = new double**[NUM_FUNC]; + m_o = snew double*[NUM_FUNC]; + m_M = snew double**[NUM_FUNC]; - m_testPoint = new double[m_dimension]; - m_testPointM = new double[m_dimension]; - m_fmax = new double[NUM_FUNC]; + m_testPoint = snew double[m_dimension]; + m_testPointM = snew double[m_dimension]; + m_fmax = snew double[NUM_FUNC]; - m_w = new double[NUM_FUNC]; - m_z = new double*[NUM_FUNC]; - m_zM = new double*[NUM_FUNC]; + m_w = snew double[NUM_FUNC]; + m_z = snew double*[NUM_FUNC]; + m_zM = snew double*[NUM_FUNC]; for (int i=0; inum_func = NUM_FUNC; theJob->num_dim = m_dimension; theJob->C = 2000.0; diff --git a/src/problems/singleObjective/cec2005Competition/F16RotatedHybridComposition1.cpp b/src/problems/singleObjective/cec2005Competition/F16RotatedHybridComposition1.cpp index 774add3..becd332 100644 --- a/src/problems/singleObjective/cec2005Competition/F16RotatedHybridComposition1.cpp +++ b/src/problems/singleObjective/cec2005Competition/F16RotatedHybridComposition1.cpp @@ -21,6 +21,7 @@ #include +#include "JMetalHeader.h" // Fixed (class) parameters const string F16RotatedHybridComposition1::FUNCTION_NAME = "Rotated Hybrid Composition Function 1"; @@ -66,26 +67,26 @@ F16RotatedHybridComposition1::F16RotatedHybridComposition1(int dimension, double { // Note: dimension starts from 0 - m_o = new double*[NUM_FUNC]; - m_M = new double**[NUM_FUNC]; + m_o = snew double*[NUM_FUNC]; + m_M = snew double**[NUM_FUNC]; - m_testPoint = new double[m_dimension]; - m_testPointM = new double[m_dimension]; - m_fmax = new double[NUM_FUNC]; + m_testPoint = snew double[m_dimension]; + m_testPointM = snew double[m_dimension]; + m_fmax = snew double[NUM_FUNC]; - m_w = new double[NUM_FUNC]; - m_z = new double*[NUM_FUNC]; - m_zM = new double*[NUM_FUNC]; + m_w = snew double[NUM_FUNC]; + m_z = snew double*[NUM_FUNC]; + m_zM = snew double*[NUM_FUNC]; for (int i=0; inum_func = NUM_FUNC; theJob->num_dim = m_dimension; theJob->C = 2000.0; diff --git a/src/problems/singleObjective/cec2005Competition/F17RotatedHybridComposition1Noise.cpp b/src/problems/singleObjective/cec2005Competition/F17RotatedHybridComposition1Noise.cpp index f42e604..cf5e227 100644 --- a/src/problems/singleObjective/cec2005Competition/F17RotatedHybridComposition1Noise.cpp +++ b/src/problems/singleObjective/cec2005Competition/F17RotatedHybridComposition1Noise.cpp @@ -21,6 +21,7 @@ #include +#include "JMetalHeader.h" // Fixed (class) parameters const string F17RotatedHybridComposition1Noise::FUNCTION_NAME = "Rotated Hybrid Composition Function 1 with Noise in Fitness"; @@ -66,26 +67,26 @@ F17RotatedHybridComposition1Noise::F17RotatedHybridComposition1Noise(int dimensi { // Note: dimension starts from 0 - m_o = new double*[NUM_FUNC]; - m_M = new double**[NUM_FUNC]; + m_o = snew double*[NUM_FUNC]; + m_M = snew double**[NUM_FUNC]; - m_testPoint = new double[m_dimension]; - m_testPointM = new double[m_dimension]; - m_fmax = new double[NUM_FUNC]; + m_testPoint = snew double[m_dimension]; + m_testPointM = snew double[m_dimension]; + m_fmax = snew double[NUM_FUNC]; - m_w = new double[NUM_FUNC]; - m_z = new double*[NUM_FUNC]; - m_zM = new double*[NUM_FUNC]; + m_w = snew double[NUM_FUNC]; + m_z = snew double*[NUM_FUNC]; + m_zM = snew double*[NUM_FUNC]; for (int i=0; inum_func = NUM_FUNC; theJob->num_dim = m_dimension; theJob->C = 2000.0; diff --git a/src/problems/singleObjective/cec2005Competition/F18RotatedHybridComposition2.cpp b/src/problems/singleObjective/cec2005Competition/F18RotatedHybridComposition2.cpp index 994161f..4d2a1d2 100644 --- a/src/problems/singleObjective/cec2005Competition/F18RotatedHybridComposition2.cpp +++ b/src/problems/singleObjective/cec2005Competition/F18RotatedHybridComposition2.cpp @@ -21,6 +21,7 @@ #include +#include "JMetalHeader.h" // Fixed (class) parameters const string F18RotatedHybridComposition2::FUNCTION_NAME = "Rotated Hybrid Composition Function 2"; @@ -65,26 +66,26 @@ F18RotatedHybridComposition2::F18RotatedHybridComposition2(int dimension, double { // Note: dimension starts from 0 - m_o = new double*[NUM_FUNC]; - m_M = new double**[NUM_FUNC]; + m_o = snew double*[NUM_FUNC]; + m_M = snew double**[NUM_FUNC]; - m_testPoint = new double[m_dimension]; - m_testPointM = new double[m_dimension]; - m_fmax = new double[NUM_FUNC]; + m_testPoint = snew double[m_dimension]; + m_testPointM = snew double[m_dimension]; + m_fmax = snew double[NUM_FUNC]; - m_w = new double[NUM_FUNC]; - m_z = new double*[NUM_FUNC]; - m_zM = new double*[NUM_FUNC]; + m_w = snew double[NUM_FUNC]; + m_z = snew double*[NUM_FUNC]; + m_zM = snew double*[NUM_FUNC]; for (int i=0; inum_func = NUM_FUNC; theJob->num_dim = m_dimension; theJob->C = 2000.0; diff --git a/src/problems/singleObjective/cec2005Competition/F19RotatedHybridComposition2NarrowBasinGlobalOpt.cpp b/src/problems/singleObjective/cec2005Competition/F19RotatedHybridComposition2NarrowBasinGlobalOpt.cpp index 72552ad..bc8caf8 100644 --- a/src/problems/singleObjective/cec2005Competition/F19RotatedHybridComposition2NarrowBasinGlobalOpt.cpp +++ b/src/problems/singleObjective/cec2005Competition/F19RotatedHybridComposition2NarrowBasinGlobalOpt.cpp @@ -21,6 +21,7 @@ #include +#include "JMetalHeader.h" // Fixed (class) parameters const string F19RotatedHybridComposition2NarrowBasinGlobalOpt::FUNCTION_NAME = "Rotated Hybrid Composition Function 2 with narrow basin global optimum"; @@ -65,26 +66,26 @@ F19RotatedHybridComposition2NarrowBasinGlobalOpt::F19RotatedHybridComposition2Na { // Note: dimension starts from 0 - m_o = new double*[NUM_FUNC]; - m_M = new double**[NUM_FUNC]; + m_o = snew double*[NUM_FUNC]; + m_M = snew double**[NUM_FUNC]; - m_testPoint = new double[m_dimension]; - m_testPointM = new double[m_dimension]; - m_fmax = new double[NUM_FUNC]; + m_testPoint = snew double[m_dimension]; + m_testPointM = snew double[m_dimension]; + m_fmax = snew double[NUM_FUNC]; - m_w = new double[NUM_FUNC]; - m_z = new double*[NUM_FUNC]; - m_zM = new double*[NUM_FUNC]; + m_w = snew double[NUM_FUNC]; + m_z = snew double*[NUM_FUNC]; + m_zM = snew double*[NUM_FUNC]; for (int i=0; inum_func = NUM_FUNC; theJob->num_dim = m_dimension; theJob->C = 2000.0; diff --git a/src/problems/singleObjective/cec2005Competition/F20RotatedHybridComposition2GlobalOptBound.cpp b/src/problems/singleObjective/cec2005Competition/F20RotatedHybridComposition2GlobalOptBound.cpp index 6df1d68..40d4786 100644 --- a/src/problems/singleObjective/cec2005Competition/F20RotatedHybridComposition2GlobalOptBound.cpp +++ b/src/problems/singleObjective/cec2005Competition/F20RotatedHybridComposition2GlobalOptBound.cpp @@ -21,6 +21,7 @@ #include +#include "JMetalHeader.h" // Fixed (class) parameters const string F20RotatedHybridComposition2GlobalOptBound::FUNCTION_NAME = "Rotated Hybrid Composition Function 2 with Global Optimum on the Bounds"; @@ -65,26 +66,26 @@ F20RotatedHybridComposition2GlobalOptBound::F20RotatedHybridComposition2GlobalOp { // Note: dimension starts from 0 - m_o = new double*[NUM_FUNC]; - m_M = new double**[NUM_FUNC]; + m_o = snew double*[NUM_FUNC]; + m_M = snew double**[NUM_FUNC]; - m_testPoint = new double[m_dimension]; - m_testPointM = new double[m_dimension]; - m_fmax = new double[NUM_FUNC]; + m_testPoint = snew double[m_dimension]; + m_testPointM = snew double[m_dimension]; + m_fmax = snew double[NUM_FUNC]; - m_w = new double[NUM_FUNC]; - m_z = new double*[NUM_FUNC]; - m_zM = new double*[NUM_FUNC]; + m_w = snew double[NUM_FUNC]; + m_z = snew double*[NUM_FUNC]; + m_zM = snew double*[NUM_FUNC]; for (int i=0; inum_func = NUM_FUNC; theJob->num_dim = m_dimension; theJob->C = 2000.0; diff --git a/src/problems/singleObjective/cec2005Competition/F21RotatedHybridComposition3.cpp b/src/problems/singleObjective/cec2005Competition/F21RotatedHybridComposition3.cpp index 513c836..b67e030 100644 --- a/src/problems/singleObjective/cec2005Competition/F21RotatedHybridComposition3.cpp +++ b/src/problems/singleObjective/cec2005Competition/F21RotatedHybridComposition3.cpp @@ -21,6 +21,7 @@ #include +#include "JMetalHeader.h" // Fixed (class) parameters const string F21RotatedHybridComposition3::FUNCTION_NAME = "Rotated Hybrid Composition Function 3"; @@ -65,26 +66,26 @@ F21RotatedHybridComposition3::F21RotatedHybridComposition3(int dimension, double { // Note: dimension starts from 0 - m_o = new double*[NUM_FUNC]; - m_M = new double**[NUM_FUNC]; + m_o = snew double*[NUM_FUNC]; + m_M = snew double**[NUM_FUNC]; - m_testPoint = new double[m_dimension]; - m_testPointM = new double[m_dimension]; - m_fmax = new double[NUM_FUNC]; + m_testPoint = snew double[m_dimension]; + m_testPointM = snew double[m_dimension]; + m_fmax = snew double[NUM_FUNC]; - m_w = new double[NUM_FUNC]; - m_z = new double*[NUM_FUNC]; - m_zM = new double*[NUM_FUNC]; + m_w = snew double[NUM_FUNC]; + m_z = snew double*[NUM_FUNC]; + m_zM = snew double*[NUM_FUNC]; for (int i=0; inum_func = NUM_FUNC; theJob->num_dim = m_dimension; theJob->C = 2000.0; diff --git a/src/problems/singleObjective/cec2005Competition/F22RotatedHybridComposition3HighCondNumMatrix.cpp b/src/problems/singleObjective/cec2005Competition/F22RotatedHybridComposition3HighCondNumMatrix.cpp index 4dd54e6..1cfb29d 100644 --- a/src/problems/singleObjective/cec2005Competition/F22RotatedHybridComposition3HighCondNumMatrix.cpp +++ b/src/problems/singleObjective/cec2005Competition/F22RotatedHybridComposition3HighCondNumMatrix.cpp @@ -21,6 +21,7 @@ #include +#include "JMetalHeader.h" // Fixed (class) parameters const string F22RotatedHybridComposition3HighCondNumMatrix::FUNCTION_NAME = "Rotated Hybrid Composition Function 3 with High Condition Number Matrix"; @@ -65,26 +66,26 @@ F22RotatedHybridComposition3HighCondNumMatrix::F22RotatedHybridComposition3HighC { // Note: dimension starts from 0 - m_o = new double*[NUM_FUNC]; - m_M = new double**[NUM_FUNC]; + m_o = snew double*[NUM_FUNC]; + m_M = snew double**[NUM_FUNC]; - m_testPoint = new double[m_dimension]; - m_testPointM = new double[m_dimension]; - m_fmax = new double[NUM_FUNC]; + m_testPoint = snew double[m_dimension]; + m_testPointM = snew double[m_dimension]; + m_fmax = snew double[NUM_FUNC]; - m_w = new double[NUM_FUNC]; - m_z = new double*[NUM_FUNC]; - m_zM = new double*[NUM_FUNC]; + m_w = snew double[NUM_FUNC]; + m_z = snew double*[NUM_FUNC]; + m_zM = snew double*[NUM_FUNC]; for (int i=0; inum_func = NUM_FUNC; theJob->num_dim = m_dimension; theJob->C = 2000.0; diff --git a/src/problems/singleObjective/cec2005Competition/F23NoncontinuousRotatedHybridComposition3.cpp b/src/problems/singleObjective/cec2005Competition/F23NoncontinuousRotatedHybridComposition3.cpp index bc9bffb..4b8e6ff 100644 --- a/src/problems/singleObjective/cec2005Competition/F23NoncontinuousRotatedHybridComposition3.cpp +++ b/src/problems/singleObjective/cec2005Competition/F23NoncontinuousRotatedHybridComposition3.cpp @@ -21,6 +21,7 @@ #include +#include "JMetalHeader.h" // Fixed (class) parameters const string F23NoncontinuousRotatedHybridComposition3::FUNCTION_NAME = "Non-Continuous Rotated Hybrid Composition Function 3"; @@ -65,26 +66,26 @@ F23NoncontinuousRotatedHybridComposition3::F23NoncontinuousRotatedHybridComposit { // Note: dimension starts from 0 - m_o = new double*[NUM_FUNC]; - m_M = new double**[NUM_FUNC]; + m_o = snew double*[NUM_FUNC]; + m_M = snew double**[NUM_FUNC]; - m_testPoint = new double[m_dimension]; - m_testPointM = new double[m_dimension]; - m_fmax = new double[NUM_FUNC]; + m_testPoint = snew double[m_dimension]; + m_testPointM = snew double[m_dimension]; + m_fmax = snew double[NUM_FUNC]; - m_w = new double[NUM_FUNC]; - m_z = new double*[NUM_FUNC]; - m_zM = new double*[NUM_FUNC]; + m_w = snew double[NUM_FUNC]; + m_z = snew double*[NUM_FUNC]; + m_zM = snew double*[NUM_FUNC]; for (int i=0; inum_func = NUM_FUNC; theJob->num_dim = m_dimension; theJob->C = 2000.0; diff --git a/src/problems/singleObjective/cec2005Competition/F24RotatedHybridComposition4.cpp b/src/problems/singleObjective/cec2005Competition/F24RotatedHybridComposition4.cpp index 17db3ed..731f4aa 100644 --- a/src/problems/singleObjective/cec2005Competition/F24RotatedHybridComposition4.cpp +++ b/src/problems/singleObjective/cec2005Competition/F24RotatedHybridComposition4.cpp @@ -21,6 +21,7 @@ #include +#include "JMetalHeader.h" // Fixed (class) parameters const string F24RotatedHybridComposition4::FUNCTION_NAME = "Rotated Hybrid Composition Function 4"; @@ -65,26 +66,26 @@ F24RotatedHybridComposition4::F24RotatedHybridComposition4(int dimension, double { // Note: dimension starts from 0 - m_o = new double*[NUM_FUNC]; - m_M = new double**[NUM_FUNC]; + m_o = snew double*[NUM_FUNC]; + m_M = snew double**[NUM_FUNC]; - m_testPoint = new double[m_dimension]; - m_testPointM = new double[m_dimension]; - m_fmax = new double[NUM_FUNC]; + m_testPoint = snew double[m_dimension]; + m_testPointM = snew double[m_dimension]; + m_fmax = snew double[NUM_FUNC]; - m_w = new double[NUM_FUNC]; - m_z = new double*[NUM_FUNC]; - m_zM = new double*[NUM_FUNC]; + m_w = snew double[NUM_FUNC]; + m_z = snew double*[NUM_FUNC]; + m_zM = snew double*[NUM_FUNC]; for (int i=0; inum_func = NUM_FUNC; theJob->num_dim = m_dimension; theJob->C = 2000.0; diff --git a/src/problems/singleObjective/cec2005Competition/F25RotatedHybridComposition4Bound.cpp b/src/problems/singleObjective/cec2005Competition/F25RotatedHybridComposition4Bound.cpp index 9c4dc11..3285435 100644 --- a/src/problems/singleObjective/cec2005Competition/F25RotatedHybridComposition4Bound.cpp +++ b/src/problems/singleObjective/cec2005Competition/F25RotatedHybridComposition4Bound.cpp @@ -21,6 +21,7 @@ #include +#include "JMetalHeader.h" // Fixed (class) parameters const string F25RotatedHybridComposition4Bound::FUNCTION_NAME = "Rotated Hybrid Composition Function 4 without bounds"; @@ -65,26 +66,26 @@ F25RotatedHybridComposition4Bound::F25RotatedHybridComposition4Bound(int dimensi { // Note: dimension starts from 0 - m_o = new double*[NUM_FUNC]; - m_M = new double**[NUM_FUNC]; + m_o = snew double*[NUM_FUNC]; + m_M = snew double**[NUM_FUNC]; - m_testPoint = new double[m_dimension]; - m_testPointM = new double[m_dimension]; - m_fmax = new double[NUM_FUNC]; + m_testPoint = snew double[m_dimension]; + m_testPointM = snew double[m_dimension]; + m_fmax = snew double[NUM_FUNC]; - m_w = new double[NUM_FUNC]; - m_z = new double*[NUM_FUNC]; - m_zM = new double*[NUM_FUNC]; + m_w = snew double[NUM_FUNC]; + m_z = snew double*[NUM_FUNC]; + m_zM = snew double*[NUM_FUNC]; for (int i=0; inum_func = NUM_FUNC; theJob->num_dim = m_dimension; theJob->C = 2000.0; diff --git a/src/problems/singleObjective/cec2005Competition/HCJob.cpp b/src/problems/singleObjective/cec2005Competition/HCJob.cpp index 5045573..618f963 100644 --- a/src/problems/singleObjective/cec2005Competition/HCJob.cpp +++ b/src/problems/singleObjective/cec2005Competition/HCJob.cpp @@ -21,15 +21,16 @@ #include +#include "JMetalHeader.h" /** * Constructor. */ HCJob::HCJob(int numFunc) { - sigma = new double[numFunc]; - biases = new double[numFunc]; - lambda = new double[numFunc]; + sigma = snew double[numFunc]; + biases = snew double[numFunc]; + lambda = snew double[numFunc]; } // HCJob /** diff --git a/src/qualityIndicator/Epsilon.cpp b/src/qualityIndicator/Epsilon.cpp index 2b7b99a..367156b 100644 --- a/src/qualityIndicator/Epsilon.cpp +++ b/src/qualityIndicator/Epsilon.cpp @@ -28,7 +28,7 @@ */ Epsilon::Epsilon() { - utils_ = new MetricsUtil(); + utils_ = snew MetricsUtil(); } // Epsilon @@ -123,7 +123,7 @@ double Epsilon::epsilon(vector > b, vector > a, void Epsilon::set_params() { int i; - obj_ = new int[dim_]; + obj_ = snew int[dim_]; for (i = 0; i < dim_; i++) { obj_[i] = 0; diff --git a/src/qualityIndicator/Fitness.cpp b/src/qualityIndicator/Fitness.cpp index 6167c6b..4ef8664 100644 --- a/src/qualityIndicator/Fitness.cpp +++ b/src/qualityIndicator/Fitness.cpp @@ -28,7 +28,7 @@ */ Fitness::Fitness() { - utils_ = new MetricsUtil(); + utils_ = snew MetricsUtil(); } // Fitness diff --git a/src/qualityIndicator/GenerationalDistance.cpp b/src/qualityIndicator/GenerationalDistance.cpp index 6bc5f89..ad25de1 100644 --- a/src/qualityIndicator/GenerationalDistance.cpp +++ b/src/qualityIndicator/GenerationalDistance.cpp @@ -33,7 +33,7 @@ const double GenerationalDistance::pow_ = 2.0; */ GenerationalDistance::GenerationalDistance() { - utils_ = new MetricsUtil(); + utils_ = snew MetricsUtil(); } // GenerationalDistance diff --git a/src/qualityIndicator/Hypervolume.cpp b/src/qualityIndicator/Hypervolume.cpp index 41dc0b0..fb567e0 100644 --- a/src/qualityIndicator/Hypervolume.cpp +++ b/src/qualityIndicator/Hypervolume.cpp @@ -27,7 +27,7 @@ */ Hypervolume::Hypervolume() { - utils_ = new MetricsUtil(); + utils_ = snew MetricsUtil(); } // Hypervolume @@ -239,10 +239,10 @@ double** Hypervolume::mergeFronts(double** front1, int sizeFront1, double** frontPtr =0; /* allocate memory */ - frontPtr =new double*[noPoints]; + frontPtr =snew double*[noPoints]; for (int y=0; y< noPoints; ++y) { - frontPtr[y] = new double[noObjectives]; + frontPtr[y] = snew double[noObjectives]; } /* copy points */ @@ -312,10 +312,10 @@ double Hypervolume::hypervolume(vector< vector > paretoFront, invertedFront = utils_->invertedFront(normalizedFront); /*Makes a copy of invertedFront in pointer of pointer format*/ - double ** invertedFront2 = new double*[invertedFront.size()]; + double ** invertedFront2 = snew double*[invertedFront.size()]; for (int i = 0; i < invertedFront.size(); i++) { - invertedFront2[i] = new double[invertedFront[i].size()]; + invertedFront2[i] = snew double[invertedFront[i].size()]; for (int j = 0; j < invertedFront[i].size(); j++) { invertedFront2[i][j] = invertedFront[i][j]; diff --git a/src/qualityIndicator/InvertedGenerationalDistance.cpp b/src/qualityIndicator/InvertedGenerationalDistance.cpp index 12a9105..717740b 100644 --- a/src/qualityIndicator/InvertedGenerationalDistance.cpp +++ b/src/qualityIndicator/InvertedGenerationalDistance.cpp @@ -33,7 +33,7 @@ const double InvertedGenerationalDistance::pow_ = 2.0; */ InvertedGenerationalDistance::InvertedGenerationalDistance() { - utils_ = new MetricsUtil(); + utils_ = snew MetricsUtil(); } // InvertedGenerationalDistance diff --git a/src/qualityIndicator/fastHypervolume/FastHypervolume.cpp b/src/qualityIndicator/fastHypervolume/FastHypervolume.cpp index e1092bd..438d2ae 100644 --- a/src/qualityIndicator/fastHypervolume/FastHypervolume.cpp +++ b/src/qualityIndicator/fastHypervolume/FastHypervolume.cpp @@ -62,7 +62,7 @@ double FastHypervolume::computeHypervolume(SolutionSet* solutionSet) if (numberOfObjectives_ == 2) { Comparator * comparator = - new ObjectiveComparator(numberOfObjectives_ - 1, true); + snew ObjectiveComparator(numberOfObjectives_ - 1, true); solutionSet->sort(comparator); delete comparator; hv = get2DHV(solutionSet); @@ -86,7 +86,7 @@ double FastHypervolume::computeHypervolume(SolutionSet* solutionSet) */ void FastHypervolume::updateReferencePoint(SolutionSet * solutionSet) { - double * maxObjectives = new double[numberOfObjectives_]; + double * maxObjectives = snew double[numberOfObjectives_]; for (int i = 0; i < numberOfObjectives_; i++) { maxObjectives[i] = 0; @@ -139,11 +139,11 @@ double FastHypervolume::get2DHV(SolutionSet * solutionSet) void FastHypervolume::computeHVContributions(SolutionSet * solutionSet) { - double * contributions = new double[solutionSet->size()]; + double * contributions = snew double[solutionSet->size()]; double solutionSetHV = 0; numberOfObjectives_ = solutionSet->get(0)->getNumberOfObjectives(); - referencePoint_ = new Solution(numberOfObjectives_); + referencePoint_ = snew Solution(numberOfObjectives_); solutionSetHV = computeHypervolume(solutionSet); diff --git a/src/qualityIndicator/fastHypervolume/FastHypervolumeArchive.cpp b/src/qualityIndicator/fastHypervolume/FastHypervolumeArchive.cpp index e69439b..ba2e9d0 100644 --- a/src/qualityIndicator/fastHypervolume/FastHypervolumeArchive.cpp +++ b/src/qualityIndicator/fastHypervolume/FastHypervolumeArchive.cpp @@ -37,14 +37,14 @@ FastHypervolumeArchive::FastHypervolumeArchive(int maxSize, int numberOfObjectiv { this->maxSize = maxSize; this->objectives = numberOfObjectives; - this->dominance = new DominanceComparator(); - this->equals = new EqualSolutions(); - this->referencePoint = new Solution(objectives) ; + this->dominance = snew DominanceComparator(); + this->equals = snew EqualSolutions(); + this->referencePoint = snew Solution(objectives) ; for (int i = 0; i < objectives; i++) { referencePoint->setObjective(i, std::numeric_limits::max()); } - crowdingDistance_ = new CrowdingComparator(); + crowdingDistance_ = snew CrowdingComparator(); } // FastHypervolumeArchive @@ -131,7 +131,7 @@ void FastHypervolumeArchive::computeHVContribution() { if (size() > 2) // The contribution can be updated { - FastHypervolume *fastHV = new FastHypervolume(); + FastHypervolume *fastHV = snew FastHypervolume(); fastHV->computeHVContributions(this); delete fastHV; } diff --git a/src/qualityIndicator/main/Epsilon_main.cpp b/src/qualityIndicator/main/Epsilon_main.cpp index 99264ab..3b3b467 100644 --- a/src/qualityIndicator/main/Epsilon_main.cpp +++ b/src/qualityIndicator/main/Epsilon_main.cpp @@ -41,7 +41,7 @@ int main(int argc, char ** argv) } //Create a new instance of the metric - Epsilon * qualityIndicator = new Epsilon(); + Epsilon * qualityIndicator = snew Epsilon(); //Read the front from the files vector< vector > solutionFront = qualityIndicator->utils_->readFront(argv[1]); diff --git a/src/qualityIndicator/main/GenerationalDistance_main.cpp b/src/qualityIndicator/main/GenerationalDistance_main.cpp index cb33d19..592f641 100644 --- a/src/qualityIndicator/main/GenerationalDistance_main.cpp +++ b/src/qualityIndicator/main/GenerationalDistance_main.cpp @@ -41,7 +41,7 @@ int main(int argc, char ** argv) } //Create a new instance of the metric - GenerationalDistance * qualityIndicator = new GenerationalDistance(); + GenerationalDistance * qualityIndicator = snew GenerationalDistance(); //Read the front from the files vector< vector > solutionFront = qualityIndicator->utils_->readFront(argv[1]); diff --git a/src/qualityIndicator/main/Hypervolume_main.cpp b/src/qualityIndicator/main/Hypervolume_main.cpp index b5a2059..9210bd6 100644 --- a/src/qualityIndicator/main/Hypervolume_main.cpp +++ b/src/qualityIndicator/main/Hypervolume_main.cpp @@ -41,7 +41,7 @@ int main(int argc, char ** argv) } //Create a new instance of the metric - Hypervolume * qualityIndicator = new Hypervolume(); + Hypervolume * qualityIndicator = snew Hypervolume(); //Read the front from the files vector< vector > solutionFront = qualityIndicator->utils_->readFront(argv[1]); diff --git a/src/qualityIndicator/main/InvertedGenerationalDistance_main.cpp b/src/qualityIndicator/main/InvertedGenerationalDistance_main.cpp index 1a70404..959effc 100644 --- a/src/qualityIndicator/main/InvertedGenerationalDistance_main.cpp +++ b/src/qualityIndicator/main/InvertedGenerationalDistance_main.cpp @@ -42,7 +42,7 @@ int main(int argc, char ** argv) //Create a new instance of the metric InvertedGenerationalDistance * qualityIndicator = - new InvertedGenerationalDistance(); + snew InvertedGenerationalDistance(); //Read the front from the files vector< vector > solutionFront = qualityIndicator->utils_->readFront(argv[1]); diff --git a/src/qualityIndicator/util/MetricsUtil.cpp b/src/qualityIndicator/util/MetricsUtil.cpp index 7593ec9..8fe6e6c 100644 --- a/src/qualityIndicator/util/MetricsUtil.cpp +++ b/src/qualityIndicator/util/MetricsUtil.cpp @@ -302,7 +302,7 @@ SolutionSet * MetricsUtil::readNonDominatedSolutionSet(string path) exit(-1); } // if - NonDominatedSolutionList * solutionSet = new NonDominatedSolutionList(); + NonDominatedSolutionList * solutionSet = snew NonDominatedSolutionList(); string line; while( getline(in, line ) ) @@ -321,7 +321,7 @@ SolutionSet * MetricsUtil::readNonDominatedSolutionSet(string path) } // if } // while - Solution * solution = new Solution(list.size()); + Solution * solution = snew Solution(list.size()); for (int i=0; isetObjective(i,list[i]); @@ -371,7 +371,7 @@ void MetricsUtil::readNonDominatedSolutionSet(string path, NonDominatedSolutionL } // if } // while - Solution * solution = new Solution(list.size()); + Solution * solution = snew Solution(list.size()); for (int i=0; isetObjective(i,list[i]); diff --git a/src/util/AdaptiveGrid.cpp b/src/util/AdaptiveGrid.cpp index ef8b2a6..47158dd 100644 --- a/src/util/AdaptiveGrid.cpp +++ b/src/util/AdaptiveGrid.cpp @@ -32,13 +32,13 @@ AdaptiveGrid::AdaptiveGrid(int bisections, int objetives) { bisections_ = bisections; objectives_ = objetives ; - lowerLimits_ = new double[objectives_]; - upperLimits_ = new double[objectives_]; - divisionSize_ = new double[objectives_]; + lowerLimits_ = snew double[objectives_]; + upperLimits_ = snew double[objectives_]; + divisionSize_ = snew double[objectives_]; sizehypercubes_ = (int)pow(2.0,bisections_*objectives_); // Size int * - hypercubes_ = new int[sizehypercubes_]; + hypercubes_ = snew int[sizehypercubes_]; for (int i = 0; i < sizehypercubes_; i++) hypercubes_[i] = 0; }//AdaptativeGrid @@ -185,7 +185,7 @@ void AdaptiveGrid::updateGrid(Solution * solution, SolutionSet * solutionSet, in int AdaptiveGrid::location(Solution * solution) { //Create a int [] to store the range of each objetive - int * position = new int[objectives_]; + int * position = snew int[objectives_]; //Calculate the position for each objetive for (int obj = 0; obj < objectives_; obj++) @@ -371,7 +371,7 @@ int AdaptiveGrid::calculateOccupied() } // for occupiedsize_ = total; - occupied_ = new int[occupiedsize_]; + occupied_ = snew int[occupiedsize_]; int base = 0; for (int i = 0; i < sizehypercubes_; i++) diff --git a/src/util/AdaptiveRandomNeighborhood.cpp b/src/util/AdaptiveRandomNeighborhood.cpp index 64758f3..b5340e0 100644 --- a/src/util/AdaptiveRandomNeighborhood.cpp +++ b/src/util/AdaptiveRandomNeighborhood.cpp @@ -37,11 +37,11 @@ AdaptiveRandomNeighborhood::AdaptiveRandomNeighborhood(SolutionSet * solutionSet numberOfRandomNeighbours_ = numberOfRandomNeighbours; //problem_ = solutionSet_->get(0)->getProblem() ; - //list_ = new int * [solutionSet_->size()]; + //list_ = snew int * [solutionSet_->size()]; for (int i = 0; i < solutionSet_->size(); i++) { - //list_[i] = new int [] + //list_[i] = snew int [] vector list_i; list_i.push_back(i); list_.push_back(list_i); @@ -110,7 +110,7 @@ int AdaptiveRandomNeighborhood::getNumberOfRandomNeighbours() SolutionSet * AdaptiveRandomNeighborhood::getBestFitnessSolutionInNeighborhood(Comparator * comparator) { - SolutionSet * result = new SolutionSet(); + SolutionSet * result = snew SolutionSet(); for (int i = 0; i < list_.size(); i++) { Solution * bestSolution = solutionSet_->get(list_.at(i).at(0)); @@ -140,7 +140,7 @@ void AdaptiveRandomNeighborhood::recompute() for (int i = 0; i < solutionSet_->size(); i++) { - //list_[i] = new int [] + //list_[i] = snew int [] vector list_i; list_i.push_back(i); list_.push_back(list_i); diff --git a/src/util/Distance.cpp b/src/util/Distance.cpp index a1b5a62..00b159c 100644 --- a/src/util/Distance.cpp +++ b/src/util/Distance.cpp @@ -51,10 +51,10 @@ double ** Distance::distanceMatrix(SolutionSet * solutionSet) //The matrix of distances int size = solutionSet->size(); - double ** distance = nullptr;// = new double [size][size]; + double ** distance = nullptr;// = snew double [size][size]; for (int i = 0; i < solutionSet->size(); i++) { - distance[i] = new double[size]; + distance[i] = snew double[size]; } //-> Calculate the distances for (int i = 0; i < solutionSet->size(); i++) @@ -201,7 +201,7 @@ void Distance::crowdingDistanceAssignment(SolutionSet * solutionSet, int nObjs) } // if //Use a new SolutionSet to evite alter original solutionSet - SolutionSet * front = new SolutionSet(size); + SolutionSet * front = snew SolutionSet(size); for (int i = 0; i < size; i++) { front->add(solutionSet->get(i)); @@ -217,7 +217,7 @@ void Distance::crowdingDistanceAssignment(SolutionSet * solutionSet, int nObjs) for (int i = 0; isort(c); delete c; objetiveMinn = front->get(0)->getObjective(i); diff --git a/src/util/NonDominatedSolutionList.cpp b/src/util/NonDominatedSolutionList.cpp index 71079ae..eab00ad 100644 --- a/src/util/NonDominatedSolutionList.cpp +++ b/src/util/NonDominatedSolutionList.cpp @@ -31,8 +31,8 @@ NonDominatedSolutionList::NonDominatedSolutionList() : SolutionSet() { - dominance = new DominanceComparator(); - equal = new SolutionComparator(); + dominance = snew DominanceComparator(); + equal = snew SolutionComparator(); } // NonDominatedList diff --git a/src/util/PermutationUtility.cpp b/src/util/PermutationUtility.cpp index 4857f9e..5ccdb6b 100644 --- a/src/util/PermutationUtility.cpp +++ b/src/util/PermutationUtility.cpp @@ -19,12 +19,13 @@ // along with this program. If not, see . #include +#include "JMetalHeader.h" int * PermutationUtility::intPermutation(int length) { - int * aux = new int[length]; - int * result = new int[length]; + int * aux = snew int[length]; + int * result = snew int[length]; // First, create an array from 0 to length - 1. // Also is needed to create an random array of size length diff --git a/src/util/PseudoRandom.cpp b/src/util/PseudoRandom.cpp index e5149e4..03d5d65 100644 --- a/src/util/PseudoRandom.cpp +++ b/src/util/PseudoRandom.cpp @@ -112,7 +112,7 @@ double PseudoRandom::randNormal(double mean, double standardDeviation) double * PseudoRandom::randSphere(int dimension) { int D = dimension ; - double * x = new double[dimension] ; + double * x = snew double[dimension] ; double length = 0 ; for (int i = 0; i < dimension; i++) diff --git a/src/util/PseudoRandom.h b/src/util/PseudoRandom.h index 3cbe031..6cc4e2c 100644 --- a/src/util/PseudoRandom.h +++ b/src/util/PseudoRandom.h @@ -24,6 +24,7 @@ #ifndef _PseudoRandom_h #define _PseudoRandom_h +#include "JMetalHeader.h" #include #include #include diff --git a/src/util/Ranking.cpp b/src/util/Ranking.cpp index ec8e033..8272b2d 100644 --- a/src/util/Ranking.cpp +++ b/src/util/Ranking.cpp @@ -47,7 +47,7 @@ Ranking::Ranking (SolutionSet * solutionSet) constraint_ = new OverallConstraintViolationComparator(); // dominateMe[i] contains the number of solutions dominating i - int * dominateMe = new int[solutionSet_->size()]; + int * dominateMe = snew int[solutionSet_->size()]; if (dominateMe == nullptr) { diff --git a/src/util/archive/AdaptiveGridArchive.cpp b/src/util/archive/AdaptiveGridArchive.cpp index ab66624..83d5eed 100644 --- a/src/util/archive/AdaptiveGridArchive.cpp +++ b/src/util/archive/AdaptiveGridArchive.cpp @@ -33,8 +33,8 @@ AdaptiveGridArchive::AdaptiveGridArchive (int maxSize,int bisections, { maxSize_ = maxSize; - dominance_ = new DominanceComparator(); - grid_ = new AdaptiveGrid(bisections,objectives); + dominance_ = snew DominanceComparator(); + grid_ = snew AdaptiveGrid(bisections,objectives); } /** diff --git a/src/util/archive/CrowdingArchive.cpp b/src/util/archive/CrowdingArchive.cpp index c2f125d..2063194 100644 --- a/src/util/archive/CrowdingArchive.cpp +++ b/src/util/archive/CrowdingArchive.cpp @@ -36,10 +36,10 @@ CrowdingArchive::CrowdingArchive(int maxSize, int numberOfObjectives) this->maxSize = maxSize; this->objectives = numberOfObjectives; - this->dominance = new DominanceComparator(); - this->equals = new EqualSolutions(); - this->crowdingDistance = new CrowdingDistanceComparator(); - this->distance = new Distance(); + this->dominance = snew DominanceComparator(); + this->equals = snew EqualSolutions(); + this->crowdingDistance = snew CrowdingDistanceComparator(); + this->distance = snew Distance(); } // CrowdingArchive diff --git a/src/util/comparators/CrowdingComparator.cpp b/src/util/comparators/CrowdingComparator.cpp index dc1c14c..132f849 100644 --- a/src/util/comparators/CrowdingComparator.cpp +++ b/src/util/comparators/CrowdingComparator.cpp @@ -29,7 +29,7 @@ */ CrowdingComparator::CrowdingComparator() : Comparator() { - comparator = new RankComparator(); + comparator = snew RankComparator(); } // CrowdingComparator diff --git a/src/util/comparators/DominanceComparator.cpp b/src/util/comparators/DominanceComparator.cpp index b97c2e4..34011cd 100644 --- a/src/util/comparators/DominanceComparator.cpp +++ b/src/util/comparators/DominanceComparator.cpp @@ -36,7 +36,7 @@ */ DominanceComparator::DominanceComparator() : Comparator() { - overallConstraintViolationComparator_ = new OverallConstraintViolationComparator(); + overallConstraintViolationComparator_ = snew OverallConstraintViolationComparator(); } // DominanceComparator diff --git a/src/util/comparators/EpsilonDominanceComparator.cpp b/src/util/comparators/EpsilonDominanceComparator.cpp index 9525875..c52de16 100644 --- a/src/util/comparators/EpsilonDominanceComparator.cpp +++ b/src/util/comparators/EpsilonDominanceComparator.cpp @@ -32,7 +32,7 @@ EpsilonDominanceComparator::EpsilonDominanceComparator(double eta) : Comparator() { eta_ = eta; - overallConstraintViolationComparator_ = new OverallConstraintViolationComparator(); + overallConstraintViolationComparator_ = snew OverallConstraintViolationComparator(); } // EpsilonDominanceComparator /** diff --git a/src/util/comparators/EqualSolutions.cpp b/src/util/comparators/EqualSolutions.cpp index 024eced..a9fdd40 100644 --- a/src/util/comparators/EqualSolutions.cpp +++ b/src/util/comparators/EqualSolutions.cpp @@ -60,7 +60,7 @@ int EqualSolutions::compare(void * o1, void * o2) double value1, value2; for (int i = 0; i < solution1->getNumberOfObjectives(); i++) { - Comparator * c = new ObjectiveComparator(i); + Comparator * c = snew ObjectiveComparator(i); flag = c->compare(solution1,solution2); delete c; value1 = solution1->getObjective(i); From 36c949831a2f47b9b7b902f8145f67a49ac08c1a Mon Sep 17 00:00:00 2001 From: Sergio Vieira Date: Fri, 28 Jul 2017 14:16:13 -0300 Subject: [PATCH 10/29] Removed unecessary namespaces --- src/core/Algorithm.cpp | 12 +- src/core/Algorithm.h | 18 +- src/core/Operator.cpp | 6 +- src/core/Operator.h | 10 +- src/core/Problem.cpp | 6 +- src/core/Problem.h | 6 +- src/core/Solution.cpp | 20 +- src/core/Solution.h | 4 +- src/core/SolutionSet.cpp | 44 +- src/core/SolutionSet.h | 16 +- src/core/SolutionType.cpp | 2 +- src/core/Variable.cpp | 28 +- .../solutionType/ArrayRealSolutionType.cpp | 2 +- .../solutionType/BinarySolutionType.cpp | 2 +- .../solutionType/RealSolutionType.cpp | 2 +- src/encodings/variable/ArrayReal.cpp | 20 +- src/encodings/variable/ArrayReal.h | 2 +- src/encodings/variable/Binary.cpp | 16 +- src/encodings/variable/Binary.h | 8 +- src/encodings/variable/BinaryReal.cpp | 6 +- src/encodings/variable/BinaryReal.h | 2 +- src/encodings/variable/Real.cpp | 6 +- src/experiments/Experiment.cpp | 42 +- src/experiments/Experiment.h | 12 +- src/experiments/ExperimentExecution.cpp | 14 +- src/experiments/ExperimentExecution.h | 16 +- src/experiments/ExperimentReport.cpp | 192 ++++----- src/experiments/ExperimentReport.h | 28 +- src/experiments/Settings.cpp | 2 +- src/experiments/settings/DE_Settings.cpp | 8 +- src/experiments/settings/DE_Settings.h | 4 +- src/experiments/settings/GDE3_Settings.cpp | 6 +- src/experiments/settings/GDE3_Settings.h | 2 +- src/experiments/settings/NSGAII_Settings.cpp | 6 +- src/experiments/settings/NSGAII_Settings.h | 2 +- src/experiments/settings/PSO_Settings.cpp | 6 +- src/experiments/settings/PSO_Settings.h | 2 +- src/experiments/settings/SMPSO_Settings.cpp | 6 +- src/experiments/settings/SMPSO_Settings.h | 2 +- src/experiments/settings/gGA_Settings.cpp | 6 +- src/experiments/settings/gGA_Settings.h | 2 +- src/experiments/settings/ssGA_Settings.cpp | 6 +- src/experiments/util/FileUtils.cpp | 6 +- src/experiments/util/FileUtils.h | 4 +- src/experiments/util/RBoxplot.cpp | 50 +-- src/experiments/util/RBoxplot.h | 4 +- src/experiments/util/RWilcoxon.cpp | 376 +++++++++--------- src/experiments/util/RWilcoxon.h | 2 +- src/experiments/util/RunExperiment.cpp | 56 +-- src/experiments/util/RunExperiment.h | 24 +- src/experiments/util/Statistics.cpp | 14 +- src/main/OMOPSO_main.cpp | 26 +- src/metaheuristics/moead/MOEAD.cpp | 28 +- src/metaheuristics/moead/MOEAD.h | 6 +- .../singleObjective/cmaes/CMAES.cpp | 6 +- .../cmaes/utils/UtilsCMAES.cpp | 8 +- .../singleObjective/geneticAlgorithm/gGA.cpp | 16 +- .../singleObjective/geneticAlgorithm/ssGA.cpp | 2 +- .../particleSwarmOptimization/PSO.cpp | 2 +- .../StandardPSO2007.cpp | 32 +- .../StandardPSO2011.cpp | 32 +- src/metaheuristics/smpso/SMPSO.h | 4 +- src/metaheuristics/smsemoa/FastSMSEMOA.h | 2 +- src/metaheuristics/smsemoa/SMSEMOA.cpp | 28 +- src/operators/crossover/Crossover.cpp | 2 +- src/operators/crossover/Crossover.h | 2 +- .../DifferentialEvolutionCrossover.cpp | 10 +- .../DifferentialEvolutionCrossover.h | 6 +- src/operators/crossover/HUXCrossover.cpp | 4 +- src/operators/crossover/HUXCrossover.h | 2 +- src/operators/crossover/SBXCrossover.cpp | 14 +- src/operators/crossover/SBXCrossover.h | 2 +- .../crossover/SinglePointCrossover.cpp | 4 +- src/operators/mutation/BitFlipMutation.cpp | 2 +- src/operators/mutation/BitFlipMutation.h | 2 +- src/operators/mutation/Mutation.cpp | 2 +- src/operators/mutation/Mutation.h | 2 +- src/operators/mutation/NonUniformMutation.cpp | 4 +- src/operators/mutation/NonUniformMutation.h | 4 +- src/operators/mutation/PolynomialMutation.cpp | 2 +- src/operators/mutation/PolynomialMutation.h | 2 +- src/operators/mutation/UniformMutation.cpp | 4 +- .../selection/BestSolutionSelection.cpp | 2 +- .../selection/BestSolutionSelection.h | 2 +- src/operators/selection/BinaryTournament.cpp | 2 +- src/operators/selection/BinaryTournament.h | 2 +- src/operators/selection/BinaryTournament2.cpp | 6 +- src/operators/selection/BinaryTournament2.h | 2 +- .../DifferentialEvolutionSelection.cpp | 4 +- .../DifferentialEvolutionSelection.h | 2 +- src/operators/selection/RandomSelection.cpp | 2 +- src/operators/selection/RandomSelection.h | 2 +- src/operators/selection/Selection.cpp | 2 +- src/operators/selection/Selection.h | 2 +- .../selection/WorstSolutionSelection.cpp | 2 +- src/problems/DTLZ/DTLZ1.cpp | 10 +- src/problems/DTLZ/DTLZ1.h | 2 +- src/problems/DTLZ/DTLZ2.cpp | 10 +- src/problems/DTLZ/DTLZ2.h | 2 +- src/problems/DTLZ/DTLZ3.cpp | 10 +- src/problems/DTLZ/DTLZ3.h | 2 +- src/problems/DTLZ/DTLZ4.cpp | 10 +- src/problems/DTLZ/DTLZ4.h | 2 +- src/problems/DTLZ/DTLZ5.cpp | 10 +- src/problems/DTLZ/DTLZ5.h | 2 +- src/problems/DTLZ/DTLZ6.cpp | 10 +- src/problems/DTLZ/DTLZ6.h | 2 +- src/problems/DTLZ/DTLZ7.cpp | 10 +- src/problems/Fonseca.cpp | 16 +- src/problems/Fonseca.h | 2 +- src/problems/Kursawe.cpp | 12 +- src/problems/Kursawe.h | 4 +- src/problems/LZ09/LZ09.cpp | 20 +- src/problems/LZ09/LZ09.h | 8 +- src/problems/LZ09/LZ09_F1.cpp | 16 +- src/problems/LZ09/LZ09_F1.h | 2 +- src/problems/LZ09/LZ09_F2.cpp | 16 +- src/problems/LZ09/LZ09_F2.h | 2 +- src/problems/LZ09/LZ09_F3.cpp | 16 +- src/problems/LZ09/LZ09_F3.h | 2 +- src/problems/LZ09/LZ09_F4.cpp | 16 +- src/problems/LZ09/LZ09_F4.h | 2 +- src/problems/LZ09/LZ09_F5.cpp | 16 +- src/problems/LZ09/LZ09_F5.h | 2 +- src/problems/LZ09/LZ09_F6.cpp | 16 +- src/problems/LZ09/LZ09_F6.h | 2 +- src/problems/LZ09/LZ09_F7.cpp | 16 +- src/problems/LZ09/LZ09_F7.h | 2 +- src/problems/LZ09/LZ09_F8.cpp | 16 +- src/problems/LZ09/LZ09_F8.h | 2 +- src/problems/LZ09/LZ09_F9.cpp | 16 +- src/problems/ProblemFactory.cpp | 76 ++-- src/problems/Schaffer.cpp | 8 +- src/problems/Schaffer.h | 2 +- src/problems/Srinivas.cpp | 12 +- src/problems/Srinivas.h | 4 +- src/problems/Tanaka.cpp | 10 +- src/problems/ZDT/ZDT1.cpp | 10 +- src/problems/ZDT/ZDT1.h | 2 +- src/problems/ZDT/ZDT2.cpp | 10 +- src/problems/ZDT/ZDT2.h | 2 +- src/problems/ZDT/ZDT3.cpp | 10 +- src/problems/ZDT/ZDT3.h | 2 +- src/problems/ZDT/ZDT4.cpp | 10 +- src/problems/ZDT/ZDT4.h | 2 +- src/problems/ZDT/ZDT5.cpp | 8 +- src/problems/ZDT/ZDT5.h | 2 +- src/problems/ZDT/ZDT6.cpp | 10 +- .../singleObjective/CEC2005Problem.cpp | 4 +- src/problems/singleObjective/CEC2005Problem.h | 2 +- src/problems/singleObjective/Griewank.cpp | 8 +- src/problems/singleObjective/Griewank.h | 2 +- src/problems/singleObjective/Rastrigin.cpp | 10 +- src/problems/singleObjective/Rastrigin.h | 2 +- src/problems/singleObjective/Rosenbrock.cpp | 10 +- src/problems/singleObjective/Rosenbrock.h | 2 +- src/problems/singleObjective/Sphere.cpp | 10 +- .../cec2005Competition/Benchmark.cpp | 28 +- .../cec2005Competition/Benchmark.h | 12 +- .../cec2005Competition/F01ShiftedSphere.cpp | 6 +- .../cec2005Competition/F01ShiftedSphere.h | 6 +- .../cec2005Competition/F02ShiftedSchwefel.cpp | 6 +- .../cec2005Competition/F02ShiftedSchwefel.h | 6 +- .../F03ShiftedRotatedHighCondElliptic.cpp | 12 +- .../F03ShiftedRotatedHighCondElliptic.h | 12 +- .../F04ShiftedSchwefelNoise.cpp | 6 +- .../F04ShiftedSchwefelNoise.h | 6 +- .../F05SchwefelGlobalOptBound.cpp | 6 +- .../F05SchwefelGlobalOptBound.h | 6 +- .../F06ShiftedRosenbrock.cpp | 6 +- .../cec2005Competition/F06ShiftedRosenbrock.h | 6 +- .../F07ShiftedRotatedGriewank.cpp | 12 +- .../F07ShiftedRotatedGriewank.h | 12 +- .../F08ShiftedRotatedAckleyGlobalOptBound.cpp | 12 +- .../F08ShiftedRotatedAckleyGlobalOptBound.h | 12 +- .../F09ShiftedRastrigin.cpp | 6 +- .../cec2005Competition/F09ShiftedRastrigin.h | 6 +- .../F10ShiftedRotatedRastrigin.cpp | 12 +- .../F10ShiftedRotatedRastrigin.h | 12 +- .../F11ShiftedRotatedWeierstrass.cpp | 12 +- .../F11ShiftedRotatedWeierstrass.h | 12 +- .../cec2005Competition/F12Schwefel.cpp | 6 +- .../cec2005Competition/F12Schwefel.h | 6 +- .../F13ShiftedExpandedGriewankRosenbrock.cpp | 6 +- .../F13ShiftedExpandedGriewankRosenbrock.h | 6 +- .../F14ShiftedRotatedExpandedScaffer.cpp | 12 +- .../F14ShiftedRotatedExpandedScaffer.h | 12 +- .../F15HybridComposition1.cpp | 8 +- .../F15HybridComposition1.h | 6 +- .../F16RotatedHybridComposition1.cpp | 14 +- .../F16RotatedHybridComposition1.h | 12 +- .../F17RotatedHybridComposition1Noise.cpp | 14 +- .../F17RotatedHybridComposition1Noise.h | 12 +- .../F18RotatedHybridComposition2.cpp | 14 +- .../F18RotatedHybridComposition2.h | 12 +- ...HybridComposition2NarrowBasinGlobalOpt.cpp | 14 +- ...edHybridComposition2NarrowBasinGlobalOpt.h | 12 +- ...otatedHybridComposition2GlobalOptBound.cpp | 14 +- ...0RotatedHybridComposition2GlobalOptBound.h | 12 +- .../F21RotatedHybridComposition3.cpp | 14 +- .../F21RotatedHybridComposition3.h | 12 +- ...tedHybridComposition3HighCondNumMatrix.cpp | 14 +- ...tatedHybridComposition3HighCondNumMatrix.h | 12 +- ...NoncontinuousRotatedHybridComposition3.cpp | 14 +- ...23NoncontinuousRotatedHybridComposition3.h | 12 +- .../F24RotatedHybridComposition4.cpp | 14 +- .../F24RotatedHybridComposition4.h | 12 +- .../F25RotatedHybridComposition4Bound.cpp | 14 +- .../F25RotatedHybridComposition4Bound.h | 12 +- .../cec2005Competition/TestFunc.cpp | 4 +- src/qualityIndicator/Epsilon.cpp | 4 +- src/qualityIndicator/Epsilon.h | 2 +- src/qualityIndicator/Fitness.cpp | 4 +- src/qualityIndicator/Fitness.h | 4 +- src/qualityIndicator/GenerationalDistance.cpp | 12 +- src/qualityIndicator/GenerationalDistance.h | 4 +- src/qualityIndicator/Hypervolume.cpp | 16 +- src/qualityIndicator/Hypervolume.h | 6 +- .../InvertedGenerationalDistance.cpp | 10 +- .../InvertedGenerationalDistance.h | 4 +- src/qualityIndicator/QualityIndicator.cpp | 2 +- src/qualityIndicator/QualityIndicator.h | 2 +- src/qualityIndicator/Spread.cpp | 14 +- .../fastHypervolume/FastHypervolume.cpp | 4 +- .../fastHypervolume/FastHypervolume.h | 2 +- .../FastHypervolumeArchive.cpp | 2 +- src/qualityIndicator/main/Epsilon_main.cpp | 10 +- .../main/GenerationalDistance_main.cpp | 10 +- .../main/Hypervolume_main.cpp | 10 +- .../InvertedGenerationalDistance_main.cpp | 10 +- .../util/LexicoGraphicalComparator.cpp | 6 +- src/qualityIndicator/util/MetricsUtil.cpp | 82 ++-- src/util/AdaptiveGrid.cpp | 4 +- src/util/AdaptiveGrid.h | 2 +- src/util/AdaptiveRandomNeighborhood.cpp | 26 +- src/util/AdaptiveRandomNeighborhood.h | 10 +- src/util/Distance.h | 2 +- src/util/PseudoRandom.cpp | 2 +- src/util/RandomGenerator.cpp | 8 +- src/util/Ranking.cpp | 10 +- src/util/wrapper/XReal.cpp | 24 +- 241 files changed, 1415 insertions(+), 1417 deletions(-) diff --git a/src/core/Algorithm.cpp b/src/core/Algorithm.cpp index 0988513..c6e9c66 100644 --- a/src/core/Algorithm.cpp +++ b/src/core/Algorithm.cpp @@ -49,7 +49,7 @@ Algorithm::~Algorithm() * @param name The operator name * @param operator The operator **/ -void Algorithm::addOperator(string name, Operator * operator_) +void Algorithm::addOperator(std::string name, Operator * operator_) { operators_[name] = operator_; } @@ -62,7 +62,7 @@ void Algorithm::addOperator(string name, Operator * operator_) * @param name The operator name * @return The operator if exists, null in another case. **/ -Operator * Algorithm::getOperator(string name) +Operator * Algorithm::getOperator(std::string name) { return operators_[name]; } @@ -77,7 +77,7 @@ Operator * Algorithm::getOperator(string name) * @param object Object that represent a parameter for the * algorithm. **/ -void Algorithm::setInputParameter(string name, void *value) +void Algorithm::setInputParameter(std::string name, void *value) { inputParameters_[name] = value; } @@ -90,7 +90,7 @@ void Algorithm::setInputParameter(string name, void *value) * @return Object representing the parameter or null if the parameter doesn't * exist or the name is wrong **/ -void * Algorithm::getInputParameter(string name) +void * Algorithm::getInputParameter(std::string name) { return inputParameters_[name]; } @@ -104,7 +104,7 @@ void * Algorithm::getInputParameter(string name) * @param name The output parameter name * @param object Object representing the output parameter **/ -void Algorithm::setOutputParameter(string name, void *value) +void Algorithm::setOutputParameter(std::string name, void *value) { outputParameters_[name] = value; } @@ -117,7 +117,7 @@ void Algorithm::setOutputParameter(string name, void *value) * @return Object representing the output parameter, or null if the parameter * doesn't exist or the name is wrong. **/ -void * Algorithm::getOutputParameter(string name) +void * Algorithm::getOutputParameter(std::string name) { return outputParameters_[name]; } diff --git a/src/core/Algorithm.h b/src/core/Algorithm.h index 8e28ef3..a7f40a1 100644 --- a/src/core/Algorithm.h +++ b/src/core/Algorithm.h @@ -44,19 +44,19 @@ class Algorithm virtual ~Algorithm(); virtual SolutionSet * execute() = 0; // this launch the execution // of an algorithm - void addOperator(string name, Operator *operator_); - Operator * getOperator(string name); - void setInputParameter(string name, void *value); - void * getInputParameter(string name); - void setOutputParameter(string name, void *value); - void * getOutputParameter(string name); + void addOperator(std::string name, Operator *operator_); + Operator * getOperator(std::string name); + void setInputParameter(std::string name, void *value); + void * getInputParameter(std::string name); + void setOutputParameter(std::string name, void *value); + void * getOutputParameter(std::string name); Problem * getProblem(); protected: Problem *problem_; - map operators_; - map inputParameters_; - map outputParameters_; + std::map operators_; + std::map inputParameters_; + std::map outputParameters_; }; // Algorithm diff --git a/src/core/Operator.cpp b/src/core/Operator.cpp index 0dbd471..10479f2 100644 --- a/src/core/Operator.cpp +++ b/src/core/Operator.cpp @@ -35,7 +35,7 @@ Operator::Operator() /** * Constructor. **/ -Operator::Operator(map parameters) +Operator::Operator(std::map parameters) { parameters_ = parameters; } // Operator @@ -52,7 +52,7 @@ Operator::~Operator() { /* do nothing */ } * @param name The parameter name. * @param value Object representing the parameter. **/ -void Operator::setParameter(string name, void *value) +void Operator::setParameter(std::string name, void *value) { parameters_[name] = value; } // setParameter @@ -63,7 +63,7 @@ void Operator::setParameter(string name, void *value) * @param name The parameter name. * @return the parameter. **/ -void * Operator::getParameter(string name) +void * Operator::getParameter(std::string name) { return parameters_[name]; } diff --git a/src/core/Operator.h b/src/core/Operator.h index d417436..3537fb5 100644 --- a/src/core/Operator.h +++ b/src/core/Operator.h @@ -27,7 +27,7 @@ #include #include -using namespace std; + /** * Stores the current operator parameters. @@ -39,15 +39,15 @@ class Operator { protected: - map parameters_; + std::map parameters_; public: Operator (); - Operator (map parameters); + Operator (std::map parameters); virtual ~Operator() = 0; virtual void *execute(void *) = 0; - void setParameter(string name, void *value); - void *getParameter(string name); + void setParameter(std::string name, void *value); + void *getParameter(std::string name); }; // Operator diff --git a/src/core/Problem.cpp b/src/core/Problem.cpp index 553a48c..ee49b0a 100644 --- a/src/core/Problem.cpp +++ b/src/core/Problem.cpp @@ -101,7 +101,7 @@ double Problem::getLowerLimit(int i) { if ((lowerLimit_ == nullptr) || (i >= numberOfVariables_)) { - cout << "Error: lower limits have been not initialized or accessing to a variable out of range" << endl; + std::cout << "Error: lower limits have been not initialized or accessing to a variable out of range" << std::endl; // exit(-1); } return lowerLimit_[i]; @@ -117,7 +117,7 @@ double Problem::getUpperLimit(int i) { if ((upperLimit_ == nullptr) || (i >= numberOfVariables_)) { - cout << "Error: upper limits have been not initialized or accessing to a variable out of range" << endl; + std::cout << "Error: upper limits have been not initialized or accessing to a variable out of range" << std::endl; //exit(-1); } return upperLimit_[i]; @@ -240,7 +240,7 @@ SolutionType * Problem::getSolutionType() * Returns the problem name * @return The problem name */ -string Problem::getName() +std::string Problem::getName() { return problemName_; } // getName diff --git a/src/core/Problem.h b/src/core/Problem.h index cf970e9..38f2864 100644 --- a/src/core/Problem.h +++ b/src/core/Problem.h @@ -30,8 +30,6 @@ #include #include -using namespace std; - class SolutionType; class Solution; @@ -48,7 +46,7 @@ class Problem int numberOfVariables_; int numberOfObjectives_; int numberOfConstraints_; - string problemName_; + std::string problemName_; SolutionType *solutionType_; double *lowerLimit_; double *upperLimit_; @@ -74,7 +72,7 @@ class Problem int getLength(int var); void setSolutionType(SolutionType * type); SolutionType * getSolutionType(); - string getName(); + std::string getName(); int getNumberOfBits(); }; // Problem diff --git a/src/core/Solution.cpp b/src/core/Solution.cpp index 318790a..7f8431e 100644 --- a/src/core/Solution.cpp +++ b/src/core/Solution.cpp @@ -58,7 +58,7 @@ Solution::Solution (int numberOfObjectives) objective_ = snew double[numberOfObjectives_]; if (objective_ == nullptr) { - cout << "ERROR GRAVE: Impossible to reserve memory for storing objectives in class Solution" << endl; + std::cout << "ERROR GRAVE: Impossible to reserve memory for storing objectives in class Solution" << std::endl; exit(-1); } rank_ = 0; @@ -82,7 +82,7 @@ Solution::Solution (Problem *problem) objective_ = snew double[numberOfObjectives_]; if (objective_ == nullptr) { - cout << "ERROR GRAVE: Impossible to reserve memory for storing objectives in class Solution" << endl; + std::cout << "ERROR GRAVE: Impossible to reserve memory for storing objectives in class Solution" << std::endl; exit(-1); } // at this point objective vector has been created successfully @@ -134,7 +134,7 @@ Solution::Solution (Solution *solution) objective_ = snew double[numberOfObjectives_]; if (objective_ == nullptr) { - cout << "ERROR GRAVE: Impossible to reserve memory for storing objectives in class Solution" << endl; + std::cout << "ERROR GRAVE: Impossible to reserve memory for storing objectives in class Solution" << std::endl; exit(-1); } for (int i = 0; i< numberOfObjectives_; i++) @@ -282,8 +282,8 @@ void Solution::setObjective(int i, double value) { if (i < 0 || i >= numberOfObjectives_) { - cout << "Solution::setObjective: objective index out of range: " << i - << endl; + std::cout << "Solution::setObjective: objective index out of range: " << i + << std::endl; exit(-1); } objective_[i] = value; @@ -298,8 +298,8 @@ double Solution::getObjective(int i) { if (i < 0 || i >= numberOfObjectives_) { - cout << "Solution::getObjective: objective index out of range: " << i - << endl; + std::cout << "Solution::getObjective: objective index out of range: " << i + << std::endl; exit(-1); } return objective_[i]; @@ -327,12 +327,12 @@ int Solution::getNumberOfVariables() /** - * Returns a string representing the solution. + * Returns a std::string representing the solution. * @return The string. */ -string Solution::toString() +std::string Solution::toString() { - string aux = ""; + std::string aux = ""; for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/core/Solution.h b/src/core/Solution.h index c621d3a..f519d21 100644 --- a/src/core/Solution.h +++ b/src/core/Solution.h @@ -33,7 +33,7 @@ #include -//using namespace std; +// // class Problem ; class Variable ; @@ -85,7 +85,7 @@ class Solution double getObjective(int i); int getNumberOfObjectives(); int getNumberOfVariables(); - string toString(); + std::string toString(); Variable ** getDecisionVariables(); void setDecisionVariables(Variable ** variables); bool isMarked(); diff --git a/src/core/SolutionSet.cpp b/src/core/SolutionSet.cpp index 1ba39ac..ae8e8cd 100644 --- a/src/core/SolutionSet.cpp +++ b/src/core/SolutionSet.cpp @@ -66,7 +66,7 @@ bool SolutionSet::add(Solution * solution) { if (solutionsList_.size() >= capacity_) { - cout << "Error in class SolutionSet the maximum capacity of the set has been reached" << endl; + std::cout << "Error in class SolutionSet the maximum capacity of the set has been reached" << std::endl; exit(-1); } solutionsList_.push_back(solution); @@ -97,7 +97,7 @@ Solution * SolutionSet::get(int i) { if (i < 0 || i >= solutionsList_.size()) { - cout << "Error in class SolutionSet trying to access to an element out of range" << endl; + std::cout << "Error in class SolutionSet trying to access to an element out of range" << std::endl; exit(-1); } return solutionsList_[i]; @@ -122,7 +122,7 @@ void SolutionSet::sort(Comparator * comparator) { if (comparator == nullptr) { - cout << "Error. No criterium for compare exist" << endl; + std::cout << "Error. No criterium for compare exist" << std::endl; exit(-1); } // if for (int i = 0; i < solutionsList_.size(); i++) @@ -161,7 +161,7 @@ int SolutionSet::indexBest(Comparator *comparator) { candidateSolution = solutionsList_[i]; flag = comparator->compare(bestKnown, candidateSolution); - //cout << "flag: " << flag << endl; + //std::cout << "flag: " << flag << std::endl; if (flag == 1) { index = i; @@ -260,20 +260,20 @@ int SolutionSet::size() * objects into the set in a file. * @param path The output file name */ -void SolutionSet::printObjectivesToFile(string file) +void SolutionSet::printObjectivesToFile(std::string file) { std::ofstream out(file.c_str()); - cout.setf(ios::fixed); + std::cout.setf(ios::fixed); for (int i = 0; i < solutionsList_.size(); i++) { int nObj = solutionsList_[i]->getNumberOfObjectives(); for (int obj = 0; obj < nObj; obj++) { out << solutionsList_[i]->getObjective(obj) << " "; - //cout << setprecision(15) << solutionsList_[i]->getObjective(obj) << " "; + //std::cout << setprecision(15) << solutionsList_[i]->getObjective(obj) << " "; } - out << endl; - //cout << endl; + out << std::endl; + //std::cout << std::endl; } out.close(); } // printObjectivesToFile @@ -286,12 +286,12 @@ void SolutionSet::printObjectivesToFile(string file) * @param append If the objectives will be appended in case a file * already exists */ -void SolutionSet::printObjectivesToFile(string file, bool append) +void SolutionSet::printObjectivesToFile(std::string file, bool append) { if (append) { std::fstream out(file.c_str(), std::ios::out | std::ios::app); - cout.setf(ios::fixed); + std::cout.setf(ios::fixed); for (int i = 0; i < solutionsList_.size(); i++) { int nObj = solutionsList_[i]->getNumberOfObjectives(); @@ -299,7 +299,7 @@ void SolutionSet::printObjectivesToFile(string file, bool append) { out << solutionsList_[i]->getObjective(obj) << " "; } - out << endl; + out << std::endl; } out.close(); } @@ -315,12 +315,12 @@ void SolutionSet::printObjectivesToFile(string file, bool append) * solutions objects into the set in a file. * @param path The output file name */ -void SolutionSet::printVariablesToFile(string file) +void SolutionSet::printVariablesToFile(std::string file) { std::ofstream out(file.c_str()); for (int i = 0; i < solutionsList_.size(); i++) { - out << solutionsList_[i]->toString() << endl ; + out << solutionsList_[i]->toString() << std::endl ; } out.close(); } // printVariablesToFile @@ -331,14 +331,14 @@ void SolutionSet::printVariablesToFile(string file) * solutions objects into the set in a file. * @param path The output file name */ -void SolutionSet::printVariablesToFile(string file, bool append) +void SolutionSet::printVariablesToFile(std::string file, bool append) { if (append) { std::fstream out(file.c_str(), std::ios::out | std::ios::app); for (int i = 0; i < solutionsList_.size(); i++) { - out << solutionsList_[i]->toString() << endl ; + out << solutionsList_[i]->toString() << std::endl ; } out.close(); } @@ -366,7 +366,7 @@ void SolutionSet::remove(int i) { if (i < 0 || i >= solutionsList_.size()) { - cout << "Error in class SolutionSet trying to access to an element out of range" << endl; + std::cout << "Error in class SolutionSet trying to access to an element out of range" << std::endl; exit(-1); } solutionsList_.erase(solutionsList_.begin() + i); @@ -404,7 +404,7 @@ void SolutionSet::replace(int position, Solution *solution) { if (position < 0 || position >= solutionsList_.size()) { - cout << "Error in class SolutionSet trying to access to an element out of range" << endl; + std::cout << "Error in class SolutionSet trying to access to an element out of range" << std::endl; exit(-1); } solutionsList_[position] = solution; @@ -415,13 +415,13 @@ void SolutionSet::replace(int position, Solution *solution) * Copies the objectives of the solution set to a matrix * @return A matrix containing the objectives */ -vector > SolutionSet::writeObjectivesToMatrix() +std::vector > SolutionSet::writeObjectivesToMatrix() { - vector > objectives; + std::vector > objectives; //objectives = snew double[size()][get(0).numberOfObjectives()]; for (int i = 0; i < size(); i++) { - vector list; + std::vector list; for (int j = 0; j < get(0)->getNumberOfObjectives(); j++) { list.push_back(get(i)->getObjective(j)); @@ -436,6 +436,6 @@ void SolutionSet::printObjectives() { for (int i = 0; i < solutionsList_.size(); i++) { - cout << solutionsList_.at(i)->toString() << endl; + std::cout << solutionsList_.at(i)->toString() << std::endl; } } diff --git a/src/core/SolutionSet.h b/src/core/SolutionSet.h index e514843..7d7f747 100644 --- a/src/core/SolutionSet.h +++ b/src/core/SolutionSet.h @@ -33,7 +33,7 @@ #include #include -using namespace std; + //class Solution ; class Comparator; @@ -46,7 +46,7 @@ class SolutionSet { protected: - vector solutionsList_; + std::vector solutionsList_; int capacity_; public: @@ -65,10 +65,10 @@ class SolutionSet int indexWorst(Comparator * comparator); Solution * worst(Comparator * comparator); int size(); - void printObjectivesToFile(string path); - void printObjectivesToFile(string path, bool append); - void printVariablesToFile(string file); - void printVariablesToFile(string file, bool append); + void printObjectivesToFile(std::string path); + void printObjectivesToFile(std::string path, bool append); + void printVariablesToFile(std::string file); + void printVariablesToFile(std::string file, bool append); void clear(); void clear(bool del); void remove(int i); @@ -76,11 +76,11 @@ class SolutionSet SolutionSet * join(SolutionSet * another); void replace(int position, Solution * solution); void replace(int position, Solution * solution, bool del); - vector > writeObjectivesToMatrix(); + std::vector > writeObjectivesToMatrix(); void printObjectives(); //void reset() ; - //string toString(); + //std::string toString(); }; diff --git a/src/core/SolutionType.cpp b/src/core/SolutionType.cpp index e9b1942..7d8b29c 100644 --- a/src/core/SolutionType.cpp +++ b/src/core/SolutionType.cpp @@ -52,7 +52,7 @@ Variable ** SolutionType::copyVariables(Variable **vars) if (variables == nullptr) { - cout << "Error grave: Impossible to reserve memory for allocating a copy of variables" << endl; + std::cout << "Error grave: Impossible to reserve memory for allocating a copy of variables" << std::endl; exit(-1); } diff --git a/src/core/Variable.cpp b/src/core/Variable.cpp index 043803c..7926a19 100644 --- a/src/core/Variable.cpp +++ b/src/core/Variable.cpp @@ -32,7 +32,7 @@ */ -using namespace std; + ///** @@ -45,8 +45,8 @@ using namespace std; // * must redefine it. // */ //double Variable::getValue() { -// cout << "Class " << typeid(this).name() << " does not implement " << -// "method getValue" << endl; +// std::cout << "Class " << typeid(this).name() << " does not implement " << +// "method getValue" << std::endl; //} // getValue // // @@ -58,8 +58,8 @@ using namespace std; // * must redefine it. // */ //void Variable::setValue(double value) { -// cout << "Class " << typeid(this).name() << " does not implement " << -// "method setValue" << endl; +// std::cout << "Class " << typeid(this).name() << " does not implement " << +// "method setValue" << std::endl; //} // setValue @@ -71,8 +71,8 @@ using namespace std; * Those classes requiring this method must redefine it. */ //double Variable::getLowerBound() { -// cout << "Class " << typeid(this).name() << " does not implement " << -// "method getLowerBound" << endl; +// std::cout << "Class " << typeid(this).name() << " does not implement " << +// "method getLowerBound" << std::endl; //} // getLowerBound @@ -83,8 +83,8 @@ using namespace std; * program is terminated. Those classes requiring this method must redefine it. */ //double Variable::getUpperBound() { -// cout << "Class " << typeid(this).name() << " does not implement " << -// "method getUpperBound" << endl; +// std::cout << "Class " << typeid(this).name() << " does not implement " << +// "method getUpperBound" << std::endl; //} // getUpperBound @@ -102,8 +102,8 @@ Variable::~Variable() { /* do nothing */ } */ void Variable::setLowerBound(double lowerBound) { - cout << "Class " << typeid(this).name() << " does not implement " << - "method setLowerBound" << endl; + std::cout << "Class " << typeid(this).name() << " does not implement " << + "method setLowerBound" << std::endl; } // setLowerBound @@ -115,8 +115,8 @@ void Variable::setLowerBound(double lowerBound) */ void Variable::setUpperBound(double upperBound) { - cout << "Class " << typeid(this).name() << " does not implement " << - "method setUpperBound" << endl; + std::cout << "Class " << typeid(this).name() << " does not implement " << + "method setUpperBound" << std::endl; } // setUpperBound @@ -125,7 +125,7 @@ void Variable::setUpperBound(double upperBound) * @return The type of the variable */ -string Variable::getVariableType() +std::string Variable::getVariableType() { return typeid(this).name() ; } // getVariableType diff --git a/src/encodings/solutionType/ArrayRealSolutionType.cpp b/src/encodings/solutionType/ArrayRealSolutionType.cpp index 61868e7..a14bda3 100644 --- a/src/encodings/solutionType/ArrayRealSolutionType.cpp +++ b/src/encodings/solutionType/ArrayRealSolutionType.cpp @@ -41,7 +41,7 @@ Variable ** ArrayRealSolutionType::createVariables() Variable **variables = snew Variable*[1]; //malloc(sizeof(Real) * problem->getNumberOfVariables()); if (problem_->getSolutionType() == nullptr) { - cout << "Error grave: Impossible to reserve memory for variable type" << endl; + std::cout << "Error grave: Impossible to reserve memory for variable type" << std::endl; exit(-1); } diff --git a/src/encodings/solutionType/BinarySolutionType.cpp b/src/encodings/solutionType/BinarySolutionType.cpp index a25c970..bb00881 100644 --- a/src/encodings/solutionType/BinarySolutionType.cpp +++ b/src/encodings/solutionType/BinarySolutionType.cpp @@ -41,7 +41,7 @@ Variable **BinarySolutionType::createVariables() Variable **variables = snew Variable*[problem_->getNumberOfVariables()]; //malloc(sizeof(Real) * problem->getNumberOfVariables()); // if (problem_->variableType_ == nullptr) { -// cout << "Error grave: Impossible to reserve memory for variable type" << endl; +// std::cout << "Error grave: Impossible to reserve memory for variable type" << std::endl; // exit(-1); // } diff --git a/src/encodings/solutionType/RealSolutionType.cpp b/src/encodings/solutionType/RealSolutionType.cpp index 3419052..d4d3178 100644 --- a/src/encodings/solutionType/RealSolutionType.cpp +++ b/src/encodings/solutionType/RealSolutionType.cpp @@ -43,7 +43,7 @@ Variable **RealSolutionType::createVariables() Variable **variables = new Variable*[problem_->getNumberOfVariables()]; //malloc(sizeof(Real) * problem->getNumberOfVariables()); if (variables == nullptr) { - cout << "Error grave: Impossible to reserve memory for variable type" << endl; + std::cout << "Error grave: Impossible to reserve memory for variable type" << std::endl; exit(-1); } diff --git a/src/encodings/variable/ArrayReal.cpp b/src/encodings/variable/ArrayReal.cpp index e4b9c90..10c1699 100644 --- a/src/encodings/variable/ArrayReal.cpp +++ b/src/encodings/variable/ArrayReal.cpp @@ -110,14 +110,14 @@ double ArrayReal::getValue(int index) return array_[index] ; else { - cerr << "ArrayReal.getValue: index value (" << index << ") invalid" << endl; + cerr << "ArrayReal.getValue: index value (" << index << ") invalid" << std::endl; exit(-1); } // if } // getValue double ArrayReal::getValue() { - cerr << "ERROR: ArrayReal::getValue() without index" << endl; + cerr << "ERROR: ArrayReal::getValue() without index" << std::endl; exit(-1); } // getValue @@ -133,13 +133,13 @@ void ArrayReal::setValue(int index, double value) array_[index] = value; else { - cout << "ArrayReal.getValue: index value (" << index << ") invalid" << endl; + std::cout << "ArrayReal.getValue: index value (" << index << ") invalid" << std::endl; } // if } // setValue void ArrayReal::setValue(double value) { - cout << "ERROR: ArrayReal::setValue(value) without index" << endl; + std::cout << "ERROR: ArrayReal::setValue(value) without index" << std::endl; } // setValue @@ -154,14 +154,14 @@ double ArrayReal::getLowerBound(int index) return problem_->getLowerLimit(index) ; else { - cerr << "ArrayReal.getValue: index value (" << index << ") invalid" << endl; + cerr << "ArrayReal.getValue: index value (" << index << ") invalid" << std::endl; exit(-1); } // if } // getLowerBound double ArrayReal::getLowerBound() { - cerr << "ERROR: ArrayReal::getLowerBound() without index" << endl; + cerr << "ERROR: ArrayReal::getLowerBound() without index" << std::endl; exit(-1); } // getLowerBound @@ -177,23 +177,23 @@ double ArrayReal::getUpperBound(int index) return problem_->getUpperLimit(index); else { - cerr << "ArrayReal.getValue: index value (" << index << ") invalid" << endl; + cerr << "ArrayReal.getValue: index value (" << index << ") invalid" << std::endl; exit(-1); } // if } // getLowerBound double ArrayReal::getUpperBound() { - cerr << "ERROR: ArrayReal::getUpperBound() without index" << endl; + cerr << "ERROR: ArrayReal::getUpperBound() without index" << std::endl; exit(-1); } // getUpperBound /** - * Returns a string representing the object + * Returns a std::string representing the object * @return The string */ -string ArrayReal::toString() +std::string ArrayReal::toString() { std::ostringstream ss; for (int i = 0; i < (size_ - 1); i ++) diff --git a/src/encodings/variable/ArrayReal.h b/src/encodings/variable/ArrayReal.h index d66316c..940078d 100644 --- a/src/encodings/variable/ArrayReal.h +++ b/src/encodings/variable/ArrayReal.h @@ -51,7 +51,7 @@ class ArrayReal : public Variable void setValue(int index, double value); double getLowerBound(int index); double getUpperBound(int index); - string toString(); + std::string toString(); void setValue(double value); double getValue(); diff --git a/src/encodings/variable/Binary.cpp b/src/encodings/variable/Binary.cpp index c33d147..1cb772c 100644 --- a/src/encodings/variable/Binary.cpp +++ b/src/encodings/variable/Binary.cpp @@ -41,7 +41,7 @@ Binary::Binary(int numberOfBits) { numberOfBits_ = numberOfBits; - bits_ = snew vector(numberOfBits_, false) ; + bits_ = snew std::vector(numberOfBits_, false) ; for (int i = 0; i < numberOfBits_; i++) { @@ -64,7 +64,7 @@ Binary::Binary(int numberOfBits) Binary::Binary(Binary * variable) { numberOfBits_ = variable->getNumberOfBits(); - bits_ = snew vector(numberOfBits_, false) ; + bits_ = snew std::vector(numberOfBits_, false) ; for (int i = 0; i < numberOfBits_; i++) { (*bits_)[i] = (*variable->bits_)[i] ; @@ -146,7 +146,7 @@ void Binary::setIth(int bit, bool value) /** * Obtain the hamming distance between two binary strings -* @param other The binary string to compare +* @param other The binary std::string to compare * @return The hamming distance */ int Binary::hammingDistance(Binary * other) @@ -166,13 +166,13 @@ int Binary::hammingDistance(Binary * other) /** - * Returns a string representing the object. + * Returns a std::string representing the object. * @return the string. */ -string Binary::toString() +std::string Binary::toString() { - vector::iterator it; - string str = "" ; + std::vector::iterator it; + std::string str = "" ; for(it = bits_->begin(); it != bits_->end(); it++) { if (*it == true) @@ -189,7 +189,7 @@ string Binary::toString() int Binary::cardinality() { int counter = 0 ; - vector::iterator it; + std::vector::iterator it; for(it = bits_->begin(); it != bits_->end(); it++) if (*it == true) counter ++ ; diff --git a/src/encodings/variable/Binary.h b/src/encodings/variable/Binary.h index b7c5b37..ed10e10 100644 --- a/src/encodings/variable/Binary.h +++ b/src/encodings/variable/Binary.h @@ -30,8 +30,8 @@ #include /** - * This class implements a generic binary string variable.It can be used as - * a base class other binary string based classes (e.g., binary coded integer + * This class implements a generic binary std::string variable.It can be used as + * a base class other binary std::string based classes (e.g., binary coded integer * or real variables). */ class Binary : public Variable @@ -51,7 +51,7 @@ class Binary : public Variable void setIth(int bit, bool value); void flip(int bit) ; int hammingDistance(Binary * other); - string toString(); + std::string toString(); int cardinality() ; double getValue(); @@ -60,7 +60,7 @@ class Binary : public Variable double getUpperBound(); protected: - vector * bits_; + std::vector * bits_; int numberOfBits_; }; diff --git a/src/encodings/variable/BinaryReal.cpp b/src/encodings/variable/BinaryReal.cpp index 3ddd493..88d34b5 100644 --- a/src/encodings/variable/BinaryReal.cpp +++ b/src/encodings/variable/BinaryReal.cpp @@ -69,7 +69,7 @@ BinaryReal::~BinaryReal() { /* do nothing */ } /** - * Decodes the real value encoded in the binary string represented + * Decodes the real value encoded in the binary std::string represented * by the BinaryReal object. The decoded value is stores in the * value_ field and can be accessed by the method * getValue. @@ -157,10 +157,10 @@ void BinaryReal::setUpperBound(double upperBound) /** - * Returns a string representing the object. + * Returns a std::string representing the object. * @return the string. */ -string BinaryReal::toString() +std::string BinaryReal::toString() { std::ostringstream ss; ss << value_; diff --git a/src/encodings/variable/BinaryReal.h b/src/encodings/variable/BinaryReal.h index e2e07e3..5c3bb6d 100644 --- a/src/encodings/variable/BinaryReal.h +++ b/src/encodings/variable/BinaryReal.h @@ -52,7 +52,7 @@ class BinaryReal : public Binary double getUpperBound(); void setLowerBound(double bound); void setUpperBound(double bound); - string toString(); + std::string toString(); private: double value_; diff --git a/src/encodings/variable/Real.cpp b/src/encodings/variable/Real.cpp index fe8263e..bf4d78c 100644 --- a/src/encodings/variable/Real.cpp +++ b/src/encodings/variable/Real.cpp @@ -135,14 +135,14 @@ void Real::setUpperBound(double bound) /** - * Returns a string representing the object + * Returns a std::string representing the object * @return The string */ -string Real::toString() +std::string Real::toString() { std::ostringstream stringStream; stringStream << value_ ; - string aux = stringStream.str() + " "; + std::string aux = stringStream.str() + " "; return aux ; } // toString diff --git a/src/experiments/Experiment.cpp b/src/experiments/Experiment.cpp index 559f080..85d5eea 100644 --- a/src/experiments/Experiment.cpp +++ b/src/experiments/Experiment.cpp @@ -37,78 +37,78 @@ void Experiment::checkExperimentDirectory() switch (res) { case 0: - cout << "Experiment directory does NOT exist. Creating" << endl; + std::cout << "Experiment directory does NOT exist. Creating" << std::endl; if (FileUtils::createDirectory(experimentBaseDirectory_) == -1) { - cout << "Error creating directory" << endl; + std::cout << "Error creating directory" << std::endl; exit(-1); } break; case 1: - cout << "Experiment directory exists." << endl; - cout << "Experiment directory is a directory" << endl; + std::cout << "Experiment directory exists." << std::endl; + std::cout << "Experiment directory is a directory" << std::endl; break; case 2: - cout << "Experiment directory exists." << endl; - cout << "Experiment directory is not a directory. Deleting file and creating directory" << endl; + std::cout << "Experiment directory exists." << std::endl; + std::cout << "Experiment directory is not a directory. Deleting file and creating directory" << std::endl; if( remove(experimentBaseDirectory_.c_str()) != 0 ) { - cout << "Error deleting file." << endl; + std::cout << "Error deleting file." << std::endl; exit(-1); } else { - cout << "File successfully deleted." << endl; + std::cout << "File successfully deleted." << std::endl; } if (FileUtils::createDirectory(experimentBaseDirectory_) == -1) { - cout << "Error creating directory" << endl; + std::cout << "Error creating directory" << std::endl; exit(-1); } break; case -1: - cout << "Error checking experiment directory" << endl; + std::cout << "Error checking experiment directory" << std::endl; exit(-1); } } // checkExperimentDirectory -void Experiment::resetFile(string file) +void Experiment::resetFile(std::string file) { int res = FileUtils::existsPath(file.c_str()); switch (res) { case 0: - cout << "File (" << file << ") does NOT exist." << endl; + std::cout << "File (" << file << ") does NOT exist." << std::endl; break; case 1: - cout << "File (" << file << ") exists." << endl; - cout << "File (" << file << ") is a directory. Deleting directory." << endl; + std::cout << "File (" << file << ") exists." << std::endl; + std::cout << "File (" << file << ") is a directory. Deleting directory." << std::endl; if( remove(file.c_str()) != 0 ) { - cout << "Error deleting directory." << endl; + std::cout << "Error deleting directory." << std::endl; exit(-1); } else { - cout << "Directory successfully deleted." << endl; + std::cout << "Directory successfully deleted." << std::endl; } break; case 2: - cout << "File (" << file << ") exists." << endl; - cout << "File (" << file << ") is a file. Deleting file." << endl; + std::cout << "File (" << file << ") exists." << std::endl; + std::cout << "File (" << file << ") is a file. Deleting file." << std::endl; if( remove(file.c_str()) != 0 ) { - cout << "Error deleting file." << endl; + std::cout << "Error deleting file." << std::endl; exit(-1); } else { - cout << "File successfully deleted." << endl; + std::cout << "File successfully deleted." << std::endl; } break; case -1: - cout << "Error checking file (" << file << ")" << endl; + std::cout << "Error checking file (" << file << ")" << std::endl; exit(-1); } } // resetFile diff --git a/src/experiments/Experiment.h b/src/experiments/Experiment.h index 7aeaeea..4528b89 100644 --- a/src/experiments/Experiment.h +++ b/src/experiments/Experiment.h @@ -28,7 +28,7 @@ #include #include -using namespace std; + /** * Abstract class representing jMetal experiments @@ -39,18 +39,18 @@ class Experiment public: - string experimentName_; - vector algorithmNameList_; // List of the names of the algorithms to + std::string experimentName_; + std::vector algorithmNameList_; // List of the names of the algorithms to // be executed - vector problemList_; // List of problems to be solved - string experimentBaseDirectory_; // Directory to store the results + std::vector problemList_; // List of problems to be solved + std::string experimentBaseDirectory_; // Directory to store the results int independentRuns_; // Number of independent runs per algorithm bool isSingleObjective_; // If this experiment is a singleObjective one or not Experiment(); void checkExperimentDirectory(); - void resetFile(string file); + void resetFile(std::string file); }; diff --git a/src/experiments/ExperimentExecution.cpp b/src/experiments/ExperimentExecution.cpp index 1c2c9fe..a6684b0 100644 --- a/src/experiments/ExperimentExecution.cpp +++ b/src/experiments/ExperimentExecution.cpp @@ -73,8 +73,8 @@ void ExperimentExecution::runExperiment(int numberOfThreads) map_["outputParetoFrontFile"] = &outputParetoFrontFile_; map_["outputParetoSetFile"] = &outputParetoSetFile_; - cout << "Initializing task list..." << endl; - //cout << "algorithmNameList_.size() = " << algorithmNameList_.size() << endl; + std::cout << "Initializing task list..." << std::endl; + //std::cout << "algorithmNameList_.size() = " << algorithmNameList_.size() << std::endl; experimentIndividualListSize_ = problemList_.size() * algorithmNameList_.size() * independentRuns_; @@ -92,7 +92,7 @@ void ExperimentExecution::runExperiment(int numberOfThreads) algorithmSettingsList_ = snew Settings*[experimentIndividualList_.size()]; - cout << "Task list initialized." << endl; + std::cout << "Task list initialized." << std::endl; int result; @@ -104,11 +104,11 @@ void ExperimentExecution::runExperiment(int numberOfThreads) // exit(-1) ; // } // else -// cout << "------- MUTEX OK ------" << endl ; +// std::cout << "------- MUTEX OK ------" << std::endl ; //pthread_t * p = new pthread_t[numberOfThreads]; //thread * p = new thread[numberOfThreads]; - vector threads; + std::vector threads; RunExperiment ** experiments_ = snew RunExperiment*[numberOfThreads]; for (int i = 0; i < numberOfThreads; i++) { @@ -124,7 +124,7 @@ void ExperimentExecution::runExperiment(int numberOfThreads) // for (int i = 0; i < numberOfThreads; i++) { // result = pthread_join(p[i], nullptr) ; -// cout << "Joined thread number " << (i+1) << "." < #include -using namespace std; + class ExperimentExecution : public Experiment { private: - map map_; // Map used to send experiment parameters to threads + std::map map_; // Map used to send experiment parameters to threads public: - string outputParetoFrontFile_; // Name of the file containing the output + std::string outputParetoFrontFile_; // Name of the file containing the output // Pareto front - string outputParetoSetFile_; // Name of the file containing the output Pareto + std::string outputParetoSetFile_; // Name of the file containing the output Pareto // set - vector experimentIndividualList_; + std::vector experimentIndividualList_; Settings ** algorithmSettingsList_; int experimentIndividualListIndex_; int experimentIndividualListSize_; @@ -61,10 +61,10 @@ class ExperimentExecution : public Experiment void runExperiment(); // TODO: Check different algorithmSettings configurations - // virtual void algorithmSettings(string problemName, int problemId, + // virtual void algorithmSettings(std::string problemName, int problemId, // Algorithm ** algorithm) = 0; - // virtual Algorithm * algorithmSettings(string problemName) = 0; - virtual Algorithm * algorithmSettings(string problemName, int algorithmId, + // virtual Algorithm * algorithmSettings(std::string problemName) = 0; + virtual Algorithm * algorithmSettings(std::string problemName, int algorithmId, int experimentIndividiualId) = 0; }; // ExperimentExecution diff --git a/src/experiments/ExperimentReport.cpp b/src/experiments/ExperimentReport.cpp index 71a72b2..0ca836f 100644 --- a/src/experiments/ExperimentReport.cpp +++ b/src/experiments/ExperimentReport.cpp @@ -66,19 +66,19 @@ void ExperimentReport::generateQualityIndicators() if (indicatorList_.size() > 0) { - cout << "PF file: " << paretoFrontDirectory_ << endl; + std::cout << "PF file: " << paretoFrontDirectory_ << std::endl; for (int algorithmIndex=0; algorithmIndex > solutionFront = + std::vector< std::vector > solutionFront = indicators->utils_->readFront(solutionFrontFile); qualityIndicatorFile = qualityIndicatorFile + "/FIT"; indicators->fitness(solutionFront, qualityIndicatorFile); @@ -125,19 +125,19 @@ void ExperimentReport::generateQualityIndicators() stringstream outputParetoFrontFilePath; outputParetoFrontFilePath << problemDirectory << "/FUN_" << numRun; - string solutionFrontFile = outputParetoFrontFilePath.str(); - string qualityIndicatorFile = problemDirectory; + std::string solutionFrontFile = outputParetoFrontFilePath.str(); + std::string qualityIndicatorFile = problemDirectory; double value; - cout << "ExperimentReport: Quality indicator: " << indicatorList_[indicatorIndex] << endl; + std::cout << "ExperimentReport: Quality indicator: " << indicatorList_[indicatorIndex] << std::endl; if (indicatorList_[indicatorIndex].compare("HV")==0) { Hypervolume * indicators = snew Hypervolume(); - vector< vector > solutionFront = + std::vector< std::vector > solutionFront = indicators->utils_->readFront(solutionFrontFile); - vector< vector > trueFront = + std::vector< std::vector > trueFront = indicators->utils_->readFront(paretoFrontPath); value = indicators->hypervolume(solutionFront, trueFront, trueFront[0].size()); delete indicators; @@ -146,9 +146,9 @@ void ExperimentReport::generateQualityIndicators() if (indicatorList_[indicatorIndex].compare("SPREAD")==0) { Spread * indicators = snew Spread(); - vector< vector > solutionFront = + std::vector< std::vector > solutionFront = indicators->utils_->readFront(solutionFrontFile); - vector< vector > trueFront = + std::vector< std::vector > trueFront = indicators->utils_->readFront(paretoFrontPath); value = indicators->spread(solutionFront, trueFront, trueFront[0].size()); delete indicators; @@ -157,9 +157,9 @@ void ExperimentReport::generateQualityIndicators() if (indicatorList_[indicatorIndex].compare("IGD")==0) { InvertedGenerationalDistance * indicators = snew InvertedGenerationalDistance(); - vector< vector > solutionFront = + std::vector< std::vector > solutionFront = indicators->utils_->readFront(solutionFrontFile); - vector< vector > trueFront = + std::vector< std::vector > trueFront = indicators->utils_->readFront(paretoFrontPath); value = indicators->invertedGenerationalDistance(solutionFront, trueFront, trueFront[0].size()); delete indicators; @@ -168,22 +168,22 @@ void ExperimentReport::generateQualityIndicators() if (indicatorList_[indicatorIndex].compare("EPSILON")==0) { Epsilon * indicators = snew Epsilon(); - vector< vector > solutionFront = + std::vector< std::vector > solutionFront = indicators->utils_->readFront(solutionFrontFile); - vector< vector > trueFront = + std::vector< std::vector > trueFront = indicators->utils_->readFront(paretoFrontPath); value = indicators->epsilon(solutionFront, trueFront, trueFront[0].size()); delete indicators; qualityIndicatorFile = qualityIndicatorFile + "/EPSILON"; } - cout << "ExperimentReport: Quality indicator file: " << qualityIndicatorFile << endl; + std::cout << "ExperimentReport: Quality indicator file: " << qualityIndicatorFile << std::endl; if (qualityIndicatorFile.compare(problemDirectory)!=0) { std::fstream out(qualityIndicatorFile.c_str(), std::ios::out | std::ios::app); - out << value << endl; + out << value << std::endl; out.close(); } // if @@ -200,25 +200,25 @@ void ExperimentReport::generateQualityIndicators() void ExperimentReport::generateReferenceFronts() { - string referenceFrontDirectory = experimentBaseDirectory_ + "/referenceFronts"; + std::string referenceFrontDirectory = experimentBaseDirectory_ + "/referenceFronts"; if (FileUtils::existsPath(referenceFrontDirectory.c_str()) != 1) { FileUtils::createDirectory(referenceFrontDirectory); - cout << "Creating " << referenceFrontDirectory << endl; + std::cout << "Creating " << referenceFrontDirectory << std::endl; } for (int problemIndex=0; problemIndexreadNonDominatedSolutionSet(solutionFrontFile, solutionSet); @@ -249,22 +249,22 @@ void ExperimentReport::generateReferenceFronts() void ExperimentReport::generateLatexTables() { latexDirectory_ = experimentBaseDirectory_ + "/" + latexDirectory_; - cout << "latex directory: " << latexDirectory_ << endl; + std::cout << "latex directory: " << latexDirectory_ << std::endl; - vector *** data = snew vector**[indicatorList_.size()]; + std::vector *** data = snew std::vector**[indicatorList_.size()]; for (int indicator = 0; indicator < indicatorList_.size(); indicator++) { // A data vector per problem - data[indicator] = snew vector*[problemList_.size()]; + data[indicator] = snew std::vector*[problemList_.size()]; for (int problem = 0; problem < problemList_.size(); problem++) { - data[indicator][problem] = snew vector[algorithmNameList_.size()]; + data[indicator][problem] = snew std::vector[algorithmNameList_.size()]; for (int algorithm = 0; algorithm < algorithmNameList_.size(); algorithm++) { - string directory = experimentBaseDirectory_; + std::string directory = experimentBaseDirectory_; directory += "/data/"; directory += "/" + algorithmNameList_[algorithm]; directory += "/" + problemList_[problem]; @@ -274,10 +274,10 @@ void ExperimentReport::generateLatexTables() std::ifstream in(directory.c_str()); if( !in ) { - cout << "Error trying to read quality indicator file: " << directory << endl; + std::cout << "Error trying to read quality indicator file: " << directory << std::endl; exit(-1); } // if - string aux; + std::string aux; while( getline(in, aux ) ) { data[indicator][problem][algorithm].push_back(atof(aux.c_str())); @@ -294,7 +294,7 @@ void ExperimentReport::generateLatexTables() double *** min; int *** numberOfValues; - map statValues; + std::map statValues; statValues["mean"] = 0.0; statValues["median"] = 0.0; @@ -337,23 +337,23 @@ void ExperimentReport::generateLatexTables() sort(data[indicator][problem][algorithm].begin(), data[indicator][problem][algorithm].end()); - string directory = experimentBaseDirectory_; + std::string directory = experimentBaseDirectory_; directory += "/" + algorithmNameList_[algorithm]; directory += "/" + problemList_[problem]; directory += "/" + indicatorList_[indicator]; - //cout << "----" << directory << "-----" << endl; + //std::cout << "----" << directory << "-----" << std::endl; //calculateStatistics(data[indicator][problem][algorithm], meanV, medianV, minV, maxV, stdDeviationV, iqrV); calculateStatistics(data[indicator][problem][algorithm], &statValues); /* - cout << "Mean: " << statValues["mean"] << endl; - cout << "Median : " << statValues["median"] << endl; - cout << "Std : " << statValues["stdDeviation"] << endl; - cout << "IQR : " << statValues["iqr"] << endl; - cout << "Min : " << statValues["min"] << endl; - cout << "Max : " << statValues["max"] << endl; - cout << "N_values: " << data[indicator][problem][algorithm].size() << endl; + std::cout << "Mean: " << statValues["mean"] << std::endl; + std::cout << "Median : " << statValues["median"] << std::endl; + std::cout << "Std : " << statValues["stdDeviation"] << std::endl; + std::cout << "IQR : " << statValues["iqr"] << std::endl; + std::cout << "Min : " << statValues["min"] << std::endl; + std::cout << "Max : " << statValues["max"] << std::endl; + std::cout << "N_values: " << data[indicator][problem][algorithm].size() << std::endl; */ mean[indicator][problem][algorithm] = statValues["mean"]; @@ -371,13 +371,13 @@ void ExperimentReport::generateLatexTables() { if (FileUtils::createDirectory(latexDirectory_) == -1) { - cout << "Error creating directory: " << latexDirectory_ << endl; + std::cout << "Error creating directory: " << latexDirectory_ << std::endl; exit(-1); } // if - cout << "Creating " << latexDirectory_ << " directory" << endl; + std::cout << "Creating " << latexDirectory_ << " directory" << std::endl; } // if - cout << "Experiment name: " << experimentName_ << endl; - string latexFile = latexDirectory_ + "/" + experimentName_ + ".tex"; + std::cout << "Experiment name: " << experimentName_ << std::endl; + std::string latexFile = latexDirectory_ + "/" + experimentName_ + ".tex"; printHeaderLatexCommands(latexFile); for (int i = 0; i < indicatorList_.size(); i++) { @@ -425,7 +425,7 @@ void ExperimentReport::generateLatexTables() /** * Calculates statistical values from a vector of Double objects */ -void ExperimentReport::calculateStatistics(vector vector, map * values) +void ExperimentReport::calculateStatistics(std::vector vector,std::map * values) { if (vector.size() > 0) { @@ -484,41 +484,41 @@ void ExperimentReport::calculateStatistics(vector vector, map problems, - string prefix, bool notch, ExperimentReport * experiment) +void ExperimentReport::generateRBoxplotScripts (int rows, int cols, std::vector problems, + std::string prefix, bool notch, ExperimentReport * experiment) { RBoxplot::generateScripts(rows, cols, problems, prefix, notch, this); } // generateRBoxplotScripts @@ -798,7 +798,7 @@ void ExperimentReport::generateRBoxplotScripts (int rows, int cols, vector problems, string prefix, +void ExperimentReport::generateRWilcoxonScripts(std::vector problems, std::string prefix, ExperimentReport * experiment) { RWilcoxon::generateScripts(problems, prefix, this); diff --git a/src/experiments/ExperimentReport.h b/src/experiments/ExperimentReport.h index 70f21b1..2229a31 100644 --- a/src/experiments/ExperimentReport.h +++ b/src/experiments/ExperimentReport.h @@ -46,7 +46,7 @@ #include #include -using namespace std; + /** * Abstract class generating jMetal experiments reports @@ -58,23 +58,23 @@ class ExperimentReport : public Experiment private: void generateReferenceFronts(); - void calculateStatistics(vector vector_, map * values); - void printHeaderLatexCommands(string fileName); - void printEndLatexCommands(string fileName); - void printMeanStdDev(string fileName, int indicator, double*** mean, + void calculateStatistics(std::vector vector_,std::map * values); + void printHeaderLatexCommands(std::string fileName); + void printEndLatexCommands(std::string fileName); + void printMeanStdDev(std::string fileName, int indicator, double*** mean, double*** stdDev); - void printMedianIQR(string fileName, int indicator, double*** median, + void printMedianIQR(std::string fileName, int indicator, double*** median, double*** IQR); public: - vector paretoFrontFile_; // List of the files containing the pareto + std::vector paretoFrontFile_; // List of the files containing the pareto // fronts corresponding to the problems in // problemList_ - vector indicatorList_; // List of the quality indicators to be applied - string latexDirectory_; // Directory to store the latex files - string paretoFrontDirectory_; // Directory containing the Pareto front files - map indicatorMinimize_; // To indicate whether an indicator + std::vector indicatorList_; // List of the quality indicators to be applied + std::string latexDirectory_; // Directory to store the latex files + std::string paretoFrontDirectory_; // Directory containing the Pareto front files + std::map indicatorMinimize_; // To indicate whether an indicator // is to be minimized. Hard-coded // in the constructor @@ -82,9 +82,9 @@ class ExperimentReport : public Experiment void generateQualityIndicators(); void generateLatexTables(); - void generateRBoxplotScripts(int rows, int cols, vector problems, - string prefix, bool notch, ExperimentReport * experiment); - void generateRWilcoxonScripts(vector problems, string prefix, + void generateRBoxplotScripts(int rows, int cols, std::vector problems, + std::string prefix, bool notch, ExperimentReport * experiment); + void generateRWilcoxonScripts(std::vector problems, std::string prefix, ExperimentReport * experiment); }; // ExperimentReport diff --git a/src/experiments/Settings.cpp b/src/experiments/Settings.cpp index 07cbd14..12a265f 100644 --- a/src/experiments/Settings.cpp +++ b/src/experiments/Settings.cpp @@ -45,7 +45,7 @@ Settings::~Settings() { /* do nothing */ } * * To be implemented. Missing the reflection features of Java here */ -Algorithm * Settings::configure(map settings) +Algorithm * Settings::configure(std::map settings) { return nullptr ; } // configure diff --git a/src/experiments/settings/DE_Settings.cpp b/src/experiments/settings/DE_Settings.cpp index a53b58a..4ec766f 100644 --- a/src/experiments/settings/DE_Settings.cpp +++ b/src/experiments/settings/DE_Settings.cpp @@ -41,7 +41,7 @@ DE_Settings::~DE_Settings () /** * Constructor */ -DE_Settings::DE_Settings(string problemName) +DE_Settings::DE_Settings(std::string problemName) { problemName_ = problemName ; @@ -66,14 +66,14 @@ Algorithm * DE_Settings::configure() algorithm->setInputParameter("populationSize",&populationSize_); algorithm->setInputParameter("maxEvaluations",&maxEvaluations_); - map parameters; + std::map parameters; // Crossover operator double crParameter = crParameter_; double fParameter = fParameter_; parameters["CR"] = &crParameter; parameters["F"] = &fParameter; - string deVariantParameter = deVariantParameter_; + std::string deVariantParameter = deVariantParameter_; parameters["DE_VARIANT"] = &deVariantParameter; crossover = snew DifferentialEvolutionCrossover(parameters); @@ -85,7 +85,7 @@ Algorithm * DE_Settings::configure() algorithm->addOperator("crossover",crossover); algorithm->addOperator("selection",selection); - cout << "DE algorithm initialized." << endl; + std::cout << "DE algorithm initialized." << std::endl; return algorithm ; } // configure diff --git a/src/experiments/settings/DE_Settings.h b/src/experiments/settings/DE_Settings.h index 06ed24c..da4b8d8 100644 --- a/src/experiments/settings/DE_Settings.h +++ b/src/experiments/settings/DE_Settings.h @@ -34,7 +34,7 @@ class DE_Settings : public Settings int maxEvaluations_ ; double crParameter_ ; double fParameter_ ; - string deVariantParameter_ ; + std::string deVariantParameter_ ; Algorithm * algorithm ; Operator * crossover ; // Crossover operator @@ -42,7 +42,7 @@ class DE_Settings : public Settings public: DE_Settings() ; - DE_Settings(string problemName) ; + DE_Settings(std::string problemName) ; ~DE_Settings() ; Algorithm * configure() ; diff --git a/src/experiments/settings/GDE3_Settings.cpp b/src/experiments/settings/GDE3_Settings.cpp index 92dee99..14764e2 100644 --- a/src/experiments/settings/GDE3_Settings.cpp +++ b/src/experiments/settings/GDE3_Settings.cpp @@ -45,7 +45,7 @@ GDE3_Settings::~GDE3_Settings () /** * Constructor */ -GDE3_Settings::GDE3_Settings(string problemName) +GDE3_Settings::GDE3_Settings(std::string problemName) { problemName_ = problemName ; @@ -72,7 +72,7 @@ Algorithm * GDE3_Settings::configure() algorithm->setInputParameter("maxIterations",&maxIterations_); // Mutation and Crossover for Real codification - map parameters; + std::map parameters; double CR = CR_; double F = F_; @@ -88,7 +88,7 @@ Algorithm * GDE3_Settings::configure() algorithm->addOperator("crossover",crossover); algorithm->addOperator("selection",selection); - cout << "GDE3 algorithm initialized." << endl; + std::cout << "GDE3 algorithm initialized." << std::endl; return algorithm ; diff --git a/src/experiments/settings/GDE3_Settings.h b/src/experiments/settings/GDE3_Settings.h index 2c02637..d5cfbbb 100644 --- a/src/experiments/settings/GDE3_Settings.h +++ b/src/experiments/settings/GDE3_Settings.h @@ -43,7 +43,7 @@ class GDE3_Settings : public Settings public: GDE3_Settings() ; - GDE3_Settings(string problemName) ; + GDE3_Settings(std::string problemName) ; ~GDE3_Settings() ; Algorithm * configure() ; diff --git a/src/experiments/settings/NSGAII_Settings.cpp b/src/experiments/settings/NSGAII_Settings.cpp index 6273faa..46eecfa 100644 --- a/src/experiments/settings/NSGAII_Settings.cpp +++ b/src/experiments/settings/NSGAII_Settings.cpp @@ -42,7 +42,7 @@ NSGAII_Settings::~NSGAII_Settings () /** * Constructor */ -NSGAII_Settings::NSGAII_Settings(string problemName) +NSGAII_Settings::NSGAII_Settings(std::string problemName) { problemName_ = problemName ; @@ -68,7 +68,7 @@ Algorithm * NSGAII_Settings::configure() algorithm->setInputParameter("maxEvaluations",&maxEvaluations_); // Mutation and Crossover for Real codification - map parameters; + std::map parameters; double crossoverProbability = crossoverProbability_; double crossoverDistributionIndex = crossoverDistributionIndex_ ; @@ -92,7 +92,7 @@ Algorithm * NSGAII_Settings::configure() algorithm->addOperator("mutation",mutation); algorithm->addOperator("selection",selection); - cout << "NGSAII algorithm initialized." << endl; + std::cout << "NGSAII algorithm initialized." << std::endl; return algorithm ; } // configure diff --git a/src/experiments/settings/NSGAII_Settings.h b/src/experiments/settings/NSGAII_Settings.h index e6d96d9..d0b3368 100644 --- a/src/experiments/settings/NSGAII_Settings.h +++ b/src/experiments/settings/NSGAII_Settings.h @@ -45,7 +45,7 @@ class NSGAII_Settings : public Settings public: NSGAII_Settings() ; - NSGAII_Settings(string problemName) ; + NSGAII_Settings(std::string problemName) ; ~NSGAII_Settings() ; Algorithm * configure() ; diff --git a/src/experiments/settings/PSO_Settings.cpp b/src/experiments/settings/PSO_Settings.cpp index e3c6fa0..90df0bc 100644 --- a/src/experiments/settings/PSO_Settings.cpp +++ b/src/experiments/settings/PSO_Settings.cpp @@ -44,7 +44,7 @@ PSO_Settings::~PSO_Settings () /** * Constructor */ -PSO_Settings::PSO_Settings(string problemName) +PSO_Settings::PSO_Settings(std::string problemName) { problemName_ = problemName ; @@ -70,7 +70,7 @@ Algorithm * PSO_Settings::configure() algorithm->setInputParameter("swarmSize", &swarmSize_); algorithm->setInputParameter("maxIterations", &maxIterations_); - map parameters; + std::map parameters; // Mutation operator double mutationProbability = mutationProbability_; @@ -82,7 +82,7 @@ Algorithm * PSO_Settings::configure() // Add the operators to the algorithm algorithm->addOperator("mutation",mutation); - cout << "PSO algorithm initialized." << endl; + std::cout << "PSO algorithm initialized." << std::endl; return algorithm ; diff --git a/src/experiments/settings/PSO_Settings.h b/src/experiments/settings/PSO_Settings.h index cfb2ea1..1646ae3 100644 --- a/src/experiments/settings/PSO_Settings.h +++ b/src/experiments/settings/PSO_Settings.h @@ -40,7 +40,7 @@ class PSO_Settings : public Settings public: PSO_Settings() ; - PSO_Settings(string problemName) ; + PSO_Settings(std::string problemName) ; ~PSO_Settings() ; Algorithm * configure() ; diff --git a/src/experiments/settings/SMPSO_Settings.cpp b/src/experiments/settings/SMPSO_Settings.cpp index c012d80..6c1173e 100644 --- a/src/experiments/settings/SMPSO_Settings.cpp +++ b/src/experiments/settings/SMPSO_Settings.cpp @@ -44,7 +44,7 @@ SMPSO_Settings::~SMPSO_Settings () /** * Constructor */ -SMPSO_Settings::SMPSO_Settings(string problemName) +SMPSO_Settings::SMPSO_Settings(std::string problemName) { problemName_ = problemName ; @@ -72,7 +72,7 @@ Algorithm * SMPSO_Settings::configure() algorithm->setInputParameter("maxIterations", &maxIterations_); algorithm->setInputParameter("archiveSize", &archiveSize_); - map parameters; + std::map parameters; double mutationProbability = mutationProbability_; double mutationDistributionIndex = mutationDistributionIndex_; @@ -83,7 +83,7 @@ Algorithm * SMPSO_Settings::configure() // Add the operators to the algorithm algorithm->addOperator("mutation",mutation); - cout << "SMPSO algorithm initialized." << endl; + std::cout << "SMPSO algorithm initialized." << std::endl; return algorithm ; diff --git a/src/experiments/settings/SMPSO_Settings.h b/src/experiments/settings/SMPSO_Settings.h index 2eded47..9173b66 100644 --- a/src/experiments/settings/SMPSO_Settings.h +++ b/src/experiments/settings/SMPSO_Settings.h @@ -41,7 +41,7 @@ class SMPSO_Settings : public Settings public: SMPSO_Settings() ; - SMPSO_Settings(string problemName) ; + SMPSO_Settings(std::string problemName) ; ~SMPSO_Settings() ; Algorithm * configure() ; diff --git a/src/experiments/settings/gGA_Settings.cpp b/src/experiments/settings/gGA_Settings.cpp index 7899d75..dbbcd44 100644 --- a/src/experiments/settings/gGA_Settings.cpp +++ b/src/experiments/settings/gGA_Settings.cpp @@ -42,7 +42,7 @@ gGA_Settings::~gGA_Settings () /** * Constructor */ -gGA_Settings::gGA_Settings(string problemName) +gGA_Settings::gGA_Settings(std::string problemName) { problemName_ = problemName ; @@ -68,7 +68,7 @@ Algorithm * gGA_Settings::configure() algorithm->setInputParameter("maxEvaluations",&maxEvaluations_); // Mutation and Crossover for Real codification - map parameters; + std::map parameters; double crossoverProbability = crossoverProbability_; double crossoverDistributionIndex = crossoverDistributionIndex_ ; @@ -92,7 +92,7 @@ Algorithm * gGA_Settings::configure() algorithm->addOperator("mutation",mutation); algorithm->addOperator("selection",selection); - cout << "gGA algorithm initialized." << endl; + std::cout << "gGA algorithm initialized." << std::endl; return algorithm ; } // configure diff --git a/src/experiments/settings/gGA_Settings.h b/src/experiments/settings/gGA_Settings.h index 5cb35bc..57e9843 100644 --- a/src/experiments/settings/gGA_Settings.h +++ b/src/experiments/settings/gGA_Settings.h @@ -45,7 +45,7 @@ class gGA_Settings : public Settings public: gGA_Settings() ; - gGA_Settings(string problemName) ; + gGA_Settings(std::string problemName) ; ~gGA_Settings() ; Algorithm * configure() ; diff --git a/src/experiments/settings/ssGA_Settings.cpp b/src/experiments/settings/ssGA_Settings.cpp index 572fa30..89f17f7 100644 --- a/src/experiments/settings/ssGA_Settings.cpp +++ b/src/experiments/settings/ssGA_Settings.cpp @@ -42,7 +42,7 @@ ssGA_Settings::~ssGA_Settings () /** * Constructor */ -ssGA_Settings::ssGA_Settings(string problemName) +ssGA_Settings::ssGA_Settings(std::string problemName) { problemName_ = problemName ; @@ -68,7 +68,7 @@ Algorithm * ssGA_Settings::configure() algorithm->setInputParameter("maxEvaluations",&maxEvaluations_); // Mutation and Crossover for Real codification - map parameters; + std::map parameters; double crossoverProbability = crossoverProbability_; double crossoverDistributionIndex = crossoverDistributionIndex_ ; @@ -92,7 +92,7 @@ Algorithm * ssGA_Settings::configure() algorithm->addOperator("mutation",mutation); algorithm->addOperator("selection",selection); - cout << "ssGA algorithm initialized." << endl; + std::cout << "ssGA algorithm initialized." << std::endl; return algorithm ; } // configure diff --git a/src/experiments/util/FileUtils.cpp b/src/experiments/util/FileUtils.cpp index 8614264..b2fd9bd 100644 --- a/src/experiments/util/FileUtils.cpp +++ b/src/experiments/util/FileUtils.cpp @@ -59,10 +59,10 @@ int FileUtils::existsPath(const char* path) /** * Creates a directory in the specified path */ -int FileUtils::createDirectory(string path) +int FileUtils::createDirectory(std::string path) { int res; - cout << "Creating directory: " << path << endl; + std::cout << "Creating directory: " << path << std::endl; if (path.size() > 512) res = 1; @@ -71,7 +71,7 @@ int FileUtils::createDirectory(string path) for (int i = 0; i < path.size(); i++) if (path[i] == '/' || i == path.size()-1) { - string path2 = path.substr(0, i+1); + std::string path2 = path.substr(0, i+1); #ifdef WINDOWS //res = mkdir(path2.c_str()); diff --git a/src/experiments/util/FileUtils.h b/src/experiments/util/FileUtils.h index 24843b2..c1abc72 100644 --- a/src/experiments/util/FileUtils.h +++ b/src/experiments/util/FileUtils.h @@ -36,7 +36,7 @@ //#include #endif -using namespace std; + class FileUtils { @@ -44,7 +44,7 @@ class FileUtils public: static int existsPath(const char* path); - static int createDirectory(string path); + static int createDirectory(std::string path); }; //FileUtils diff --git a/src/experiments/util/RBoxplot.cpp b/src/experiments/util/RBoxplot.cpp index fb879cb..044b24f 100644 --- a/src/experiments/util/RBoxplot.cpp +++ b/src/experiments/util/RBoxplot.cpp @@ -22,46 +22,46 @@ #include -void RBoxplot::generateScripts(int rows, int cols, vector problems, string prefix, +void RBoxplot::generateScripts(int rows, int cols, std::vector problems, std::string prefix, bool notch, ExperimentReport * experiment) { // STEP 1. Creating R output directory - string rDirectory = "R"; + std::string rDirectory = "R"; rDirectory = experiment->experimentBaseDirectory_ + "/" + rDirectory; - cout << "R : " << rDirectory << endl; + std::cout << "R : " << rDirectory << std::endl; if (FileUtils::existsPath(rDirectory.c_str()) == 0) { FileUtils::createDirectory(rDirectory); - cout << "Creating " << rDirectory << " directory" << endl; + std::cout << "Creating " << rDirectory << " directory" << std::endl; } for (int indicator = 0; indicator < experiment->indicatorList_.size(); indicator++) { - cout << "Indicator: " << experiment->indicatorList_[indicator] << endl; - string rFile = rDirectory + "/" + prefix + "." + experiment->indicatorList_[indicator] + ".Boxplot.R"; + std::cout << "Indicator: " << experiment->indicatorList_[indicator] << std::endl; + std::string rFile = rDirectory + "/" + prefix + "." + experiment->indicatorList_[indicator] + ".Boxplot.R"; std::ofstream out(rFile.c_str()); out << "postscript(\"" << prefix << "." << experiment->indicatorList_[indicator] << ".Boxplot.eps\", horizontal=FALSE, onefile=FALSE, height=8, width=12, pointsize=10)" << - endl; - //out << "resultDirectory<-\"../data/" << experimentName_ << "\"" << endl; - out << "resultDirectory<-\"../data/" << "\"" << endl; - out << "qIndicator <- function(indicator, problem)" << endl; - out << "{" << endl; + std::endl; + //out << "resultDirectory<-\"../data/" << experimentName_ << "\"" << std::endl; + out << "resultDirectory<-\"../data/" << "\"" << std::endl; + out << "qIndicator <- function(indicator, problem)" << std::endl; + out << "{" << std::endl; for (int i = 0; i < experiment->algorithmNameList_.size(); i++) { out << "file" << experiment->algorithmNameList_[i] << "<-paste(resultDirectory, \"" << - experiment->algorithmNameList_[i] << "\", sep=\"/\")" << endl; + experiment->algorithmNameList_[i] << "\", sep=\"/\")" << std::endl; out << "file" << experiment->algorithmNameList_[i] << "<-paste(file" << - experiment->algorithmNameList_[i] << ", " << "problem, sep=\"/\")" << endl; + experiment->algorithmNameList_[i] << ", " << "problem, sep=\"/\")" << std::endl; out << "file" << experiment->algorithmNameList_[i] << "<-paste(file" << - experiment->algorithmNameList_[i] << ", " << "indicator, sep=\"/\")" << endl; + experiment->algorithmNameList_[i] << ", " << "indicator, sep=\"/\")" << std::endl; out << experiment->algorithmNameList_[i] << "<-scan(" << "file" << - experiment->algorithmNameList_[i] << ")" << endl; - out << endl; + experiment->algorithmNameList_[i] << ")" << std::endl; + out << std::endl; } // for out << "algs<-c("; @@ -70,7 +70,7 @@ void RBoxplot::generateScripts(int rows, int cols, vector problems, stri out << "\"" << experiment->algorithmNameList_[i] << "\","; } // for out << "\"" << experiment->algorithmNameList_[ experiment->algorithmNameList_.size() - 1] << - "\")" << endl; + "\")" << std::endl; out << "boxplot("; for (int i = 0; i < experiment->algorithmNameList_.size(); i++) @@ -79,24 +79,24 @@ void RBoxplot::generateScripts(int rows, int cols, vector problems, stri } // for if (notch) { - out << "names=algs, notch = TRUE)" << endl; + out << "names=algs, notch = TRUE)" << std::endl; } else { - out << "names=algs, notch = FALSE)" << endl; + out << "names=algs, notch = FALSE)" << std::endl; } - out << "titulo <-paste(indicator, problem, sep=\":\")" << endl; - out << "title(main=titulo)" << endl; + out << "titulo <-paste(indicator, problem, sep=\":\")" << std::endl; + out << "title(main=titulo)" << std::endl; - out << "}" << endl; + out << "}" << std::endl; - out << "par(mfrow=c(" << rows << "," << cols << "))" << endl; + out << "par(mfrow=c(" << rows << "," << cols << "))" << std::endl; - out << "indicator<-\"" << experiment->indicatorList_[indicator] << "\"" << endl; + out << "indicator<-\"" << experiment->indicatorList_[indicator] << "\"" << std::endl; for (int i = 0; i < problems.size(); i++) { - out << "qIndicator(indicator, \"" << problems[i] << "\")" << endl; + out << "qIndicator(indicator, \"" << problems[i] << "\")" << std::endl; } out.close(); diff --git a/src/experiments/util/RBoxplot.h b/src/experiments/util/RBoxplot.h index 5f9c74c..3fca0ee 100644 --- a/src/experiments/util/RBoxplot.h +++ b/src/experiments/util/RBoxplot.h @@ -35,8 +35,8 @@ class ExperimentReport; class RBoxplot { public: - static void generateScripts(int rows, int cols, vector problems, - string prefix, bool notch, ExperimentReport * experiment); + static void generateScripts(int rows, int cols, std::vector problems, + std::string prefix, bool notch, ExperimentReport * experiment); }; #endif /* __RBOXPLOT__ */ diff --git a/src/experiments/util/RWilcoxon.cpp b/src/experiments/util/RWilcoxon.cpp index e714663..5a07661 100644 --- a/src/experiments/util/RWilcoxon.cpp +++ b/src/experiments/util/RWilcoxon.cpp @@ -23,49 +23,49 @@ #include -void RWilcoxon::generateScripts(vector problems, string prefix, ExperimentReport * experiment) +void RWilcoxon::generateScripts(std::vector problems, std::string prefix, ExperimentReport * experiment) { // STEP 1. Creating R output directory - string rDirectory = "R"; + std::string rDirectory = "R"; rDirectory = experiment->experimentBaseDirectory_ + "/" + rDirectory; - cout << "R : " << rDirectory << endl; + std::cout << "R : " << rDirectory << std::endl; if (FileUtils::existsPath(rDirectory.c_str()) == 0) { FileUtils::createDirectory(rDirectory); - cout << "Creating " << rDirectory << " directory" << endl; + std::cout << "Creating " << rDirectory << " directory" << std::endl; } for (int indicator = 0; indicator < experiment->indicatorList_.size(); indicator++) { - cout << "Indicator: " << experiment->indicatorList_[indicator] << endl; - string rFile = rDirectory + "/" + prefix + "." + experiment->indicatorList_[indicator] + ".Wilcox.R"; - string texFile = rDirectory + "/" + prefix + "." + experiment->indicatorList_[indicator] + ".Wilcox.tex"; + std::cout << "Indicator: " << experiment->indicatorList_[indicator] << std::endl; + std::string rFile = rDirectory + "/" + prefix + "." + experiment->indicatorList_[indicator] + ".Wilcox.R"; + std::string texFile = rDirectory + "/" + prefix + "." + experiment->indicatorList_[indicator] + ".Wilcox.tex"; std::ofstream out(rFile.c_str()); - string output = "write(\"\", \"" + texFile + "\",append=FALSE)"; - out << output << endl; + std::string output = "write(\"\", \"" + texFile + "\",append=FALSE)"; + out << output << std::endl; // Generate function latexHeader() - string dataDirectory = experiment->experimentBaseDirectory_ + "/data"; - out << "resultDirectory<-\"" << dataDirectory << "\"" << endl; - out << "latexHeader <- function() {" << endl; - out << " write(\"\\\\documentclass{article}\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\title{StandardStudy}\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\usepackage{amssymb}\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\author{A.J.Nebro}\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\begin{document}\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\maketitle\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\section{Tables}\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\\", \"" + texFile + "\", append=TRUE)\n}" << endl; - //out << output << endl; + std::string dataDirectory = experiment->experimentBaseDirectory_ + "/data"; + out << "resultDirectory<-\"" << dataDirectory << "\"" << std::endl; + out << "latexHeader <- function() {" << std::endl; + out << " write(\"\\\\documentclass{article}\", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " write(\"\\\\title{StandardStudy}\", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " write(\"\\\\usepackage{amssymb}\", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " write(\"\\\\author{A.J.Nebro}\", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " write(\"\\\\begin{document}\", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " write(\"\\\\maketitle\", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " write(\"\\\\section{Tables}\", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " write(\"\\\\\", \"" + texFile + "\", append=TRUE)\n}" << std::endl; + //out << output << std::endl; // Write function latexTableHeader - string latexTableLabel = ""; - string latexTabularAlignment = ""; - string latexTableFirstLine = ""; - string latexTableCaption = ""; + std::string latexTableLabel = ""; + std::string latexTabularAlignment = ""; + std::string latexTableFirstLine = ""; + std::string latexTableCaption = ""; latexTableCaption = " write(\"\\\\caption{\", \"" + texFile + "\", append=TRUE)" + "\n" + " write(problem, \"" + texFile + "\", append=TRUE)" + "\n" + @@ -85,108 +85,108 @@ void RWilcoxon::generateScripts(vector problems, string prefix, Experime latexTableFirstLine += "\\\\\\\\ \""; // Generate function latexTableHeader() - out << "latexTableHeader <- function(problem, tabularString, latexTableFirstLine) {" << endl; - out << " write(\"\\\\begin{table}\", \"" + texFile + "\", append=TRUE)" << endl; - out << latexTableCaption << endl; - out << latexTableLabel << endl; - out << " write(\"\\\\centering\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\begin{scriptsize}\", \"" + texFile + "\", append=TRUE)" << endl; - //out << " write(\"\\\\begin{tabular}{" + latexTabularAlignment + "}\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\begin{tabular}{\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(tabularString, \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"}\", \"" + texFile + "\", append=TRUE)" << endl; + out << "latexTableHeader <- function(problem, tabularString, latexTableFirstLine) {" << std::endl; + out << " write(\"\\\\begin{table}\", \"" + texFile + "\", append=TRUE)" << std::endl; + out << latexTableCaption << std::endl; + out << latexTableLabel << std::endl; + out << " write(\"\\\\centering\", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " write(\"\\\\begin{scriptsize}\", \"" + texFile + "\", append=TRUE)" << std::endl; + //out << " write(\"\\\\begin{tabular}{" + latexTabularAlignment + "}\", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " write(\"\\\\begin{tabular}{\", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " write(tabularString, \"" + texFile + "\", append=TRUE)" << std::endl; + out << " write(\"}\", \"" + texFile + "\", append=TRUE)" << std::endl; //out << latexTableFirstLine + - out << " write(latexTableFirstLine, \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\hline \", \"" + texFile + "\", append=TRUE)" + "\n" + "}" << endl; - //out << output << endl; + out << " write(latexTableFirstLine, \"" + texFile + "\", append=TRUE)" << std::endl; + out << " write(\"\\\\hline \", \"" + texFile + "\", append=TRUE)" + "\n" + "}" << std::endl; + //out << output << std::endl; // Generate function latexTableTail() - out << "latexTableTail <- function() { " << endl; - out << " write(\"\\\\hline\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\end{tabular}\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\end{scriptsize}\", \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\"\\\\end{table}\", \"" + texFile + "\", append=TRUE)" + "\n" + "}" << endl; - //out << output << endl; + out << "latexTableTail <- function() { " << std::endl; + out << " write(\"\\\\hline\", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " write(\"\\\\end{tabular}\", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " write(\"\\\\end{scriptsize}\", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " write(\"\\\\end{table}\", \"" + texFile + "\", append=TRUE)" + "\n" + "}" << std::endl; + //out << output << std::endl; // Generate function latexTail() - out << "latexTail <- function() { " << endl; - out << " write(\"\\\\end{document}\", \"" + texFile + "\", append=TRUE)" + "\n" + "}" << endl; - //out << output << endl; + out << "latexTail <- function() { " << std::endl; + out << " write(\"\\\\end{document}\", \"" + texFile + "\", append=TRUE)" + "\n" + "}" << std::endl; + //out << output << std::endl; if ((bool) experiment->indicatorMinimize_[experiment->indicatorList_[indicator]] == true) // minimize by default { // Generate function printTableLine() - out << "printTableLine <- function(indicator, algorithm1, algorithm2, i, j, problem) { " << endl; - out << " file1<-paste(resultDirectory, algorithm1, sep=\"/\")" << endl; - out << " file1<-paste(file1, problem, sep=\"/\")" << endl; - out << " file1<-paste(file1, indicator, sep=\"/\")" << endl; - out << " data1<-scan(file1)" << endl; - out << " file2<-paste(resultDirectory, algorithm2, sep=\"/\")" << endl; - out << " file2<-paste(file2, problem, sep=\"/\")" << endl; - out << " file2<-paste(file2, indicator, sep=\"/\")" << endl; - out << " data2<-scan(file2)" << endl; - out << " if (i == j) {" << endl; - out << " write(\"-- \", \"" + texFile + "\", append=TRUE)" << endl; - out << " }" << endl; - out << " else if (i < j) {" << endl; - out << " if (wilcox.test(data1, data2)$p.value <= 0.05) {" << endl; - out << " if (median(data1) <= median(data2)) {" << endl; - out << " write(\"$\\\\blacktriangle$\", \"" + texFile + "\", append=TRUE)" << endl; - out << " }" << endl; - out << " else {" << endl; - out << " write(\"$\\\\triangledown$\", \"" + texFile + "\", append=TRUE) " << endl; - out << " }" << endl; - out << " }" << endl; - out << " else {" << endl; - out << " write(\"--\", \"" + texFile + "\", append=TRUE) " << endl; - out << " }" << endl; - out << " }" << endl; - out << " else {" << endl; - out << " write(\" \", \"" + texFile + "\", append=TRUE)" << endl; - out << " }" << endl; - out << "}" << endl; + out << "printTableLine <- function(indicator, algorithm1, algorithm2, i, j, problem) { " << std::endl; + out << " file1<-paste(resultDirectory, algorithm1, sep=\"/\")" << std::endl; + out << " file1<-paste(file1, problem, sep=\"/\")" << std::endl; + out << " file1<-paste(file1, indicator, sep=\"/\")" << std::endl; + out << " data1<-scan(file1)" << std::endl; + out << " file2<-paste(resultDirectory, algorithm2, sep=\"/\")" << std::endl; + out << " file2<-paste(file2, problem, sep=\"/\")" << std::endl; + out << " file2<-paste(file2, indicator, sep=\"/\")" << std::endl; + out << " data2<-scan(file2)" << std::endl; + out << " if (i == j) {" << std::endl; + out << " write(\"-- \", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " }" << std::endl; + out << " else if (i < j) {" << std::endl; + out << " if (wilcox.test(data1, data2)$p.value <= 0.05) {" << std::endl; + out << " if (median(data1) <= median(data2)) {" << std::endl; + out << " write(\"$\\\\blacktriangle$\", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " }" << std::endl; + out << " else {" << std::endl; + out << " write(\"$\\\\triangledown$\", \"" + texFile + "\", append=TRUE) " << std::endl; + out << " }" << std::endl; + out << " }" << std::endl; + out << " else {" << std::endl; + out << " write(\"--\", \"" + texFile + "\", append=TRUE) " << std::endl; + out << " }" << std::endl; + out << " }" << std::endl; + out << " else {" << std::endl; + out << " write(\" \", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " }" << std::endl; + out << "}" << std::endl; } // if else { // Generate function printTableLine() - out << "printTableLine <- function(indicator, algorithm1, algorithm2, i, j, problem) { " << endl; - out << " file1<-paste(resultDirectory, algorithm1, sep=\"/\")" << endl; - out << " file1<-paste(file1, problem, sep=\"/\")" << endl; - out << " file1<-paste(file1, indicator, sep=\"/\")" << endl; - out << " data1<-scan(file1)" << endl; - out << " file2<-paste(resultDirectory, algorithm2, sep=\"/\")" << endl; - out << " file2<-paste(file2, problem, sep=\"/\")" << endl; - out << " file2<-paste(file2, indicator, sep=\"/\")" << endl; - out << " data2<-scan(file2)" << endl; - out << " if (i == j) {" << endl; - out << " write(\"--\", \"" + texFile + "\", append=TRUE)" << endl; - out << " }" << endl; - out << " else if (i < j) {" << endl; - out << " if (wilcox.test(data1, data2)$p.value <= 0.05) {" << endl; - out << " if (median(data1) >= median(data2)) {" << endl; - out << " write(\"$\\\\blacktriangle$\", \"" + texFile + "\", append=TRUE)" << endl; - out << " }" << endl; - out << " else {" << endl; - out << " write(\"$\\\\triangledown$\", \"" + texFile + "\", append=TRUE) " << endl; - out << " }" << endl; - out << " }" << endl; - out << " else {" << endl; - out << " write(\"--\", \"" + texFile + "\", append=TRUE) " << endl; - out << " }" << endl; - out << " }" << endl; - out << " else {" << endl; - out << " write(\" \", \"" + texFile + "\", append=TRUE)" << endl; - out << " }" << endl; - out << "}" << endl; + out << "printTableLine <- function(indicator, algorithm1, algorithm2, i, j, problem) { " << std::endl; + out << " file1<-paste(resultDirectory, algorithm1, sep=\"/\")" << std::endl; + out << " file1<-paste(file1, problem, sep=\"/\")" << std::endl; + out << " file1<-paste(file1, indicator, sep=\"/\")" << std::endl; + out << " data1<-scan(file1)" << std::endl; + out << " file2<-paste(resultDirectory, algorithm2, sep=\"/\")" << std::endl; + out << " file2<-paste(file2, problem, sep=\"/\")" << std::endl; + out << " file2<-paste(file2, indicator, sep=\"/\")" << std::endl; + out << " data2<-scan(file2)" << std::endl; + out << " if (i == j) {" << std::endl; + out << " write(\"--\", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " }" << std::endl; + out << " else if (i < j) {" << std::endl; + out << " if (wilcox.test(data1, data2)$p.value <= 0.05) {" << std::endl; + out << " if (median(data1) >= median(data2)) {" << std::endl; + out << " write(\"$\\\\blacktriangle$\", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " }" << std::endl; + out << " else {" << std::endl; + out << " write(\"$\\\\triangledown$\", \"" + texFile + "\", append=TRUE) " << std::endl; + out << " }" << std::endl; + out << " }" << std::endl; + out << " else {" << std::endl; + out << " write(\"--\", \"" + texFile + "\", append=TRUE) " << std::endl; + out << " }" << std::endl; + out << " }" << std::endl; + out << " else {" << std::endl; + out << " write(\" \", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " }" << std::endl; + out << "}" << std::endl; } - //out << output << endl; + //out << output << std::endl; // Start of the R script output = "### START OF SCRIPT "; - out << output << endl; + out << output << std::endl; - string problemList = "problemList <-c("; - string algorithmList = "algorithmList <-c("; + std::string problemList = "problemList <-c("; + std::string algorithmList = "algorithmList <-c("; for (int i = 0; i < (problems.size() - 1); i++) { @@ -205,8 +205,8 @@ void RWilcoxon::generateScripts(vector problems, string prefix, Experime { latexTabularAlignment += "c"; } // for - string tabularString = "tabularString <-c(\""+ latexTabularAlignment + "\") "; - string tableFirstLine = "latexTableFirstLine <-c(\"" + latexTableFirstLine + ") "; + std::string tabularString = "tabularString <-c(\""+ latexTabularAlignment + "\") "; + std::string tableFirstLine = "latexTableFirstLine <-c(\"" + latexTableFirstLine + ") "; output = "# Constants\n" + problemList + "\n" + @@ -214,45 +214,45 @@ void RWilcoxon::generateScripts(vector problems, string prefix, Experime tabularString + "\n" + tableFirstLine + "\n" + "indicator<-\"" + experiment->indicatorList_[indicator] + "\""; - out << output << endl; + out << output << std::endl; - out << "\n# Step 1. Writes the latex header" << endl; - out << "latexHeader()" << endl << endl;; - //out << output << endl; + out << "\n# Step 1. Writes the latex header" << std::endl; + out << "latexHeader()" << std::endl << std::endl;; + //out << output << std::endl; // Generate tables per problem - out << "# Step 2. Problem loop" << endl; - out << "for (problem in problemList) {" << endl; - out << " latexTableHeader(problem, tabularString, latexTableFirstLine)" << endl << endl; - out << " indx = 0" << endl; - out << " for (i in algorithmList) {" << endl; - out << " if (i != \"" + experiment->algorithmNameList_[experiment->algorithmNameList_.size() - 1]+ "\") {" << endl; - out << " write(i , \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\" & \", \"" + texFile + "\", append=TRUE)" << endl; - out << " jndx = 0 " << endl; - out << " for (j in algorithmList) {" << endl; - out << " if (jndx != 0) {" << endl; - out << " if (indx != jndx) {" << endl; - out << " printTableLine(indicator, i, j, indx, jndx, problem)" << endl; - out << " }" << endl; - out << " else {" << endl; - out << " write(\" \", \"" + texFile + "\", append=TRUE)" << endl; - out << " }" << endl; - out << " if (j != \"" + experiment->algorithmNameList_[experiment->algorithmNameList_.size() - 1] + "\") {" << endl; - out << " write(\" & \", \"" + texFile + "\", append=TRUE)" << endl; - out << " }" << endl; - out << " else {" << endl; - out << " write(\" \\\\\\\\ \", \"" + texFile + "\", append=TRUE)" << endl; - out << " }" << endl; - out << " }" << endl; - out << " jndx = jndx + 1" << endl; - out << " }" << endl; - out << " indx = indx + 1" << endl; - out << " }" << endl; - out << " }" << endl << endl; - out << " latexTableTail()" << endl; - out << "} # for problem" << endl; - //out << output << endl; + out << "# Step 2. Problem loop" << std::endl; + out << "for (problem in problemList) {" << std::endl; + out << " latexTableHeader(problem, tabularString, latexTableFirstLine)" << std::endl << std::endl; + out << " indx = 0" << std::endl; + out << " for (i in algorithmList) {" << std::endl; + out << " if (i != \"" + experiment->algorithmNameList_[experiment->algorithmNameList_.size() - 1]+ "\") {" << std::endl; + out << " write(i , \"" + texFile + "\", append=TRUE)" << std::endl; + out << " write(\" & \", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " jndx = 0 " << std::endl; + out << " for (j in algorithmList) {" << std::endl; + out << " if (jndx != 0) {" << std::endl; + out << " if (indx != jndx) {" << std::endl; + out << " printTableLine(indicator, i, j, indx, jndx, problem)" << std::endl; + out << " }" << std::endl; + out << " else {" << std::endl; + out << " write(\" \", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " }" << std::endl; + out << " if (j != \"" + experiment->algorithmNameList_[experiment->algorithmNameList_.size() - 1] + "\") {" << std::endl; + out << " write(\" & \", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " }" << std::endl; + out << " else {" << std::endl; + out << " write(\" \\\\\\\\ \", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " }" << std::endl; + out << " }" << std::endl; + out << " jndx = jndx + 1" << std::endl; + out << " }" << std::endl; + out << " indx = indx + 1" << std::endl; + out << " }" << std::endl; + out << " }" << std::endl << std::endl; + out << " latexTableTail()" << std::endl; + out << "} # for problem" << std::endl; + //out << output << std::endl; // Generate full table problemList = ""; @@ -282,51 +282,51 @@ void RWilcoxon::generateScripts(vector problems, string prefix, Experime latexTableFirstLine = "latexTableFirstLine <-c(\""+ latexTableFirstLine + "\") "; output = tabularString; - out << output + "\n" << endl; + out << output + "\n" << std::endl; output = latexTableFirstLine ; - out << output + "\n" << endl; + out << output + "\n" << std::endl; - out << "# Step 3. Problem loop" << endl; - out << "latexTableHeader(\"" + problemList + "\", tabularString, latexTableFirstLine)" << endl << endl; - out << "indx = 0" << endl; - out << "for (i in algorithmList) {" << endl; - out << " if (i != \"" + experiment->algorithmNameList_[experiment->algorithmNameList_.size() - 1]+ "\") {" << endl; - out << " write(i , \"" + texFile + "\", append=TRUE)" << endl; - out << " write(\" & \", \"" + texFile + "\", append=TRUE)" << endl << endl; - out << " jndx = 0" << endl; - out << " for (j in algorithmList) {" << endl; - out << " for (problem in problemList) {" << endl; - out << " if (jndx != 0) {" << endl; - out << " if (i != j) {" << endl; - out << " printTableLine(indicator, i, j, indx, jndx, problem)" << endl; - out << " }" << endl; - out << " else {" << endl; - out << " write(\" \", \"" + texFile + "\", append=TRUE)" << endl; - out << " } " << endl; - out << " if (problem == \"" + problems[problems.size() - 1] + "\") {" << endl; - out << " if (j == \"" + experiment->algorithmNameList_[experiment->algorithmNameList_.size() - 1] + "\") {" << endl; - out << " write(\" \\\\\\\\ \", \"" + texFile + "\", append=TRUE)" << endl; - out << " } " << endl; - out << " else {" << endl; - out << " write(\" & \", \"" + texFile + "\", append=TRUE)" << endl; - out << " }" << endl; - out << " }" << endl; - out << " else {" << endl; - out << " write(\"&\", \"" + texFile + "\", append=TRUE)" << endl; - out << " }" << endl; - out << " }" << endl; - out << " }" << endl; - out << " jndx = jndx + 1" << endl; - out << " }" << endl; - out << " indx = indx + 1" << endl; - out << " }" << endl; - out << "} # for algorithm" << endl << endl; - out << "latexTableTail()" << endl; - //out << output << endl; + out << "# Step 3. Problem loop" << std::endl; + out << "latexTableHeader(\"" + problemList + "\", tabularString, latexTableFirstLine)" << std::endl << std::endl; + out << "indx = 0" << std::endl; + out << "for (i in algorithmList) {" << std::endl; + out << " if (i != \"" + experiment->algorithmNameList_[experiment->algorithmNameList_.size() - 1]+ "\") {" << std::endl; + out << " write(i , \"" + texFile + "\", append=TRUE)" << std::endl; + out << " write(\" & \", \"" + texFile + "\", append=TRUE)" << std::endl << std::endl; + out << " jndx = 0" << std::endl; + out << " for (j in algorithmList) {" << std::endl; + out << " for (problem in problemList) {" << std::endl; + out << " if (jndx != 0) {" << std::endl; + out << " if (i != j) {" << std::endl; + out << " printTableLine(indicator, i, j, indx, jndx, problem)" << std::endl; + out << " }" << std::endl; + out << " else {" << std::endl; + out << " write(\" \", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " } " << std::endl; + out << " if (problem == \"" + problems[problems.size() - 1] + "\") {" << std::endl; + out << " if (j == \"" + experiment->algorithmNameList_[experiment->algorithmNameList_.size() - 1] + "\") {" << std::endl; + out << " write(\" \\\\\\\\ \", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " } " << std::endl; + out << " else {" << std::endl; + out << " write(\" & \", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " }" << std::endl; + out << " }" << std::endl; + out << " else {" << std::endl; + out << " write(\"&\", \"" + texFile + "\", append=TRUE)" << std::endl; + out << " }" << std::endl; + out << " }" << std::endl; + out << " }" << std::endl; + out << " jndx = jndx + 1" << std::endl; + out << " }" << std::endl; + out << " indx = indx + 1" << std::endl; + out << " }" << std::endl; + out << "} # for algorithm" << std::endl << std::endl; + out << "latexTableTail()" << std::endl; + //out << output << std::endl; // Generate end of file - out << "#Step 4. Writes the end of latex file " << endl; - out << "latexTail()" << endl; + out << "#Step 4. Writes the end of latex file " << std::endl; + out << "latexTail()" << std::endl; out.close(); } // for diff --git a/src/experiments/util/RWilcoxon.h b/src/experiments/util/RWilcoxon.h index 69d7b4a..9996d18 100644 --- a/src/experiments/util/RWilcoxon.h +++ b/src/experiments/util/RWilcoxon.h @@ -35,7 +35,7 @@ class ExperimentReport; class RWilcoxon { public: - static void generateScripts(vector problems, string prefix, + static void generateScripts(std::vector problems, std::string prefix, ExperimentReport * experiment); }; // RWilcoxon diff --git a/src/experiments/util/RunExperiment.cpp b/src/experiments/util/RunExperiment.cpp index 69220b1..5fc476d 100644 --- a/src/experiments/util/RunExperiment.cpp +++ b/src/experiments/util/RunExperiment.cpp @@ -31,7 +31,7 @@ /** * Constructor */ -RunExperiment::RunExperiment(ExperimentExecution * experiment, map map, +RunExperiment::RunExperiment(ExperimentExecution * experiment,std::map map, int id, int numberOfThreads, int numberOfProblems, int threadIndex, mutex * mtx) { @@ -56,24 +56,24 @@ void RunExperiment::run() Algorithm * algorithm; // jMetal algorithm to be executed - string experimentName = *(string*) map_["name"]; - cout << experimentName << endl; + std::string experimentName = *(string*) map_["name"]; + std::cout << experimentName << std::endl; experimentBaseDirectory_ = *(string*) map_["experimentDirectory"]; - cout << experimentBaseDirectory_ << endl; - algorithmNameList_ = *(vector*) map_["algorithmNameList"]; - problemList_ = *(vector*) map_["problemList"]; + std::cout << experimentBaseDirectory_ << std::endl; + algorithmNameList_ = *(std::vector*) map_["algorithmNameList"]; + problemList_ = *(std::vector*) map_["problemList"]; independentRuns_ = *(int*) map_["independentRuns"]; - cout << independentRuns_ << endl; + std::cout << independentRuns_ << std::endl; outputParetoFrontFile_ = *(string*) map_["outputParetoFrontFile"]; - cout << outputParetoFrontFile_ << endl; + std::cout << outputParetoFrontFile_ << std::endl; outputParetoSetFile_ = *(string*) map_["outputParetoSetFile"]; - cout << outputParetoSetFile_ << endl; + std::cout << outputParetoSetFile_ << std::endl; int numberOfAlgorithms = algorithmNameList_.size(); - cout << "Experiment name: " << experimentName << endl; - cout << "Experiment directory: " << experimentBaseDirectory_ << endl; - cout << "Number of threads: " << numberOfThreads_ << endl; + std::cout << "Experiment name: " << experimentName << std::endl; + std::cout << "Experiment directory: " << experimentBaseDirectory_ << std::endl; + std::cout << "Number of threads: " << numberOfThreads_ << std::endl; SolutionSet * resultFront = nullptr; @@ -89,16 +89,16 @@ void RunExperiment::run() // WAIT MUTEX // int result = pthread_mutex_lock(mutex_) ; // if (result != 0) { -// cerr << "RUNEXPERIMENT[" << threadIndex_ << "]: ERROR LOCKING THE MUTEX" << endl; +// cerr << "RUNEXPERIMENT[" << threadIndex_ << "]: ERROR LOCKING THE MUTEX" << std::endl; // exit(-1) ; // } mutex_->lock(); int experimentIndividualListIndex = experiment_->experimentIndividualListIndex_; - // cout << "Thread[" << threadIndex_ << "] experimentIndividualListIndex = " << - // experimentIndividualListIndex << endl; - // cout << "Thread[" << threadIndex_ << "] experiment_->experimentIndividualList_.size() = " << - // experiment_->experimentIndividualList_.size() << endl; + // std::cout << "Thread[" << threadIndex_ << "] experimentIndividualListIndex = " << + // experimentIndividualListIndex << std::endl; + // std::cout << "Thread[" << threadIndex_ << "] experiment_->experimentIndividualList_.size() = " << + // experiment_->experimentIndividualList_.size() << std::endl; if (experimentIndividualListIndex < experiment_->experimentIndividualList_.size()) { ExperimentIndividual * expIndv @@ -110,14 +110,14 @@ void RunExperiment::run() } else { - // cout << "Thread[" << threadIndex_ << "] is finishing." << endl; + // std::cout << "Thread[" << threadIndex_ << "] is finishing." << std::endl; end = true; } // SIGNAL MUTEX // result = pthread_mutex_unlock(mutex_) ; // if (result != 0) { -// cerr << "RUNEXPERIMENT[" << threadIndex_ << "]: ERROR UNLOCKING THE MUTEX" << endl; +// cerr << "RUNEXPERIMENT[" << threadIndex_ << "]: ERROR UNLOCKING THE MUTEX" << std::endl; // exit(-1) ; // } mutex_->unlock(); @@ -126,8 +126,8 @@ void RunExperiment::run() { Problem * problem; // The problem to solve - string problemName; - string pfFilePath = ""; + std::string problemName; + std::string pfFilePath = ""; // Get the problem from the list problemName = problemList_[problemIndex] ; @@ -140,19 +140,19 @@ void RunExperiment::run() problem = algorithm->getProblem(); // Create output directories - string directory; + std::string directory; directory = experimentBaseDirectory_ + "/data/" + algorithmNameList_[algorithmIndex] + "/" + problemList_[problemIndex]; if (FileUtils::existsPath(directory.c_str()) != 1) { FileUtils::createDirectory(directory); - cout << "Creating directory: " << directory << endl; + std::cout << "Creating directory: " << directory << std::endl; } // Run the algorithm - cout << "Thread[" << threadIndex_ << "]: Start of algorithm: " << + std::cout << "Thread[" << threadIndex_ << "]: Start of algorithm: " << algorithmNameList_[algorithmIndex] << ", problem: " << - problemList_[problemIndex] << ", run: " << numRun << endl; + problemList_[problemIndex] << ", run: " << numRun << std::endl; resultFront= algorithm->execute(); // Put the results in the output directory @@ -176,9 +176,9 @@ void RunExperiment::run() resultFront->printVariablesToFile(outputParetoSetFilePath.str(), experiment_->isSingleObjective_); - cout << "Thread[" << threadIndex_ << "]: End of algorithm: " << + std::cout << "Thread[" << threadIndex_ << "]: End of algorithm: " << algorithmNameList_[algorithmIndex] << ", problem: " << - problemList_[problemIndex] << ", run: " << numRun << endl; + problemList_[problemIndex] << ", run: " << numRun << std::endl; delete resultFront; delete experiment_->algorithmSettingsList_[experimentIndividualListIndex]; @@ -187,7 +187,7 @@ void RunExperiment::run() } // while - cout << "Thread[" << threadIndex_ << "] has finished." << endl; + std::cout << "Thread[" << threadIndex_ << "] has finished." << std::endl; } // run diff --git a/src/experiments/util/RunExperiment.h b/src/experiments/util/RunExperiment.h index bc1e1dd..c371eab 100644 --- a/src/experiments/util/RunExperiment.h +++ b/src/experiments/util/RunExperiment.h @@ -36,7 +36,7 @@ #include #include -using namespace std; + class ExperimentExecution; @@ -47,11 +47,11 @@ class RunExperiment ExperimentExecution * experiment_; int id_; - map map_; + std::map map_; int numberOfThreads_; int numberOfProblems_; - RunExperiment(ExperimentExecution * experiment, map map, int id, + RunExperiment(ExperimentExecution * experiment,std::map map, int id, int numberOfThreads, int numberOfProblems, int threadIndex, mutex * mtx); void run(); @@ -62,17 +62,17 @@ class RunExperiment mutex * mutex_; - string experimentName_; - vector algorithmNameList_; // List of the names of the algorithms to + std::string experimentName_; + std::vector algorithmNameList_; // List of the names of the algorithms to // be executed - vector problemList_; // List of problems to be solved - string experimentBaseDirectory_; // Directory to store the results - string latexDirectory_; // Directory to store the latex files - string rDirectory_; // Directory to store the generated R scripts - string paretoFrontDirectory_; // Directory containing the Pareto front files - string outputParetoFrontFile_; // Name of the file containing the output + std::vector problemList_; // List of problems to be solved + std::string experimentBaseDirectory_; // Directory to store the results + std::string latexDirectory_; // Directory to store the latex files + std::string rDirectory_; // Directory to store the generated R scripts + std::string paretoFrontDirectory_; // Directory containing the Pareto front files + std::string outputParetoFrontFile_; // Name of the file containing the output // Pareto front - string outputParetoSetFile_; // Name of the file containing the output + std::string outputParetoSetFile_; // Name of the file containing the output // Pareto set int independentRuns_; // Number of independent runs per algorithm // TODO: Settings[] algorithmSettings_; // Parameter settings of each algorithm diff --git a/src/experiments/util/Statistics.cpp b/src/experiments/util/Statistics.cpp index 829c2ba..b3290d1 100644 --- a/src/experiments/util/Statistics.cpp +++ b/src/experiments/util/Statistics.cpp @@ -31,12 +31,12 @@ * @param last index of last position to consider in the vector * @return The median */ -double Statistics::calculateMedian(vector vector_, int first, int last) +double Statistics::calculateMedian(std::vector vector_, int first, int last) { double median = 0.0; int size = last - first + 1; - // cout << "size: " << size << "first: " << first << " last: " << last << endl; + // std::cout << "size: " << size << "first: " << first << " last: " << last << std::endl; if (size % 2 != 0) { @@ -56,7 +56,7 @@ double Statistics::calculateMedian(vector vector_, int first, int last) * @param vector * @return The IQR */ -double Statistics::calculateIQR(vector vector_) +double Statistics::calculateIQR(std::vector vector_) { double q3 = 0.0; double q1 = 0.0; @@ -67,15 +67,15 @@ double Statistics::calculateIQR(vector vector_) { q3 = calculateMedian(vector_, vector_.size() / 2 + 1, vector_.size() - 1); q1 = calculateMedian(vector_, 0, vector_.size() / 2 - 1); - //cout << "Q1: [" << 0 << ", " << (vector.size()/2 - 1) << "] = " << q1 << endl; - //cout << "Q3: [" << (vector.size()/2+1) << ", " << (vector.size()-1) << "]= " << q3 << endl; + //std::cout << "Q1: [" << 0 << ", " << (vector.size()/2 - 1) << "] = " << q1 << std::endl; + //std::cout << "Q3: [" << (vector.size()/2+1) << ", " << (vector.size()-1) << "]= " << q3 << std::endl; } else { q3 = calculateMedian(vector_, vector_.size() / 2, vector_.size() - 1); q1 = calculateMedian(vector_, 0, vector_.size() / 2 - 1); - //cout << "Q1: [" << 0 << ", " << (vector.size()/2 - 1) << "] = " << q1 << endl; - //cout << "Q3: [" << (vector.size()/2) << ", " << (vector.size()-1) << "]= " << q3 << endl; + //std::cout << "Q1: [" << 0 << ", " << (vector.size()/2 - 1) << "] = " << q1 << std::endl; + //std::cout << "Q3: [" << (vector.size()/2) << ", " << (vector.size()-1) << "]= " << q3 << std::endl; } // else } // if diff --git a/src/main/OMOPSO_main.cpp b/src/main/OMOPSO_main.cpp index 0af77df..646a753 100644 --- a/src/main/OMOPSO_main.cpp +++ b/src/main/OMOPSO_main.cpp @@ -49,19 +49,19 @@ int main(int argc, char ** argv) QualityIndicator *indicators ; // Object to get quality indicators - map parameters; // Operator parameters + std::map parameters; // Operator parameters indicators = nullptr; if (argc>=2) { problem = ProblemFactory::getProblem(argc, argv); - cout << "Selected problem: " << problem->getName() << endl; + std::cout << "Selected problem: " << problem->getName() << std::endl; } else { - cout << "No problem selected." << endl; - cout << "Default problem will be used: Kursawe" << endl; + std::cout << "No problem selected." << std::endl; + std::cout << "Default problem will be used: Kursawe" << std::endl; problem = ProblemFactory::getProblem(const_cast("Kursawe")); } @@ -101,20 +101,20 @@ int main(int argc, char ** argv) secs = secs / CLOCKS_PER_SEC; // Print the results - cout << "Total execution time: " << secs << "s" << endl; - cout << "Variables values have been written to file VAR" << endl; + std::cout << "Total execution time: " << secs << "s" << std::endl; + std::cout << "Variables values have been written to file VAR" << std::endl; population->printVariablesToFile("VAR"); - cout << "Objectives values have been written to file FUN" << endl; + std::cout << "Objectives values have been written to file FUN" << std::endl; population->printObjectivesToFile("FUN"); if (indicators != nullptr) { - cout << "Quality indicators" << endl ; - cout << "Hypervolume: " << indicators->getHypervolume(population) << endl; - cout << "GD : " << indicators->getGD(population) << endl ; - cout << "IGD : " << indicators->getIGD(population) << endl ; - cout << "Spread : " << indicators->getSpread(population) << endl ; - cout << "Epsilon : " << indicators->getEpsilon(population) << endl ; + std::cout << "Quality indicators" << std::endl ; + std::cout << "Hypervolume: " << indicators->getHypervolume(population) << std::endl; + std::cout << "GD : " << indicators->getGD(population) << std::endl ; + std::cout << "IGD : " << indicators->getIGD(population) << std::endl ; + std::cout << "Spread : " << indicators->getSpread(population) << std::endl ; + std::cout << "Epsilon : " << indicators->getEpsilon(population) << std::endl ; } // if delete uniformMutation; diff --git a/src/metaheuristics/moead/MOEAD.cpp b/src/metaheuristics/moead/MOEAD.cpp index 8f811f9..d8c7e09 100644 --- a/src/metaheuristics/moead/MOEAD.cpp +++ b/src/metaheuristics/moead/MOEAD.cpp @@ -45,7 +45,7 @@ SolutionSet * MOEAD::execute() evaluations_ = 0; maxEvaluations = *(int *) getInputParameter("maxEvaluations"); populationSize_ = *(int *) getInputParameter("populationSize"); - dataDirectory_ = * (string *) getInputParameter("dataDirectory"); + dataDirectory_ = * (std::string *) getInputParameter("dataDirectory"); population_ = snew SolutionSet(populationSize_); //indArray_ = new Solution*[problem_->getNumberOfObjectives()]; @@ -71,7 +71,7 @@ SolutionSet * MOEAD::execute() // STEP 1.1. Compute euclidean distances between weight vectors and find T initUniformWeight(); //for (int i = 0; i < 300; i++) - // cout << lambda_[i][0] << " " << lambda_[i][1] << endl ; + // std::cout << lambda_[i][0] << " " << lambda_[i][1] << std::endl ; initNeighborhood(); @@ -102,7 +102,7 @@ SolutionSet * MOEAD::execute() { type = 2; // whole population } - vector p; + std::vector p; matingSelection(p, n, 2, type); // STEP 2.2. Reproduction @@ -170,22 +170,22 @@ void MOEAD::initUniformWeight() ostringstream os; os << dataDirectory_ + "/" << "W" << problem_->getNumberOfObjectives() << "D_" << populationSize_ << ".dat"; - string dataFileName; + std::string dataFileName; dataFileName = os.str(); // Open the file std::ifstream in(dataFileName.c_str()); if( !in ) { - cout << "initUniformWeight: failed when reading from file: : " << - dataFileName << endl; + std::cout << "initUniformWeight: failed when reading from file: : " << + dataFileName << std::endl; exit(-1); } // if //int numberOfObjectives = 0; int i = 0; int j = 0; - string aux; + std::string aux; while (getline(in, aux)) { istringstream iss(aux); @@ -195,13 +195,13 @@ void MOEAD::initUniformWeight() lambda_[i] = snew double[problem_->getNumberOfObjectives()]; while (iss) { - string token; + std::string token; iss >> token; if (token.compare("")!=0) { double value = atof(token.c_str()); lambda_[i][j] = value; - //cout << "lambda[" << i << "," << j << "] = " << value << endl; + //std::cout << "lambda[" << i << "," << j << "] = " << value << std::endl; j++; } // if } // while @@ -229,8 +229,8 @@ void MOEAD::initNeighborhood() problem_->getNumberOfObjectives()); //x[j] = dist_vector(population[i].namda,population[j].namda); idx[j] = j; - // cout << "x[" << j << "]: " << x[j] << ". idx[" << j << "]: " << - // idx[j] << endl ; + // std::cout << "x[" << j << "]: " << x[j] << ". idx[" << j << "]: " << + // idx[j] << std::endl ; } // for // find 'niche' nearest neighboring subproblems @@ -241,7 +241,7 @@ void MOEAD::initNeighborhood() for (int k = 0; k < T_; k++) { neighborhood_[i][k] = idx[k]; - //cout << "neg[ << i << "," << k << "]: " << neighborhood_[i][k] << endl; + //std::cout << "neg[ << i << "," << k << "]: " << neighborhood_[i][k] << std::endl; } } // for @@ -290,7 +290,7 @@ void MOEAD::initIdealPoint() /** * matingSelection */ -void MOEAD::matingSelection(vector &list, int cid, int size, int type) +void MOEAD::matingSelection(std::vector &list, int cid, int size, int type) { // list : the set of the indexes of selected mating parents @@ -457,7 +457,7 @@ double MOEAD::fitnessFunction(Solution * individual, double * lambda) } // if else { - cout << "MOEAD.fitnessFunction: unknown type " << functionType_ << endl; + std::cout << "MOEAD.fitnessFunction: unknown type " << functionType_ << std::endl; exit (EXIT_FAILURE); } return fitness; diff --git a/src/metaheuristics/moead/MOEAD.h b/src/metaheuristics/moead/MOEAD.h index 3794a19..2239edd 100644 --- a/src/metaheuristics/moead/MOEAD.h +++ b/src/metaheuristics/moead/MOEAD.h @@ -71,7 +71,7 @@ class MOEAD : public Algorithm */ int nr_; Solution ** indArray_; - string functionType_; + std::string functionType_; int evaluations_; /** * Operators @@ -79,13 +79,13 @@ class MOEAD : public Algorithm Operator * crossover_; Operator * mutation_; - string dataDirectory_; + std::string dataDirectory_; void initUniformWeight(); void initNeighborhood(); void initPopulation(); void initIdealPoint(); - void matingSelection(vector &list, int cid, int size, int type); + void matingSelection(std::vector &list, int cid, int size, int type); void updateReference(Solution * individual); void updateProblem(Solution * indiv, int id, int type); double fitnessFunction(Solution * individual, double * lambda); diff --git a/src/metaheuristics/singleObjective/cmaes/CMAES.cpp b/src/metaheuristics/singleObjective/cmaes/CMAES.cpp index d958600..7d6e0e2 100644 --- a/src/metaheuristics/singleObjective/cmaes/CMAES.cpp +++ b/src/metaheuristics/singleObjective/cmaes/CMAES.cpp @@ -64,7 +64,7 @@ SolutionSet * CMAES::execute() { if (!isFeasible(population_->get(i))) { - //cout << "RESAMPLING!" << endl; + //std::cout << "RESAMPLING!" << std::endl; population_->replace(i, resampleSingle(i)); } problem_->evaluate(population_->get(i)); @@ -72,7 +72,7 @@ SolutionSet * CMAES::execute() counteval += populationSize; storeBest(comparator); - //cout << counteval << ": " << bestSolutionEver->getObjective(0) << endl; + //std::cout << counteval << ": " << bestSolutionEver->getObjective(0) << std::endl; updateDistribution(); delete population_; @@ -483,7 +483,7 @@ void CMAES::updateDistribution() { if (diagD[i] < 0) // numerical problem? { - cerr << "CMAES::updateDistribution(): WARNING - an eigenvalue has become negative." << endl; + cerr << "CMAES::updateDistribution(): WARNING - an eigenvalue has become negative." << std::endl; counteval = maxEvaluations; //throw new JMException("Exception in CMAES.execute(): an eigenvalue has become negative.") ; } diff --git a/src/metaheuristics/singleObjective/cmaes/utils/UtilsCMAES.cpp b/src/metaheuristics/singleObjective/cmaes/utils/UtilsCMAES.cpp index e5d733c..b40215a 100644 --- a/src/metaheuristics/singleObjective/cmaes/utils/UtilsCMAES.cpp +++ b/src/metaheuristics/singleObjective/cmaes/utils/UtilsCMAES.cpp @@ -325,7 +325,7 @@ int UtilsCMAES::checkEigenSystem (int N, double ** C, double * diag, double ** Q /* compute Q diag Q^T and Q Q^T to check */ int i, j, k, res = 0; double cc, dd; - string s; + std::string s; for (i=0; i < N; ++i) for (j=0; j < N; ++j) @@ -342,15 +342,15 @@ int UtilsCMAES::checkEigenSystem (int N, double ** C, double * diag, double ** Q ostringstream stringStream; stringStream << " " << i << " " << j << " " << cc << " " << C[i>j?i:j][i>j?j:i] << " " << (cc-C[i>j?i:j][i>j?j:i]); s = stringStream.str(); - cerr << "UtilsCMAES::checkEigenSystem(): WARNING - imprecise result detected " << s << endl; + cerr << "UtilsCMAES::checkEigenSystem(): WARNING - imprecise result detected " << s << std::endl; ++res; } if (fabs(dd - (i==j?1:0)) > 1e-10) { ostringstream stringStream; - stringStream << i << " " << j << " " << dd << endl; + stringStream << i << " " << j << " " << dd << std::endl; s = stringStream.str(); - cerr << "UtilsCMAES::checkEigenSystem(): WARNING - imprecise result detected (Q not orthog.) " << s << endl; + cerr << "UtilsCMAES::checkEigenSystem(): WARNING - imprecise result detected (Q not orthog.) " << s << std::endl; ++res; } } diff --git a/src/metaheuristics/singleObjective/geneticAlgorithm/gGA.cpp b/src/metaheuristics/singleObjective/geneticAlgorithm/gGA.cpp index 0eefcfb..7877bd8 100644 --- a/src/metaheuristics/singleObjective/geneticAlgorithm/gGA.cpp +++ b/src/metaheuristics/singleObjective/geneticAlgorithm/gGA.cpp @@ -59,23 +59,23 @@ SolutionSet * gGA::execute() populationSize = *(int *) getInputParameter("populationSize"); maxEvaluations = *(int *) getInputParameter("maxEvaluations"); // TODO: indicators = (QualityIndicator) getInputParameter("indicators"); -// cout << "populationSize = " << populationSize << endl; -// cout << "maxEvaluations = " << maxEvaluations << endl; +// std::cout << "populationSize = " << populationSize << std::endl; +// std::cout << "maxEvaluations = " << maxEvaluations << std::endl; //Initialize the variables population = snew SolutionSet(populationSize); evaluations = 0; -// cout << "Poblacion inicializada con maxsize = " << population->getMaxSize() << endl; -// cout << "Poblacion inicializada con size = " << population->size() << endl; -// cout << "Problema: " << problem_->getName() << endl; +// std::cout << "Poblacion inicializada con maxsize = " << population->getMaxSize() << std::endl; +// std::cout << "Poblacion inicializada con size = " << population->size() << std::endl; +// std::cout << "Problema: " << problem_->getName() << std::endl; //Read the operators mutationOperator = operators_["mutation"]; crossoverOperator = operators_["crossover"]; selectionOperator = operators_["selection"]; -// cout << "Comienza la inicializacion de la poblacion con size " << populationSize << endl; +// std::cout << "Comienza la inicializacion de la poblacion con size " << populationSize << std::endl; // Create the initial solutionSet Solution * newSolution; @@ -88,8 +88,8 @@ SolutionSet * gGA::execute() population->add(newSolution); } //for -// cout << "gGA: Poblacion inicializada con size = " << population->size() << endl; -// cout << "gGA: Maximo de evaluaciones: " << maxEvaluations << endl; +// std::cout << "gGA: Poblacion inicializada con size = " << population->size() << std::endl; +// std::cout << "gGA: Maximo de evaluaciones: " << maxEvaluations << std::endl; // Generations while (evaluations < maxEvaluations) diff --git a/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.cpp b/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.cpp index c228da7..f733a5d 100644 --- a/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.cpp +++ b/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.cpp @@ -57,7 +57,7 @@ SolutionSet * ssGA::execute() Comparator * comparator = new ObjectiveComparator(0); // Single objective comparator Operator * findWorstSolution; - map parameters; // Operator parameters + std::map parameters; // Operator parameters parameters["comparator"] = comparator; findWorstSolution = new WorstSolutionSelection(parameters) ; diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp b/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp index b81401e..a0859ae 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp @@ -49,7 +49,7 @@ PSO::PSO(Problem *problem) : Algorithm(problem) ChVel2_ = 1.0; comparator_ = new ObjectiveComparator(0); // Single objective comparator - map parameters; // Operator parameters + std::map parameters; // Operator parameters parameters["comparator"] = comparator_; findBestSolution_ = new BestSolutionSelection(parameters); diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp index dcbec27..03b0031 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp @@ -40,7 +40,7 @@ StandardPSO2007::StandardPSO2007(Problem * problem) : Algorithm(problem) C_ = 1.0/2.0 + log(2) ; //1.193; comparator_ = new ObjectiveComparator(0) ; // Single objective comparator - map parameters ; // Operator parameters + std::map parameters ; // Operator parameters parameters["comparator"] = comparator_; findBestSolution_ = new BestSolutionSelection(parameters) ; @@ -80,7 +80,7 @@ void StandardPSO2007::initParams() maxIterations_ = *(int *) getInputParameter("maxIterations"); numberOfParticlesToInform_ = *(int *) getInputParameter("numberOfParticlesToInform"); - cout << "Swarm size: " << swarmSize_ << endl; + std::cout << "Swarm size: " << swarmSize_ << std::endl; iteration_ = 0; @@ -212,9 +212,9 @@ SolutionSet * StandardPSO2007::execute() neighborhood_ = new AdaptiveRandomNeighborhood(swarm_, numberOfParticlesToInform_) ; - cout << "SwarmSize: " << swarmSize_ << endl; - cout << "Swarm size: " << swarm_->size() << endl; - cout << "list size: " << neighborhood_->getNeighborhood().size() << endl; + std::cout << "SwarmSize: " << swarmSize_ << std::endl; + std::cout << "Swarm size: " << swarm_->size() << std::endl; + std::cout << "list size: " << neighborhood_->getNeighborhood().size() << std::endl; //-> Step2. Initialize the speed_ of each particle for (int i = 0; i < swarmSize_; i++) @@ -241,25 +241,25 @@ SolutionSet * StandardPSO2007::execute() neighborhoodBest_[i] = getNeighborBest(i) ; } - //cout << "neighborhood_i " << neighborhood_->getNeighbors(0) << endl; - cout << "["; + //std::cout << "neighborhood_i " << neighborhood_->getNeighbors(0) << std::endl; + std::cout << "["; for (int i = 0; i < neighborhood_->getNeighbors(0).size()-1; i++) { - cout << neighborhood_->getNeighbors(0).at(i) << ","; + std::cout << neighborhood_->getNeighbors(0).at(i) << ","; } - cout << neighborhood_->getNeighbors(0).back() << "]" << endl; + std::cout << neighborhood_->getNeighbors(0).back() << "]" << std::endl; for (int s : neighborhood_->getNeighbors(0)) { - cout << s << ": " << localBest_[s]->getObjective(0) << endl; + std::cout << s << ": " << localBest_[s]->getObjective(0) << std::endl; } - cout << "localBest_i " << localBest_[0]->getObjective(0) << endl; - cout << "neighborhoodBest_i " << getNeighborBest(0)->getObjective(0) << endl; + std::cout << "localBest_i " << localBest_[0]->getObjective(0) << std::endl; + std::cout << "neighborhoodBest_i " << getNeighborBest(0)->getObjective(0) << std::endl; - cout << "Swarm: " << swarm_ << endl; + std::cout << "Swarm: " << swarm_ << std::endl; swarm_->printObjectives(); double b = swarm_->best(comparator_)->getObjective(0) ; - cout << "Best: " << b << endl; + std::cout << "Best: " << b << std::endl; double bestFoundFitness = numeric_limits::max(); @@ -298,11 +298,11 @@ SolutionSet * StandardPSO2007::execute() //System.out.println("Swarm( " + iteration_+ "): " + swarm_) ; //swarm_.printObjectives(); double bestCurrentFitness = swarm_->best(comparator_)->getObjective(0) ; - cout << "Best: " << bestCurrentFitness << endl; + std::cout << "Best: " << bestCurrentFitness << std::endl; if (bestCurrentFitness == bestFoundFitness) { - cout << "Recomputing" << endl; + std::cout << "Recomputing" << std::endl; neighborhood_->recompute(); } diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp index a6732f1..a398f0f 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp @@ -41,7 +41,7 @@ StandardPSO2011::StandardPSO2011(Problem * problem) : Algorithm(problem) ChVel_ = -0.5 ; comparator_ = new ObjectiveComparator(0) ; // Single objective comparator - map parameters ; // Operator parameters + std::map parameters ; // Operator parameters parameters["comparator"] = comparator_; findBestSolution_ = new BestSolutionSelection(parameters) ; @@ -81,7 +81,7 @@ void StandardPSO2011::initParams() maxIterations_ = *(int *) getInputParameter("maxIterations"); numberOfParticlesToInform_ = *(int *) getInputParameter("numberOfParticlesToInform"); - cout << "Swarm size: " << swarmSize_ << endl; + std::cout << "Swarm size: " << swarmSize_ << std::endl; iteration_ = 0; @@ -238,9 +238,9 @@ SolutionSet * StandardPSO2011::execute() neighborhood_ = new AdaptiveRandomNeighborhood(swarm_, numberOfParticlesToInform_) ; - cout << "SwarmSize: " << swarmSize_ << endl; - cout << "Swarm size: " << swarm_->size() << endl; - cout << "list size: " << neighborhood_->getNeighborhood().size() << endl; + std::cout << "SwarmSize: " << swarmSize_ << std::endl; + std::cout << "Swarm size: " << swarm_->size() << std::endl; + std::cout << "list size: " << neighborhood_->getNeighborhood().size() << std::endl; //-> Step2. Initialize the speed_ of each particle for (int i = 0; i < swarmSize_; i++) @@ -268,25 +268,25 @@ SolutionSet * StandardPSO2011::execute() neighborhoodBest_[i] = getNeighborBest(i) ; } - //cout << "neighborhood_i " << neighborhood_->getNeighbors(0) << endl; - cout << "["; + //std::cout << "neighborhood_i " << neighborhood_->getNeighbors(0) << std::endl; + std::cout << "["; for (int i = 0; i < neighborhood_->getNeighbors(0).size()-1; i++) { - cout << neighborhood_->getNeighbors(0).at(i) << ","; + std::cout << neighborhood_->getNeighbors(0).at(i) << ","; } - cout << neighborhood_->getNeighbors(0).back() << "]" << endl; + std::cout << neighborhood_->getNeighbors(0).back() << "]" << std::endl; for (int s : neighborhood_->getNeighbors(0)) { - cout << s << ": " << localBest_[s]->getObjective(0) << endl; + std::cout << s << ": " << localBest_[s]->getObjective(0) << std::endl; } - cout << "localBest_i " << localBest_[0]->getObjective(0) << endl; - cout << "neighborhoodBest_i " << getNeighborBest(0)->getObjective(0) << endl; + std::cout << "localBest_i " << localBest_[0]->getObjective(0) << std::endl; + std::cout << "neighborhoodBest_i " << getNeighborBest(0)->getObjective(0) << std::endl; - cout << "Swarm: " << swarm_ << endl; + std::cout << "Swarm: " << swarm_ << std::endl; swarm_->printObjectives(); double b = swarm_->best(comparator_)->getObjective(0) ; - cout << "Best: " << b << endl; + std::cout << "Best: " << b << std::endl; double bestFoundFitness = numeric_limits::max(); @@ -325,11 +325,11 @@ SolutionSet * StandardPSO2011::execute() //System.out.println("Swarm( " + iteration_+ "): " + swarm_) ; //swarm_.printObjectives(); double bestCurrentFitness = swarm_->best(comparator_)->getObjective(0) ; - //cout << "Best: " << bestCurrentFitness << endl; + //std::cout << "Best: " << bestCurrentFitness << std::endl; if (bestCurrentFitness == bestFoundFitness) { - //cout << "Recomputing" << endl; + //std::cout << "Recomputing" << std::endl; neighborhood_->recompute(); } diff --git a/src/metaheuristics/smpso/SMPSO.h b/src/metaheuristics/smpso/SMPSO.h index a015f77..87357ed 100644 --- a/src/metaheuristics/smpso/SMPSO.h +++ b/src/metaheuristics/smpso/SMPSO.h @@ -135,8 +135,8 @@ class SMPSO : public Algorithm public: SMPSO(Problem * problem); - //TODO: SMPSO(Problem * problem, vector variables, string trueParetoFront); - //TODO: SMPSO(Problem * problem, string trueParetoFront); + //TODO: SMPSO(Problem * problem, std::vector variables, std::string trueParetoFront); + //TODO: SMPSO(Problem * problem, std::string trueParetoFront); SolutionSet * execute(); //TODO: SolutionSet * getLeader(); diff --git a/src/metaheuristics/smsemoa/FastSMSEMOA.h b/src/metaheuristics/smsemoa/FastSMSEMOA.h index 309aa7d..1ef5b54 100644 --- a/src/metaheuristics/smsemoa/FastSMSEMOA.h +++ b/src/metaheuristics/smsemoa/FastSMSEMOA.h @@ -40,7 +40,7 @@ class FastSMSEMOA : public Algorithm MetricsUtil * utils_; Hypervolume * hv_; - vector hvContributions(vector< vector > front); + std::vector hvContributions(std::vector< std::vector > front); public: diff --git a/src/metaheuristics/smsemoa/SMSEMOA.cpp b/src/metaheuristics/smsemoa/SMSEMOA.cpp index bf68d5b..061fd1a 100644 --- a/src/metaheuristics/smsemoa/SMSEMOA.cpp +++ b/src/metaheuristics/smsemoa/SMSEMOA.cpp @@ -123,7 +123,7 @@ SolutionSet * SMSEMOA::execute() evaluations++; - //cout << "Evaluations " << evaluations << endl; + //std::cout << "Evaluations " << evaluations << std::endl; delete offSpring[1]; delete[] offSpring; @@ -143,24 +143,24 @@ SolutionSet * SMSEMOA::execute() population->get(j)->setCrowdingDistance(0.0); } - //cout << "front 0 size: " << ranking->getSubfront(0)->size() << endl ; + //std::cout << "front 0 size: " << ranking->getSubfront(0)->size() << std::endl ; SolutionSet *lastFront = ranking->getSubfront(ranking->getNumberOfSubfronts() - 1); if (lastFront->size() > 1) { - vector > frontValues = lastFront->writeObjectivesToMatrix(); + std::vector > frontValues = lastFront->writeObjectivesToMatrix(); int numberOfObjectives = problem_->getNumberOfObjectives(); // STEP 1. Obtain the maximum and minimum values of the Pareto front - vector maximumValues = utils_->getMaximumValues(unionSolution->writeObjectivesToMatrix(), numberOfObjectives); - vector minimumValues = utils_->getMinimumValues(unionSolution->writeObjectivesToMatrix(), numberOfObjectives); + std::vector maximumValues = utils_->getMaximumValues(unionSolution->writeObjectivesToMatrix(), numberOfObjectives); + std::vector minimumValues = utils_->getMinimumValues(unionSolution->writeObjectivesToMatrix(), numberOfObjectives); // STEP 2. Get the normalized front - vector > normalizedFront = utils_->getNormalizedFront(frontValues, maximumValues, minimumValues); + std::vector > normalizedFront = utils_->getNormalizedFront(frontValues, maximumValues, minimumValues); // compute offsets for reference point in normalized space - vector offsets; + std::vector offsets; for (int i = 0; i < maximumValues.size(); i++) { offsets.push_back(offset / (maximumValues[i] - minimumValues[i])); @@ -168,7 +168,7 @@ SolutionSet * SMSEMOA::execute() // STEP 3. Inverse the pareto front. This is needed because the original //metric by Zitzler is for maximization problems - vector > invertedFront = utils_->invertedFront(normalizedFront); + std::vector > invertedFront = utils_->invertedFront(normalizedFront); // shift away from origin, so that boundary points also get a contribution > 0 for (int i = 0; i < invertedFront.size(); i++) { @@ -179,7 +179,7 @@ SolutionSet * SMSEMOA::execute() } // calculate contributions and sort - vector contributions = hvContributions(invertedFront); + std::vector contributions = hvContributions(invertedFront); for (int i = 0; i < contributions.size(); i++) { // contribution values are used analogously to crowding distance @@ -238,22 +238,22 @@ SolutionSet * SMSEMOA::execute() return result; } -vector SMSEMOA::hvContributions(vector< vector > front) +std::vector SMSEMOA::hvContributions(std::vector< std::vector > front) { int numberOfObjectives = problem_->getNumberOfObjectives(); - vector contributions; + std::vector contributions; double hv; double** frontSubset; - vector< vector > frontCopy; + std::vector< std::vector > frontCopy; double** totalFront = snew double*[front.size()]; for (int i = 0; i < front.size(); i++) { - frontCopy.push_back(vector()); + frontCopy.push_back(std::vector()); totalFront[i] = snew double[front[i].size()]; for (int j = 0; j < front[i].size(); j++) { @@ -267,7 +267,7 @@ vector SMSEMOA::hvContributions(vector< vector > front) for (int i = 0; i < front.size(); i++) { - vector evaluatedPoint; + std::vector evaluatedPoint; for (int j = 0; j < frontCopy[i].size(); j++) { evaluatedPoint.push_back(frontCopy[i][j]); diff --git a/src/operators/crossover/Crossover.cpp b/src/operators/crossover/Crossover.cpp index 55d96c4..4a147e9 100644 --- a/src/operators/crossover/Crossover.cpp +++ b/src/operators/crossover/Crossover.cpp @@ -22,7 +22,7 @@ #include -Crossover::Crossover(map parameters) +Crossover::Crossover(std::map parameters) : Operator(parameters) {} Crossover::~Crossover() { /* do nothing */ } diff --git a/src/operators/crossover/Crossover.h b/src/operators/crossover/Crossover.h index 4d611f4..f734330 100644 --- a/src/operators/crossover/Crossover.h +++ b/src/operators/crossover/Crossover.h @@ -33,7 +33,7 @@ class Crossover : public Operator { public: - Crossover(map parameters); + Crossover(std::map parameters); virtual ~Crossover() = 0; }; diff --git a/src/operators/crossover/DifferentialEvolutionCrossover.cpp b/src/operators/crossover/DifferentialEvolutionCrossover.cpp index 86b9080..f642cd1 100644 --- a/src/operators/crossover/DifferentialEvolutionCrossover.cpp +++ b/src/operators/crossover/DifferentialEvolutionCrossover.cpp @@ -59,13 +59,13 @@ const double DifferentialEvolutionCrossover::DEFAULT_K = 0.5; /** * DEFAULT_VARIANT defines the default DE variant */ -const string DifferentialEvolutionCrossover::DEFAULT_DE_VARIANT = "rand/1/bin"; +const std::string DifferentialEvolutionCrossover::DEFAULT_DE_VARIANT = "rand/1/bin"; /** * Constructor */ -DifferentialEvolutionCrossover::DifferentialEvolutionCrossover(map parameters) +DifferentialEvolutionCrossover::DifferentialEvolutionCrossover(std::map parameters) : Crossover(parameters) { @@ -88,7 +88,7 @@ DifferentialEvolutionCrossover::DifferentialEvolutionCrossover(map parameters); + DifferentialEvolutionCrossover(std::map parameters); void *execute(void *); protected: static const double DEFAULT_CR; static const double DEFAULT_F; static const double DEFAULT_K; - static const string DEFAULT_DE_VARIANT; + static const std::string DEFAULT_DE_VARIANT; private: double CR_ ; double F_ ; double K_ ; - string DE_Variant_ ; // DE variant (rand/1/bin, rand/1/exp, etc.) + std::string DE_Variant_ ; // DE variant (rand/1/bin, rand/1/exp, etc.) //TODO: A�adir VALID_TYPES; }; diff --git a/src/operators/crossover/HUXCrossover.cpp b/src/operators/crossover/HUXCrossover.cpp index 11b48f4..d3f2141 100644 --- a/src/operators/crossover/HUXCrossover.cpp +++ b/src/operators/crossover/HUXCrossover.cpp @@ -27,7 +27,7 @@ * Create a new SBX crossover operator whit a default * index given by DEFAULT_INDEX_CROSSOVER */ -HUXCrossover::HUXCrossover(map parameters) +HUXCrossover::HUXCrossover(std::map parameters) : Crossover(parameters) { crossoverProbability_ = 0.0 ; @@ -51,7 +51,7 @@ Solution ** HUXCrossover::doCrossover(double probability, Solution *parent1, Sol if (offSpring == nullptr) { - cout << "Error grave: Impossible reserve memory for allocating new solutions when performing SinglePointCrossover " << endl; + std::cout << "Error grave: Impossible reserve memory for allocating new solutions when performing SinglePointCrossover " << std::endl; exit(-1); } diff --git a/src/operators/crossover/HUXCrossover.h b/src/operators/crossover/HUXCrossover.h index 0f2aff3..4a0fdbf 100644 --- a/src/operators/crossover/HUXCrossover.h +++ b/src/operators/crossover/HUXCrossover.h @@ -33,7 +33,7 @@ class HUXCrossover : public Crossover { public: - HUXCrossover(map parameters); + HUXCrossover(std::map parameters); void *execute(void *); private: diff --git a/src/operators/crossover/SBXCrossover.cpp b/src/operators/crossover/SBXCrossover.cpp index fde1da7..6e7d462 100644 --- a/src/operators/crossover/SBXCrossover.cpp +++ b/src/operators/crossover/SBXCrossover.cpp @@ -38,7 +38,7 @@ const double SBXCrossover::ETA_C_DEFAULT_ = 20.0; * Create a new SBX crossover operator whit a default * index given by DEFAULT_INDEX_CROSSOVER */ -SBXCrossover::SBXCrossover(map parameters) +SBXCrossover::SBXCrossover(std::map parameters) : Crossover(parameters) { //TODO: crossoverProbability_ = nullptr; @@ -70,18 +70,18 @@ Solution ** SBXCrossover::doCrossover(double probability, Solution *parent1, Sol if (offSpring == nullptr) { - cout << "Error grave: Impossible reserve memory for allocating new solutions when performing SBXCrossover " << endl; + std::cout << "Error grave: Impossible reserve memory for allocating new solutions when performing SBXCrossover " << std::endl; exit(-1); } -// cout << "SBXCrossover: AggregativeValue de parent1 = " << parent1->getAggregativeValue() << endl; -// cout << "SBXCrossover: AggregativeValue de parent2 = " << parent2->getAggregativeValue() << endl; +// std::cout << "SBXCrossover: AggregativeValue de parent1 = " << parent1->getAggregativeValue() << std::endl; +// std::cout << "SBXCrossover: AggregativeValue de parent2 = " << parent2->getAggregativeValue() << std::endl; offSpring[0] = new Solution(parent1); offSpring[1] = new Solution(parent2); -// cout << "SBXCrossover: AggregativeValue de offSpring[0] = " << offSpring[0]->getAggregativeValue() << endl; -// cout << "SBXCrossover: AggregativeValue de offSpring[1] = " << offSpring[1]->getAggregativeValue() << endl; +// std::cout << "SBXCrossover: AggregativeValue de offSpring[0] = " << offSpring[0]->getAggregativeValue() << std::endl; +// std::cout << "SBXCrossover: AggregativeValue de offSpring[1] = " << offSpring[1]->getAggregativeValue() << std::endl; int i; double rand; @@ -122,7 +122,7 @@ Solution ** SBXCrossover::doCrossover(double probability, Solution *parent1, Sol yL = x1->getLowerBound(i); yu = x1->getUpperBound(i); - //cout << yL << " " << yu << endl; + //std::cout << yL << " " << yu << std::endl; rand = PseudoRandom::randDouble(); beta = 1.0 + (2.0*(y1-yL)/(y2-y1)); diff --git a/src/operators/crossover/SBXCrossover.h b/src/operators/crossover/SBXCrossover.h index ddb6ec1..63718b3 100644 --- a/src/operators/crossover/SBXCrossover.h +++ b/src/operators/crossover/SBXCrossover.h @@ -36,7 +36,7 @@ class SBXCrossover : public Crossover { public: - SBXCrossover(map parameters); + SBXCrossover(std::map parameters); ~SBXCrossover(); void *execute(void *); diff --git a/src/operators/crossover/SinglePointCrossover.cpp b/src/operators/crossover/SinglePointCrossover.cpp index 95aedd5..c0bb4c6 100644 --- a/src/operators/crossover/SinglePointCrossover.cpp +++ b/src/operators/crossover/SinglePointCrossover.cpp @@ -33,7 +33,7 @@ * Create a new SBX crossover operator whit a default * index given by DEFAULT_INDEX_CROSSOVER */ -SinglePointCrossover::SinglePointCrossover(map parameters) +SinglePointCrossover::SinglePointCrossover(std::map parameters) : Crossover(parameters) { crossoverProbability_ = 0.0 ; @@ -57,7 +57,7 @@ Solution ** SinglePointCrossover::doCrossover(double probability, Solution *pare if (offSpring == nullptr) { - cout << "Error grave: Impossible reserve memory for allocating new solutions when performing SinglePointCrossover " << endl; + std::cout << "Error grave: Impossible reserve memory for allocating new solutions when performing SinglePointCrossover " << std::endl; exit(-1); } diff --git a/src/operators/mutation/BitFlipMutation.cpp b/src/operators/mutation/BitFlipMutation.cpp index 79f3a6c..81b21a3 100644 --- a/src/operators/mutation/BitFlipMutation.cpp +++ b/src/operators/mutation/BitFlipMutation.cpp @@ -26,7 +26,7 @@ * Constructor * Creates a new instance of the polynomial mutation operator */ -BitFlipMutation::BitFlipMutation(map parameters) +BitFlipMutation::BitFlipMutation(std::map parameters) : Mutation(parameters) { mutationProbability_ = 0.0 ; diff --git a/src/operators/mutation/BitFlipMutation.h b/src/operators/mutation/BitFlipMutation.h index 9e681d9..6a99b5d 100644 --- a/src/operators/mutation/BitFlipMutation.h +++ b/src/operators/mutation/BitFlipMutation.h @@ -36,7 +36,7 @@ class BitFlipMutation : public Mutation { public: - BitFlipMutation(map parameters); + BitFlipMutation(std::map parameters); ~BitFlipMutation(); void * execute(void *); diff --git a/src/operators/mutation/Mutation.cpp b/src/operators/mutation/Mutation.cpp index 83c5a46..8a90614 100644 --- a/src/operators/mutation/Mutation.cpp +++ b/src/operators/mutation/Mutation.cpp @@ -22,7 +22,7 @@ #include -Mutation::Mutation(map parameters) +Mutation::Mutation(std::map parameters) : Operator (parameters) {} Mutation::~Mutation() { /* do nothing */ } diff --git a/src/operators/mutation/Mutation.h b/src/operators/mutation/Mutation.h index c55f74a..40622a7 100644 --- a/src/operators/mutation/Mutation.h +++ b/src/operators/mutation/Mutation.h @@ -33,7 +33,7 @@ class Mutation : public Operator { public: - Mutation(map parameters); + Mutation(std::map parameters); virtual ~Mutation() = 0; }; diff --git a/src/operators/mutation/NonUniformMutation.cpp b/src/operators/mutation/NonUniformMutation.cpp index ff00f17..065f658 100644 --- a/src/operators/mutation/NonUniformMutation.cpp +++ b/src/operators/mutation/NonUniformMutation.cpp @@ -28,13 +28,13 @@ /** * Valid solution types to apply this operator. */ -const string NonUniformMutation::VALID_TYPES[] = {"Real", "ArrayReal"}; +const std::string NonUniformMutation::VALID_TYPES[] = {"Real", "ArrayReal"}; /** * Constructor * Creates a new instance of the non uniform mutation */ -NonUniformMutation::NonUniformMutation(map parameters) +NonUniformMutation::NonUniformMutation(std::map parameters) : Mutation(parameters) { if (parameters["probability"] != nullptr) diff --git a/src/operators/mutation/NonUniformMutation.h b/src/operators/mutation/NonUniformMutation.h index 30cf6e5..c8e681e 100644 --- a/src/operators/mutation/NonUniformMutation.h +++ b/src/operators/mutation/NonUniformMutation.h @@ -38,7 +38,7 @@ class NonUniformMutation : public Mutation /** * Valid solution types to apply this operator. */ - static const string VALID_TYPES[]; + static const std::string VALID_TYPES[]; /** * perturbation_ stores the perturbation value used in the Non Uniform @@ -78,7 +78,7 @@ class NonUniformMutation : public Mutation * Constructor. * Creates a new instance of the non uniform mutation */ - NonUniformMutation(map parameters); + NonUniformMutation(std::map parameters); /** * Executes the operation diff --git a/src/operators/mutation/PolynomialMutation.cpp b/src/operators/mutation/PolynomialMutation.cpp index 661f3b4..b2172bc 100644 --- a/src/operators/mutation/PolynomialMutation.cpp +++ b/src/operators/mutation/PolynomialMutation.cpp @@ -32,7 +32,7 @@ const double PolynomialMutation::eta_m_ = ETA_M_DEFAULT_; * Constructor * Creates a new instance of the polynomial mutation operator */ -PolynomialMutation::PolynomialMutation(map parameters) +PolynomialMutation::PolynomialMutation(std::map parameters) : Mutation(parameters) { // TODO: mutationProbability_ = nullptr; diff --git a/src/operators/mutation/PolynomialMutation.h b/src/operators/mutation/PolynomialMutation.h index c8dccdd..f2d457d 100644 --- a/src/operators/mutation/PolynomialMutation.h +++ b/src/operators/mutation/PolynomialMutation.h @@ -42,7 +42,7 @@ class PolynomialMutation : public Mutation static const double ETA_M_DEFAULT_; static const double eta_m_; - PolynomialMutation(map parameters); + PolynomialMutation(std::map parameters); ~PolynomialMutation(); void * execute(void *); diff --git a/src/operators/mutation/UniformMutation.cpp b/src/operators/mutation/UniformMutation.cpp index 69221cb..4f6ac34 100644 --- a/src/operators/mutation/UniformMutation.cpp +++ b/src/operators/mutation/UniformMutation.cpp @@ -27,13 +27,13 @@ /** * Valid solution types to apply this operator. */ -const string UniformMutation::VALID_TYPES[] = {"Real", "ArrayReal"}; +const std::string UniformMutation::VALID_TYPES[] = {"Real", "ArrayReal"}; /** * Constructor * Creates a new uniform mutation operator instance */ -UniformMutation::UniformMutation(map parameters) +UniformMutation::UniformMutation(std::map parameters) : Mutation(parameters) { if (parameters["probability"] != nullptr) diff --git a/src/operators/selection/BestSolutionSelection.cpp b/src/operators/selection/BestSolutionSelection.cpp index be4990d..f11a9d2 100644 --- a/src/operators/selection/BestSolutionSelection.cpp +++ b/src/operators/selection/BestSolutionSelection.cpp @@ -31,7 +31,7 @@ /** * Constructor */ -BestSolutionSelection::BestSolutionSelection(map parameters) +BestSolutionSelection::BestSolutionSelection(std::map parameters) : Selection(parameters) { comparator_ = nullptr; diff --git a/src/operators/selection/BestSolutionSelection.h b/src/operators/selection/BestSolutionSelection.h index 7f93dde..b777ca4 100644 --- a/src/operators/selection/BestSolutionSelection.h +++ b/src/operators/selection/BestSolutionSelection.h @@ -36,7 +36,7 @@ class BestSolutionSelection : public Selection Comparator * comparator_; public: - BestSolutionSelection(map parameters); + BestSolutionSelection(std::map parameters); void *execute(void *); }; diff --git a/src/operators/selection/BinaryTournament.cpp b/src/operators/selection/BinaryTournament.cpp index 30f21b2..20560bd 100644 --- a/src/operators/selection/BinaryTournament.cpp +++ b/src/operators/selection/BinaryTournament.cpp @@ -32,7 +32,7 @@ * Constructor * Creates a new Binary tournament operator using a BinaryTournamentComparator */ -BinaryTournament::BinaryTournament(map parameters) +BinaryTournament::BinaryTournament(std::map parameters) : Selection(parameters) { if (parameters["comparator"] != nullptr) diff --git a/src/operators/selection/BinaryTournament.h b/src/operators/selection/BinaryTournament.h index ae5c360..52e6abe 100644 --- a/src/operators/selection/BinaryTournament.h +++ b/src/operators/selection/BinaryTournament.h @@ -37,7 +37,7 @@ class BinaryTournament : public Selection Comparator * comparator_; public: - BinaryTournament(map parameters); + BinaryTournament(std::map parameters); ~BinaryTournament(); void *execute(void *); diff --git a/src/operators/selection/BinaryTournament2.cpp b/src/operators/selection/BinaryTournament2.cpp index 0636502..bb5c51d 100644 --- a/src/operators/selection/BinaryTournament2.cpp +++ b/src/operators/selection/BinaryTournament2.cpp @@ -35,7 +35,7 @@ * Creates a new instance of the Binary tournament operator (Deb's * NSGA-II implementation version) */ -BinaryTournament2::BinaryTournament2(map parameters) +BinaryTournament2::BinaryTournament2(std::map parameters) : Selection(parameters) { index_ = 0; @@ -43,8 +43,8 @@ BinaryTournament2::BinaryTournament2(map parameters) dominance_ = snew DominanceComparator(); if (dominance_ == nullptr) { - cout << "BinaryTournament::BinaryTournament: error creating comparator" ; - cout << endl ; + std::cout << "BinaryTournament::BinaryTournament: error creating comparator" ; + std::cout << std::endl ; exit(-1) ; } } diff --git a/src/operators/selection/BinaryTournament2.h b/src/operators/selection/BinaryTournament2.h index a5acfb1..3badd21 100644 --- a/src/operators/selection/BinaryTournament2.h +++ b/src/operators/selection/BinaryTournament2.h @@ -42,7 +42,7 @@ class BinaryTournament2 : public Selection int index_; public: - BinaryTournament2(map parameters); + BinaryTournament2(std::map parameters); ~BinaryTournament2(); void *execute(void *); diff --git a/src/operators/selection/DifferentialEvolutionSelection.cpp b/src/operators/selection/DifferentialEvolutionSelection.cpp index 2015b78..d98d32a 100644 --- a/src/operators/selection/DifferentialEvolutionSelection.cpp +++ b/src/operators/selection/DifferentialEvolutionSelection.cpp @@ -32,7 +32,7 @@ /** * Constructor */ -DifferentialEvolutionSelection::DifferentialEvolutionSelection(map parameters) +DifferentialEvolutionSelection::DifferentialEvolutionSelection(std::map parameters) : Selection(parameters) {} @@ -54,7 +54,7 @@ void * DifferentialEvolutionSelection::execute(void * object) if (population->size() < 4) { - cerr << "DifferentialEvolutionSelection: the population has less than four solutions" << endl; + cerr << "DifferentialEvolutionSelection: the population has less than four solutions" << std::endl; exit(-1); } diff --git a/src/operators/selection/DifferentialEvolutionSelection.h b/src/operators/selection/DifferentialEvolutionSelection.h index 23e8d67..01f95c0 100644 --- a/src/operators/selection/DifferentialEvolutionSelection.h +++ b/src/operators/selection/DifferentialEvolutionSelection.h @@ -34,7 +34,7 @@ class DifferentialEvolutionSelection : public Selection { public: - DifferentialEvolutionSelection(map parameters); + DifferentialEvolutionSelection(std::map parameters); void *execute(void *); }; diff --git a/src/operators/selection/RandomSelection.cpp b/src/operators/selection/RandomSelection.cpp index 5390098..2e36834 100755 --- a/src/operators/selection/RandomSelection.cpp +++ b/src/operators/selection/RandomSelection.cpp @@ -32,7 +32,7 @@ * Constructor * Creates a new RandomSelection operator using a BinaryTournamentComparator */ -RandomSelection::RandomSelection(map parameters): Selection(parameters) +RandomSelection::RandomSelection(std::map parameters): Selection(parameters) { } // RandomSelection diff --git a/src/operators/selection/RandomSelection.h b/src/operators/selection/RandomSelection.h index 704e787..9bc0eb8 100755 --- a/src/operators/selection/RandomSelection.h +++ b/src/operators/selection/RandomSelection.h @@ -37,7 +37,7 @@ class RandomSelection : public Selection Comparator * comparator_; public: - RandomSelection(map parameters); + RandomSelection(std::map parameters); ~RandomSelection(); void *execute(void *); diff --git a/src/operators/selection/Selection.cpp b/src/operators/selection/Selection.cpp index 0d9de76..cd0bdbe 100644 --- a/src/operators/selection/Selection.cpp +++ b/src/operators/selection/Selection.cpp @@ -22,7 +22,7 @@ #include -Selection::Selection(map parameters) +Selection::Selection(std::map parameters) : Operator(parameters) {} Selection::~Selection() { /* do nothing */ } diff --git a/src/operators/selection/Selection.h b/src/operators/selection/Selection.h index b4bf53b..79567da 100644 --- a/src/operators/selection/Selection.h +++ b/src/operators/selection/Selection.h @@ -33,7 +33,7 @@ class Selection : public Operator { public: - Selection (map parameters); + Selection (std::map parameters); virtual ~Selection() = 0; }; diff --git a/src/operators/selection/WorstSolutionSelection.cpp b/src/operators/selection/WorstSolutionSelection.cpp index 75f3256..95a68c1 100644 --- a/src/operators/selection/WorstSolutionSelection.cpp +++ b/src/operators/selection/WorstSolutionSelection.cpp @@ -31,7 +31,7 @@ /** * Constructor */ -WorstSolutionSelection::WorstSolutionSelection(map parameters) +WorstSolutionSelection::WorstSolutionSelection(std::map parameters) : Selection(parameters) { comparator_ = nullptr; diff --git a/src/problems/DTLZ/DTLZ1.cpp b/src/problems/DTLZ/DTLZ1.cpp index 0ae7cbf..a8ba843 100644 --- a/src/problems/DTLZ/DTLZ1.cpp +++ b/src/problems/DTLZ/DTLZ1.cpp @@ -22,7 +22,7 @@ const double DTLZ1::PI = 3.141592653589793; -DTLZ1::DTLZ1(string solutionType, int numberOfVariables, int numberOfObjectives) +DTLZ1::DTLZ1(std::string solutionType, int numberOfVariables, int numberOfObjectives) { numberOfVariables_ = numberOfVariables; numberOfObjectives_ = numberOfObjectives; @@ -32,14 +32,14 @@ DTLZ1::DTLZ1(string solutionType, int numberOfVariables, int numberOfObjectives) lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } @@ -54,13 +54,13 @@ DTLZ1::DTLZ1(string solutionType, int numberOfVariables, int numberOfObjectives) else if (solutionType.compare("Real") == 0) { solutionType_ = snew RealSolutionType(this) ; - //cout << "Tipo seleccionado Real" << endl; + //std::cout << "Tipo seleccionado Real" << std::endl; } else if (solutionType.compare("ArrayReal") == 0) solutionType_ = snew ArrayRealSolutionType(this) ; else { - cout << "Error: solution type " << solutionType << " invalid" << endl; + std::cout << "Error: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } diff --git a/src/problems/DTLZ/DTLZ1.h b/src/problems/DTLZ/DTLZ1.h index 4f47822..478273f 100644 --- a/src/problems/DTLZ/DTLZ1.h +++ b/src/problems/DTLZ/DTLZ1.h @@ -32,7 +32,7 @@ class DTLZ1 : public Problem { public: - DTLZ1(string solutionType, int numberOfVariables = 7, int numberOfObjectives = 3); + DTLZ1(std::string solutionType, int numberOfVariables = 7, int numberOfObjectives = 3); void evaluate(Solution *solution); virtual ~DTLZ1(); diff --git a/src/problems/DTLZ/DTLZ2.cpp b/src/problems/DTLZ/DTLZ2.cpp index 5fee5d8..429bbfd 100644 --- a/src/problems/DTLZ/DTLZ2.cpp +++ b/src/problems/DTLZ/DTLZ2.cpp @@ -22,7 +22,7 @@ const double DTLZ2::PI = 3.141592653589793; -DTLZ2::DTLZ2(string solutionType, int numberOfVariables, int numberOfObjectives) +DTLZ2::DTLZ2(std::string solutionType, int numberOfVariables, int numberOfObjectives) { numberOfVariables_ = numberOfVariables; numberOfObjectives_ = numberOfObjectives; @@ -32,14 +32,14 @@ DTLZ2::DTLZ2(string solutionType, int numberOfVariables, int numberOfObjectives) lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } @@ -54,13 +54,13 @@ DTLZ2::DTLZ2(string solutionType, int numberOfVariables, int numberOfObjectives) else if (solutionType.compare("Real") == 0) { solutionType_ = snew RealSolutionType(this) ; - //cout << "Tipo seleccionado Real" << endl; + //std::cout << "Tipo seleccionado Real" << std::endl; } else if (solutionType.compare("ArrayReal") == 0) solutionType_ = snew ArrayRealSolutionType(this) ; else { - cout << "Error: solution type " << solutionType << " invalid" << endl; + std::cout << "Error: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } diff --git a/src/problems/DTLZ/DTLZ2.h b/src/problems/DTLZ/DTLZ2.h index 7c1d4e3..69609fa 100644 --- a/src/problems/DTLZ/DTLZ2.h +++ b/src/problems/DTLZ/DTLZ2.h @@ -32,7 +32,7 @@ class DTLZ2 : public Problem { public: - DTLZ2(string solutionType, int numberOfVariables = 12, int numberOfObjectives = 3); + DTLZ2(std::string solutionType, int numberOfVariables = 12, int numberOfObjectives = 3); void evaluate(Solution *solution); virtual ~DTLZ2(); diff --git a/src/problems/DTLZ/DTLZ3.cpp b/src/problems/DTLZ/DTLZ3.cpp index f22ae56..2ea155a 100644 --- a/src/problems/DTLZ/DTLZ3.cpp +++ b/src/problems/DTLZ/DTLZ3.cpp @@ -22,7 +22,7 @@ const double DTLZ3::PI = 3.141592653589793; -DTLZ3::DTLZ3(string solutionType, int numberOfVariables, int numberOfObjectives) +DTLZ3::DTLZ3(std::string solutionType, int numberOfVariables, int numberOfObjectives) { numberOfVariables_ = numberOfVariables; numberOfObjectives_ = numberOfObjectives; @@ -32,14 +32,14 @@ DTLZ3::DTLZ3(string solutionType, int numberOfVariables, int numberOfObjectives) lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } @@ -54,13 +54,13 @@ DTLZ3::DTLZ3(string solutionType, int numberOfVariables, int numberOfObjectives) else if (solutionType.compare("Real") == 0) { solutionType_ = snew RealSolutionType(this) ; - // cout << "Tipo seleccionado Real" << endl; + // std::cout << "Tipo seleccionado Real" << std::endl; } else if (solutionType.compare("ArrayReal") == 0) solutionType_ = snew ArrayRealSolutionType(this) ; else { - cout << "Error: solution type " << solutionType << " invalid" << endl; + std::cout << "Error: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } fx_ = snew double[numberOfObjectives_] ; diff --git a/src/problems/DTLZ/DTLZ3.h b/src/problems/DTLZ/DTLZ3.h index bc884ab..657bdf1 100644 --- a/src/problems/DTLZ/DTLZ3.h +++ b/src/problems/DTLZ/DTLZ3.h @@ -32,7 +32,7 @@ class DTLZ3 : public Problem { public: - DTLZ3(string solutionType, int numberOfVariables = 12, int numberOfObjectives = 3); + DTLZ3(std::string solutionType, int numberOfVariables = 12, int numberOfObjectives = 3); void evaluate(Solution *solution); virtual ~DTLZ3(); diff --git a/src/problems/DTLZ/DTLZ4.cpp b/src/problems/DTLZ/DTLZ4.cpp index 86a8287..2edea2c 100644 --- a/src/problems/DTLZ/DTLZ4.cpp +++ b/src/problems/DTLZ/DTLZ4.cpp @@ -22,7 +22,7 @@ const double DTLZ4::PI = 3.141592653589793; -DTLZ4::DTLZ4(string solutionType, int numberOfVariables, int numberOfObjectives) +DTLZ4::DTLZ4(std::string solutionType, int numberOfVariables, int numberOfObjectives) { numberOfVariables_ = numberOfVariables; numberOfObjectives_ = numberOfObjectives; @@ -32,14 +32,14 @@ DTLZ4::DTLZ4(string solutionType, int numberOfVariables, int numberOfObjectives) lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } @@ -54,13 +54,13 @@ DTLZ4::DTLZ4(string solutionType, int numberOfVariables, int numberOfObjectives) else if (solutionType.compare("Real") == 0) { solutionType_ = snew RealSolutionType(this) ; - // cout << "Tipo seleccionado Real" << endl; + // std::cout << "Tipo seleccionado Real" << std::endl; } else if (solutionType.compare("ArrayReal") == 0) solutionType_ = snew ArrayRealSolutionType(this) ; else { - cout << "Error: solution type " << solutionType << " invalid" << endl; + std::cout << "Error: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } diff --git a/src/problems/DTLZ/DTLZ4.h b/src/problems/DTLZ/DTLZ4.h index 4ec73a5..8bb54c4 100644 --- a/src/problems/DTLZ/DTLZ4.h +++ b/src/problems/DTLZ/DTLZ4.h @@ -32,7 +32,7 @@ class DTLZ4 : public Problem { public: - DTLZ4(string solutionType, int numberOfVariables = 12, int numberOfObjectives = 3); + DTLZ4(std::string solutionType, int numberOfVariables = 12, int numberOfObjectives = 3); void evaluate(Solution *solution); virtual ~DTLZ4(); diff --git a/src/problems/DTLZ/DTLZ5.cpp b/src/problems/DTLZ/DTLZ5.cpp index cd1f768..0e4766d 100644 --- a/src/problems/DTLZ/DTLZ5.cpp +++ b/src/problems/DTLZ/DTLZ5.cpp @@ -22,7 +22,7 @@ const double DTLZ5::PI = 3.141592653589793; -DTLZ5::DTLZ5(string solutionType, int numberOfVariables, int numberOfObjectives) +DTLZ5::DTLZ5(std::string solutionType, int numberOfVariables, int numberOfObjectives) { numberOfVariables_ = numberOfVariables; numberOfObjectives_ = numberOfObjectives; @@ -32,14 +32,14 @@ DTLZ5::DTLZ5(string solutionType, int numberOfVariables, int numberOfObjectives) lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } @@ -54,13 +54,13 @@ DTLZ5::DTLZ5(string solutionType, int numberOfVariables, int numberOfObjectives) else if (solutionType.compare("Real") == 0) { solutionType_ = snew RealSolutionType(this) ; - //cout << "Tipo seleccionado Real" << endl; + //std::cout << "Tipo seleccionado Real" << std::endl; } else if (solutionType.compare("ArrayReal") == 0) solutionType_ = snew ArrayRealSolutionType(this) ; else { - cout << "Error: solution type " << solutionType << " invalid" << endl; + std::cout << "Error: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } diff --git a/src/problems/DTLZ/DTLZ5.h b/src/problems/DTLZ/DTLZ5.h index de0777d..7dac71c 100644 --- a/src/problems/DTLZ/DTLZ5.h +++ b/src/problems/DTLZ/DTLZ5.h @@ -32,7 +32,7 @@ class DTLZ5 : public Problem { public: - DTLZ5(string solutionType, int numberOfVariables = 12, int numberOfObjectives = 3); + DTLZ5(std::string solutionType, int numberOfVariables = 12, int numberOfObjectives = 3); void evaluate(Solution *solution); virtual ~DTLZ5(); diff --git a/src/problems/DTLZ/DTLZ6.cpp b/src/problems/DTLZ/DTLZ6.cpp index eab58bb..56c3bb7 100644 --- a/src/problems/DTLZ/DTLZ6.cpp +++ b/src/problems/DTLZ/DTLZ6.cpp @@ -22,7 +22,7 @@ const double DTLZ6::PI = 3.141592653589793; -DTLZ6::DTLZ6(string solutionType, int numberOfVariables, int numberOfObjectives) +DTLZ6::DTLZ6(std::string solutionType, int numberOfVariables, int numberOfObjectives) { numberOfVariables_ = numberOfVariables; numberOfObjectives_ = numberOfObjectives; @@ -32,14 +32,14 @@ DTLZ6::DTLZ6(string solutionType, int numberOfVariables, int numberOfObjectives) lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } @@ -54,13 +54,13 @@ DTLZ6::DTLZ6(string solutionType, int numberOfVariables, int numberOfObjectives) else if (solutionType.compare("Real") == 0) { solutionType_ = snew RealSolutionType(this) ; - //cout << "Tipo seleccionado Real" << endl; + //std::cout << "Tipo seleccionado Real" << std::endl; } else if (solutionType.compare("ArrayReal") == 0) solutionType_ = snew ArrayRealSolutionType(this) ; else { - cout << "Error: solution type " << solutionType << " invalid" << endl; + std::cout << "Error: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } diff --git a/src/problems/DTLZ/DTLZ6.h b/src/problems/DTLZ/DTLZ6.h index d9cabcd..8b72a7e 100644 --- a/src/problems/DTLZ/DTLZ6.h +++ b/src/problems/DTLZ/DTLZ6.h @@ -32,7 +32,7 @@ class DTLZ6 : public Problem { public: - DTLZ6(string solutionType, int numberOfVariables = 12, int numberOfObjectives = 2); + DTLZ6(std::string solutionType, int numberOfVariables = 12, int numberOfObjectives = 2); void evaluate(Solution *solution); virtual ~DTLZ6(); diff --git a/src/problems/DTLZ/DTLZ7.cpp b/src/problems/DTLZ/DTLZ7.cpp index 6f66bfa..071308d 100644 --- a/src/problems/DTLZ/DTLZ7.cpp +++ b/src/problems/DTLZ/DTLZ7.cpp @@ -22,7 +22,7 @@ const double DTLZ7::PI = 3.141592653589793; -DTLZ7::DTLZ7(string solutionType, int numberOfVariables, int numberOfObjectives) +DTLZ7::DTLZ7(std::string solutionType, int numberOfVariables, int numberOfObjectives) { numberOfVariables_ = numberOfVariables; numberOfObjectives_ = numberOfObjectives; @@ -32,14 +32,14 @@ DTLZ7::DTLZ7(string solutionType, int numberOfVariables, int numberOfObjectives) lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } @@ -54,13 +54,13 @@ DTLZ7::DTLZ7(string solutionType, int numberOfVariables, int numberOfObjectives) else if (solutionType.compare("Real") == 0) { solutionType_ = snew RealSolutionType(this) ; - //cout << "Tipo seleccionado Real" << endl; + //std::cout << "Tipo seleccionado Real" << std::endl; } else if (solutionType.compare("ArrayReal") == 0) solutionType_ = snew ArrayRealSolutionType(this) ; else { - cout << "Error: solution type " << solutionType << " invalid" << endl; + std::cout << "Error: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } diff --git a/src/problems/Fonseca.cpp b/src/problems/Fonseca.cpp index a64b017..10a3641 100644 --- a/src/problems/Fonseca.cpp +++ b/src/problems/Fonseca.cpp @@ -24,7 +24,7 @@ /** * Class constructor */ -Fonseca::Fonseca(string solutionType) +Fonseca::Fonseca(std::string solutionType) { numberOfVariables_ = 3; numberOfObjectives_ = 2; @@ -34,13 +34,13 @@ Fonseca::Fonseca(string solutionType) lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { - cout << "Fonseca::Fonseca. Error reserving memory for storing the array of lower limits" << endl; + std::cout << "Fonseca::Fonseca. Error reserving memory for storing the array of lower limits" << std::endl; } // if upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { - cout << "Fonseca::Fonseca. Error reserving memory for storing the array of upper limits" << endl; + std::cout << "Fonseca::Fonseca. Error reserving memory for storing the array of upper limits" << std::endl; exit(-1) ; } // if @@ -52,13 +52,13 @@ Fonseca::Fonseca(string solutionType) if (solutionType.compare("BinaryReal") == 0) { - //cout << "Selected solution type: BinaryReal" << endl; + //std::cout << "Selected solution type: BinaryReal" << std::endl; solutionType_ = snew BinaryRealSolutionType(this) ; } else if (solutionType.compare("Real") == 0) { solutionType_ = snew RealSolutionType(this) ; - //cout << "Selected solution type: Real" << endl; + //std::cout << "Selected solution type: Real" << std::endl; } else if (solutionType.compare("ArrayReal") == 0) { @@ -66,7 +66,7 @@ Fonseca::Fonseca(string solutionType) } else { - cout << "Error: solution type " << solutionType << " invalid" << endl; + std::cout << "Error: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } } // Fonseca @@ -95,14 +95,14 @@ void Fonseca::evaluate(Solution *solution) fx = snew double[numberOfObjectives_]; if (fx == nullptr) { - cout << "Fonseca::evaluate: Error reserving memory for the function values array" << endl; + std::cout << "Fonseca::evaluate: Error reserving memory for the function values array" << std::endl; exit(-1); } // if x = snew double[numberOfVariables_]; if (x == nullptr) { - cout << "Fonseca::evaluate: Error reserving memory for the variable values array" << endl; + std::cout << "Fonseca::evaluate: Error reserving memory for the variable values array" << std::endl; exit(-1); } // if diff --git a/src/problems/Fonseca.h b/src/problems/Fonseca.h index 0d467e8..fdaacf3 100644 --- a/src/problems/Fonseca.h +++ b/src/problems/Fonseca.h @@ -36,7 +36,7 @@ class Fonseca : public Problem { public: - Fonseca(string solutionType); + Fonseca(std::string solutionType); ~Fonseca(); void evaluate(Solution *solution); }; diff --git a/src/problems/Kursawe.cpp b/src/problems/Kursawe.cpp index 04b8976..8cdf2dd 100644 --- a/src/problems/Kursawe.cpp +++ b/src/problems/Kursawe.cpp @@ -36,7 +36,7 @@ * @param numberOfVariables Number of variables of the problem * @param solutionType The solution type must "Real", "BinaryReal, and "ArrayReal". */ -Kursawe::Kursawe(string solutionType, int numberOfVariables) +Kursawe::Kursawe(std::string solutionType, int numberOfVariables) { numberOfVariables_ = numberOfVariables; numberOfObjectives_ = 2; @@ -46,14 +46,14 @@ Kursawe::Kursawe(string solutionType, int numberOfVariables) lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } @@ -68,13 +68,13 @@ Kursawe::Kursawe(string solutionType, int numberOfVariables) else if (solutionType.compare("Real") == 0) { solutionType_ = snew RealSolutionType(this) ; - //cout << "Tipo seleccionado Real" << endl; + //std::cout << "Tipo seleccionado Real" << std::endl; } else if (solutionType.compare("ArrayReal") == 0) solutionType_ = snew ArrayRealSolutionType(this) ; else { - cout << "Error: solution type " << solutionType << " invalid" << endl; + std::cout << "Error: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } } // Kursawe @@ -104,7 +104,7 @@ void Kursawe::evaluate(Solution *solution) double * fx = snew double[2]; // function values if (fx == nullptr) { - cout << "Error grave: Impossible to reserve memory while evaluating the problem" << endl; + std::cout << "Error grave: Impossible to reserve memory while evaluating the problem" << std::endl; exit(-1); } diff --git a/src/problems/Kursawe.h b/src/problems/Kursawe.h index f230fb3..0d34a8d 100644 --- a/src/problems/Kursawe.h +++ b/src/problems/Kursawe.h @@ -31,7 +31,7 @@ #include #include -//using namespace std; +// /** * Class representing problem Kursawe @@ -40,7 +40,7 @@ class Kursawe : public Problem { public: - Kursawe(string solutionType, int numberOfVariables = 3); + Kursawe(std::string solutionType, int numberOfVariables = 3); ~Kursawe(); void evaluate(Solution *solution); }; diff --git a/src/problems/LZ09/LZ09.cpp b/src/problems/LZ09/LZ09.cpp index 1ae5e05..cbe0559 100644 --- a/src/problems/LZ09/LZ09.cpp +++ b/src/problems/LZ09/LZ09.cpp @@ -35,7 +35,7 @@ LZ09::LZ09(int nvar, int nobj, int ptype, int dtype, int ltype) /** * Alpha function */ -void LZ09::alphaFunction(double *alpha, vector * x, int dim, int type) +void LZ09::alphaFunction(double *alpha, std::vector * x, int dim, int type) { if (dim == 2) { @@ -105,7 +105,7 @@ void LZ09::alphaFunction(double *alpha, vector * x, int dim, int type) */ -double LZ09::betaFunction(vector * x, int type) +double LZ09::betaFunction(std::vector * x, int type) { double beta; @@ -263,7 +263,7 @@ double LZ09::psfunc3(double x, double t1, double t2, int dim, int type) return beta; } -void LZ09::objective(vector *x_var, vector *y_obj) +void LZ09::objective(std::vector *x_var, std::vector *y_obj) { // 2-objective case if(nobj_==2) @@ -271,8 +271,8 @@ void LZ09::objective(vector *x_var, vector *y_obj) if(ltype_==21||ltype_==22||ltype_==23||ltype_==24||ltype_==26) { double g = 0, h = 0, a, b; - vector aa ; // *aa = new vector(); - vector bb ; // *bb = new vector(); + std::vector aa ; // *aa = new vector(); + std::vector bb ; // *bb = new vector(); for(int n=1; n *x_var, vector *y_obj) { double g = 0, h = 0, a, b; double e = 0, c; - vector aa ; //= new Vector() ; - vector bb ; //= new Vector() ; + std::vector aa ; //= new Vector() ; + std::vector bb ; //= new Vector() ; for(int n=1; n *x_var, vector *y_obj) if(ltype_==31||ltype_==32) { double g = 0, h = 0, e = 0, a; - vector aa ; - vector bb ; - vector cc ; + std::vector aa ; + std::vector bb ; + std::vector cc ; for(int n=2; nat(n),x_var->at(0),x_var->at(1),n,ltype_); diff --git a/src/problems/LZ09/LZ09.h b/src/problems/LZ09/LZ09.h index bbc98ac..0d4678c 100644 --- a/src/problems/LZ09/LZ09.h +++ b/src/problems/LZ09/LZ09.h @@ -25,7 +25,7 @@ #include #include -using namespace std; + class LZ09 { @@ -38,11 +38,11 @@ class LZ09 public: LZ09 (int nvar, int nobj, int ptype, int dtype, int ltype) ; - void alphaFunction(double *alpha, vector *x, int dim, int type) ; - double betaFunction(vector * x, int type) ; + void alphaFunction(double *alpha, std::vector *x, int dim, int type) ; + double betaFunction(std::vector * x, int type) ; double psfunc2(double x, double t1, int dim, int type, int css) ; double psfunc3(double x, double t1, double t2, int dim, int type) ; - void objective(vector * x_var, vector * y_obj) ; + void objective(std::vector * x_var, std::vector * y_obj) ; }; diff --git a/src/problems/LZ09/LZ09_F1.cpp b/src/problems/LZ09/LZ09_F1.cpp index 1106de8..dea119e 100644 --- a/src/problems/LZ09/LZ09_F1.cpp +++ b/src/problems/LZ09/LZ09_F1.cpp @@ -23,7 +23,7 @@ /** * Constructor */ -LZ09_F1::LZ09_F1(string solutionType, int ptype, int dtype, int ltype) +LZ09_F1::LZ09_F1(std::string solutionType, int ptype, int dtype, int ltype) { numberOfVariables_ = 10; numberOfObjectives_ = 2; @@ -39,16 +39,16 @@ LZ09_F1::LZ09_F1(string solutionType, int ptype, int dtype, int ltype) lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { - cout << "LZ09_F1::LZ09_F1: Error reserving memory for storing the " - << "variable lower limits" << endl; + std::cout << "LZ09_F1::LZ09_F1: Error reserving memory for storing the " + << "variable lower limits" << std::endl; exit(-1); } upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { - cout << "LZ09_F1::LZ09_F1: Error reserving memory for storing the " - << "variable lower limits" << endl; + std::cout << "LZ09_F1::LZ09_F1: Error reserving memory for storing the " + << "variable lower limits" << std::endl; exit(-1); } @@ -68,7 +68,7 @@ LZ09_F1::LZ09_F1(string solutionType, int ptype, int dtype, int ltype) solutionType_ = snew ArrayRealSolutionType(this) ; else { - cout << "LZ09_F1::LZ09_F1: solution type " << solutionType << " invalid" << endl; + std::cout << "LZ09_F1::LZ09_F1: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } @@ -91,8 +91,8 @@ void LZ09_F1::evaluate(Solution * solution) { XReal * vars = snew XReal(solution); - vector * x = snew vector(numberOfVariables_) ; - vector * y = snew vector(numberOfObjectives_); + std::vector * x = snew std::vector(numberOfVariables_) ; + std::vector * y = snew std::vector(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F1.h b/src/problems/LZ09/LZ09_F1.h index df8cc59..b5e3fc7 100644 --- a/src/problems/LZ09/LZ09_F1.h +++ b/src/problems/LZ09/LZ09_F1.h @@ -34,7 +34,7 @@ class LZ09_F1 : public Problem { public: - LZ09_F1(string solutionType, int ptype=21, int dtype=1, int ltype=21); + LZ09_F1(std::string solutionType, int ptype=21, int dtype=1, int ltype=21); void evaluate(Solution *solution); virtual ~LZ09_F1(); diff --git a/src/problems/LZ09/LZ09_F2.cpp b/src/problems/LZ09/LZ09_F2.cpp index 5d14f86..14d2ad8 100644 --- a/src/problems/LZ09/LZ09_F2.cpp +++ b/src/problems/LZ09/LZ09_F2.cpp @@ -23,7 +23,7 @@ /** * Constructor */ -LZ09_F2::LZ09_F2(string solutionType, int ptype, int dtype, int ltype) +LZ09_F2::LZ09_F2(std::string solutionType, int ptype, int dtype, int ltype) { numberOfVariables_ = 30; numberOfObjectives_ = 2; @@ -39,16 +39,16 @@ LZ09_F2::LZ09_F2(string solutionType, int ptype, int dtype, int ltype) lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { - cout << "LZ09_F2::LZ09_F2: Error reserving memory for storing the " - << "variable lower limits" << endl; + std::cout << "LZ09_F2::LZ09_F2: Error reserving memory for storing the " + << "variable lower limits" << std::endl; exit(-1); } upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { - cout << "LZ09_F2::LZ09_F2: Error reserving memory for storing the " - << "variable lower limits" << endl; + std::cout << "LZ09_F2::LZ09_F2: Error reserving memory for storing the " + << "variable lower limits" << std::endl; exit(-1); } @@ -70,7 +70,7 @@ LZ09_F2::LZ09_F2(string solutionType, int ptype, int dtype, int ltype) solutionType_ = snew ArrayRealSolutionType(this) ; else { - cout << "LZ09_F2::LZ09_F2: solution type " << solutionType << " invalid" << endl; + std::cout << "LZ09_F2::LZ09_F2: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } @@ -93,8 +93,8 @@ void LZ09_F2::evaluate(Solution * solution) { XReal * vars = snew XReal(solution); - vector * x = snew vector(numberOfVariables_) ; - vector * y = snew vector(numberOfObjectives_); + std::vector * x = snew std::vector(numberOfVariables_) ; + std::vector * y = snew std::vector(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F2.h b/src/problems/LZ09/LZ09_F2.h index eeb95cd..3b84471 100644 --- a/src/problems/LZ09/LZ09_F2.h +++ b/src/problems/LZ09/LZ09_F2.h @@ -34,7 +34,7 @@ class LZ09_F2 : public Problem { public: - LZ09_F2(string solutionType, int ptype=21, int dtype=1, int ltype=22); + LZ09_F2(std::string solutionType, int ptype=21, int dtype=1, int ltype=22); void evaluate(Solution *solution); virtual ~LZ09_F2(); diff --git a/src/problems/LZ09/LZ09_F3.cpp b/src/problems/LZ09/LZ09_F3.cpp index eb32679..af5b99a 100644 --- a/src/problems/LZ09/LZ09_F3.cpp +++ b/src/problems/LZ09/LZ09_F3.cpp @@ -23,7 +23,7 @@ /** * Constructor */ -LZ09_F3::LZ09_F3(string solutionType, int ptype, int dtype, int ltype) +LZ09_F3::LZ09_F3(std::string solutionType, int ptype, int dtype, int ltype) { numberOfVariables_ = 30; numberOfObjectives_ = 2; @@ -39,16 +39,16 @@ LZ09_F3::LZ09_F3(string solutionType, int ptype, int dtype, int ltype) lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { - cout << "LZ09_F3::LZ09_F3: Error reserving memory for storing the " - << "variable lower limits" << endl; + std::cout << "LZ09_F3::LZ09_F3: Error reserving memory for storing the " + << "variable lower limits" << std::endl; exit(-1); } upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { - cout << "LZ09_F3::LZ09_F3: Error reserving memory for storing the " - << "variable lower limits" << endl; + std::cout << "LZ09_F3::LZ09_F3: Error reserving memory for storing the " + << "variable lower limits" << std::endl; exit(-1); } @@ -70,7 +70,7 @@ LZ09_F3::LZ09_F3(string solutionType, int ptype, int dtype, int ltype) solutionType_ = snew ArrayRealSolutionType(this) ; else { - cout << "LZ09_F3::LZ09_F3: solution type " << solutionType << " invalid" << endl; + std::cout << "LZ09_F3::LZ09_F3: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } @@ -93,8 +93,8 @@ void LZ09_F3::evaluate(Solution * solution) { XReal * vars = snew XReal(solution); - vector * x = snew vector(numberOfVariables_) ; - vector * y = snew vector(numberOfObjectives_); + std::vector * x = snew std::vector(numberOfVariables_) ; + std::vector * y = snew std::vector(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F3.h b/src/problems/LZ09/LZ09_F3.h index 7722a00..76e6a27 100644 --- a/src/problems/LZ09/LZ09_F3.h +++ b/src/problems/LZ09/LZ09_F3.h @@ -34,7 +34,7 @@ class LZ09_F3 : public Problem { public: - LZ09_F3(string solutionType, int ptype=21, int dtype=1, int ltype=23); + LZ09_F3(std::string solutionType, int ptype=21, int dtype=1, int ltype=23); void evaluate(Solution *solution); virtual ~LZ09_F3(); diff --git a/src/problems/LZ09/LZ09_F4.cpp b/src/problems/LZ09/LZ09_F4.cpp index 37d0262..006ba38 100644 --- a/src/problems/LZ09/LZ09_F4.cpp +++ b/src/problems/LZ09/LZ09_F4.cpp @@ -23,7 +23,7 @@ /** * Constructor */ -LZ09_F4::LZ09_F4(string solutionType, int ptype, int dtype, int ltype) +LZ09_F4::LZ09_F4(std::string solutionType, int ptype, int dtype, int ltype) { numberOfVariables_ = 30; numberOfObjectives_ = 2; @@ -39,16 +39,16 @@ LZ09_F4::LZ09_F4(string solutionType, int ptype, int dtype, int ltype) lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { - cout << "LZ09_F4::LZ09_F4: Error reserving memory for storing the " - << "variable lower limits" << endl; + std::cout << "LZ09_F4::LZ09_F4: Error reserving memory for storing the " + << "variable lower limits" << std::endl; exit(-1); } upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { - cout << "LZ09_F4::LZ09_F4: Error reserving memory for storing the " - << "variable lower limits" << endl; + std::cout << "LZ09_F4::LZ09_F4: Error reserving memory for storing the " + << "variable lower limits" << std::endl; exit(-1); } @@ -70,7 +70,7 @@ LZ09_F4::LZ09_F4(string solutionType, int ptype, int dtype, int ltype) solutionType_ = snew ArrayRealSolutionType(this) ; else { - cout << "LZ09_F4::LZ09_F4: solution type " << solutionType << " invalid" << endl; + std::cout << "LZ09_F4::LZ09_F4: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } @@ -93,8 +93,8 @@ void LZ09_F4::evaluate(Solution * solution) { XReal * vars = snew XReal(solution); - vector * x = snew vector(numberOfVariables_) ; - vector * y = snew vector(numberOfObjectives_); + std::vector * x = snew std::vector(numberOfVariables_) ; + std::vector * y = snew std::vector(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F4.h b/src/problems/LZ09/LZ09_F4.h index ffac555..99b9c82 100644 --- a/src/problems/LZ09/LZ09_F4.h +++ b/src/problems/LZ09/LZ09_F4.h @@ -34,7 +34,7 @@ class LZ09_F4 : public Problem { public: - LZ09_F4(string solutionType, int ptype=21, int dtype=1, int ltype=24); + LZ09_F4(std::string solutionType, int ptype=21, int dtype=1, int ltype=24); void evaluate(Solution *solution); virtual ~LZ09_F4(); diff --git a/src/problems/LZ09/LZ09_F5.cpp b/src/problems/LZ09/LZ09_F5.cpp index 299271d..3389106 100644 --- a/src/problems/LZ09/LZ09_F5.cpp +++ b/src/problems/LZ09/LZ09_F5.cpp @@ -23,7 +23,7 @@ /** * Constructor */ -LZ09_F5::LZ09_F5(string solutionType, int ptype, int dtype, int ltype) +LZ09_F5::LZ09_F5(std::string solutionType, int ptype, int dtype, int ltype) { numberOfVariables_ = 30; numberOfObjectives_ = 2; @@ -39,16 +39,16 @@ LZ09_F5::LZ09_F5(string solutionType, int ptype, int dtype, int ltype) lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { - cout << "LZ09_F5::LZ09_F5: Error reserving memory for storing the " - << "variable lower limits" << endl; + std::cout << "LZ09_F5::LZ09_F5: Error reserving memory for storing the " + << "variable lower limits" << std::endl; exit(-1); } upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { - cout << "LZ09_F5::LZ09_F5: Error reserving memory for storing the " - << "variable lower limits" << endl; + std::cout << "LZ09_F5::LZ09_F5: Error reserving memory for storing the " + << "variable lower limits" << std::endl; exit(-1); } @@ -70,7 +70,7 @@ LZ09_F5::LZ09_F5(string solutionType, int ptype, int dtype, int ltype) solutionType_ = snew ArrayRealSolutionType(this) ; else { - cout << "LZ09_F5::LZ09_F5: solution type " << solutionType << " invalid" << endl; + std::cout << "LZ09_F5::LZ09_F5: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } @@ -93,8 +93,8 @@ void LZ09_F5::evaluate(Solution * solution) { XReal * vars = snew XReal(solution); - vector * x = snew vector(numberOfVariables_) ; - vector * y = snew vector(numberOfObjectives_); + std::vector * x = snew std::vector(numberOfVariables_) ; + std::vector * y = snew std::vector(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F5.h b/src/problems/LZ09/LZ09_F5.h index e7f006c..1f3a5ab 100644 --- a/src/problems/LZ09/LZ09_F5.h +++ b/src/problems/LZ09/LZ09_F5.h @@ -34,7 +34,7 @@ class LZ09_F5 : public Problem { public: - LZ09_F5(string solutionType, int ptype=21, int dtype=1, int ltype=26); + LZ09_F5(std::string solutionType, int ptype=21, int dtype=1, int ltype=26); void evaluate(Solution *solution); virtual ~LZ09_F5(); diff --git a/src/problems/LZ09/LZ09_F6.cpp b/src/problems/LZ09/LZ09_F6.cpp index 096dbcf..0989e7a 100644 --- a/src/problems/LZ09/LZ09_F6.cpp +++ b/src/problems/LZ09/LZ09_F6.cpp @@ -23,7 +23,7 @@ /** * Constructor */ -LZ09_F6::LZ09_F6(string solutionType, int ptype, int dtype, int ltype) +LZ09_F6::LZ09_F6(std::string solutionType, int ptype, int dtype, int ltype) { numberOfVariables_ = 10; numberOfObjectives_ = 3; @@ -39,16 +39,16 @@ LZ09_F6::LZ09_F6(string solutionType, int ptype, int dtype, int ltype) lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { - cout << "LZ09_F6::LZ09_F6: Error reserving memory for storing the " - << "variable lower limits" << endl; + std::cout << "LZ09_F6::LZ09_F6: Error reserving memory for storing the " + << "variable lower limits" << std::endl; exit(-1); } upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { - cout << "LZ09_F6::LZ09_F6: Error reserving memory for storing the " - << "variable lower limits" << endl; + std::cout << "LZ09_F6::LZ09_F6: Error reserving memory for storing the " + << "variable lower limits" << std::endl; exit(-1); } @@ -70,7 +70,7 @@ LZ09_F6::LZ09_F6(string solutionType, int ptype, int dtype, int ltype) solutionType_ = snew ArrayRealSolutionType(this) ; else { - cout << "LZ09_F6::LZ09_F6: solution type " << solutionType << " invalid" << endl; + std::cout << "LZ09_F6::LZ09_F6: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } @@ -93,8 +93,8 @@ void LZ09_F6::evaluate(Solution * solution) { XReal * vars = snew XReal(solution); - vector * x = snew vector(numberOfVariables_) ; - vector * y = snew vector(numberOfObjectives_); + std::vector * x = snew std::vector(numberOfVariables_) ; + std::vector * y = snew std::vector(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F6.h b/src/problems/LZ09/LZ09_F6.h index 4e310da..350ac70 100644 --- a/src/problems/LZ09/LZ09_F6.h +++ b/src/problems/LZ09/LZ09_F6.h @@ -34,7 +34,7 @@ class LZ09_F6 : public Problem { public: - LZ09_F6(string solutionType, int ptype=31, int dtype=1, int ltype=32); + LZ09_F6(std::string solutionType, int ptype=31, int dtype=1, int ltype=32); void evaluate(Solution *solution); virtual ~LZ09_F6(); diff --git a/src/problems/LZ09/LZ09_F7.cpp b/src/problems/LZ09/LZ09_F7.cpp index 332423e..41a7409 100644 --- a/src/problems/LZ09/LZ09_F7.cpp +++ b/src/problems/LZ09/LZ09_F7.cpp @@ -23,7 +23,7 @@ /** * Constructor */ -LZ09_F7::LZ09_F7(string solutionType, int ptype, int dtype, int ltype) +LZ09_F7::LZ09_F7(std::string solutionType, int ptype, int dtype, int ltype) { numberOfVariables_ = 10; numberOfObjectives_ = 2; @@ -39,16 +39,16 @@ LZ09_F7::LZ09_F7(string solutionType, int ptype, int dtype, int ltype) lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { - cout << "LZ09_F7::LZ09_F7: Error reserving memory for storing the " - << "variable lower limits" << endl; + std::cout << "LZ09_F7::LZ09_F7: Error reserving memory for storing the " + << "variable lower limits" << std::endl; exit(-1); } upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { - cout << "LZ09_F7::LZ09_F7: Error reserving memory for storing the " - << "variable lower limits" << endl; + std::cout << "LZ09_F7::LZ09_F7: Error reserving memory for storing the " + << "variable lower limits" << std::endl; exit(-1); } @@ -70,7 +70,7 @@ LZ09_F7::LZ09_F7(string solutionType, int ptype, int dtype, int ltype) solutionType_ = snew ArrayRealSolutionType(this) ; else { - cout << "LZ09_F7::LZ09_F7: solution type " << solutionType << " invalid" << endl; + std::cout << "LZ09_F7::LZ09_F7: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } @@ -93,8 +93,8 @@ void LZ09_F7::evaluate(Solution * solution) { XReal * vars = snew XReal(solution); - vector * x = snew vector(numberOfVariables_) ; - vector * y = snew vector(numberOfObjectives_); + std::vector * x = snew std::vector(numberOfVariables_) ; + std::vector * y = snew std::vector(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F7.h b/src/problems/LZ09/LZ09_F7.h index 125fd6d..49a7c1b 100644 --- a/src/problems/LZ09/LZ09_F7.h +++ b/src/problems/LZ09/LZ09_F7.h @@ -34,7 +34,7 @@ class LZ09_F7 : public Problem { public: - LZ09_F7(string solutionType, int ptype=21, int dtype=3, int ltype=21); + LZ09_F7(std::string solutionType, int ptype=21, int dtype=3, int ltype=21); void evaluate(Solution *solution); virtual ~LZ09_F7(); diff --git a/src/problems/LZ09/LZ09_F8.cpp b/src/problems/LZ09/LZ09_F8.cpp index 5744daf..c953ae3 100644 --- a/src/problems/LZ09/LZ09_F8.cpp +++ b/src/problems/LZ09/LZ09_F8.cpp @@ -23,7 +23,7 @@ /** * Constructor */ -LZ09_F8::LZ09_F8(string solutionType, int ptype, int dtype, int ltype) +LZ09_F8::LZ09_F8(std::string solutionType, int ptype, int dtype, int ltype) { numberOfVariables_ = 10; numberOfObjectives_ = 2; @@ -39,16 +39,16 @@ LZ09_F8::LZ09_F8(string solutionType, int ptype, int dtype, int ltype) lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { - cout << "LZ09_F8::LZ09_F8: Error reserving memory for storing the " - << "variable lower limits" << endl; + std::cout << "LZ09_F8::LZ09_F8: Error reserving memory for storing the " + << "variable lower limits" << std::endl; exit(-1); } upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { - cout << "LZ09_F8::LZ09_F8: Error reserving memory for storing the " - << "variable lower limits" << endl; + std::cout << "LZ09_F8::LZ09_F8: Error reserving memory for storing the " + << "variable lower limits" << std::endl; exit(-1); } @@ -70,7 +70,7 @@ LZ09_F8::LZ09_F8(string solutionType, int ptype, int dtype, int ltype) solutionType_ = snew ArrayRealSolutionType(this) ; else { - cout << "LZ09_F8::LZ09_F8: solution type " << solutionType << " invalid" << endl; + std::cout << "LZ09_F8::LZ09_F8: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } @@ -93,8 +93,8 @@ void LZ09_F8::evaluate(Solution * solution) { XReal * vars = snew XReal(solution); - vector * x = snew vector(numberOfVariables_) ; - vector * y = snew vector(numberOfObjectives_); + std::vector * x = snew std::vector(numberOfVariables_) ; + std::vector * y = snew std::vector(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F8.h b/src/problems/LZ09/LZ09_F8.h index d68d910..198cd4e 100644 --- a/src/problems/LZ09/LZ09_F8.h +++ b/src/problems/LZ09/LZ09_F8.h @@ -34,7 +34,7 @@ class LZ09_F8 : public Problem { public: - LZ09_F8(string solutionType, int ptype=21, int dtype=4, int ltype=21); + LZ09_F8(std::string solutionType, int ptype=21, int dtype=4, int ltype=21); void evaluate(Solution *solution); virtual ~LZ09_F8(); diff --git a/src/problems/LZ09/LZ09_F9.cpp b/src/problems/LZ09/LZ09_F9.cpp index 52f3982..0abc38e 100644 --- a/src/problems/LZ09/LZ09_F9.cpp +++ b/src/problems/LZ09/LZ09_F9.cpp @@ -23,7 +23,7 @@ /** * Constructor */ -LZ09_F9::LZ09_F9(string solutionType, int ptype, int dtype, int ltype) +LZ09_F9::LZ09_F9(std::string solutionType, int ptype, int dtype, int ltype) { numberOfVariables_ = 30; numberOfObjectives_ = 2; @@ -39,16 +39,16 @@ LZ09_F9::LZ09_F9(string solutionType, int ptype, int dtype, int ltype) lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { - cout << "LZ09_F9::LZ09_F9: Error reserving memory for storing the " - << "variable lower limits" << endl; + std::cout << "LZ09_F9::LZ09_F9: Error reserving memory for storing the " + << "variable lower limits" << std::endl; exit(-1); } upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { - cout << "LZ09_F9::LZ09_F9: Error reserving memory for storing the " - << "variable lower limits" << endl; + std::cout << "LZ09_F9::LZ09_F9: Error reserving memory for storing the " + << "variable lower limits" << std::endl; exit(-1); } @@ -70,7 +70,7 @@ LZ09_F9::LZ09_F9(string solutionType, int ptype, int dtype, int ltype) solutionType_ = snew ArrayRealSolutionType(this) ; else { - cout << "LZ09_F9::LZ09_F9: solution type " << solutionType << " invalid" << endl; + std::cout << "LZ09_F9::LZ09_F9: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } @@ -93,8 +93,8 @@ void LZ09_F9::evaluate(Solution * solution) { XReal * vars = snew XReal(solution); - vector * x = snew vector(numberOfVariables_) ; - vector * y = snew vector(numberOfObjectives_); + std::vector * x = snew std::vector(numberOfVariables_) ; + std::vector * y = snew std::vector(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/ProblemFactory.cpp b/src/problems/ProblemFactory.cpp index aa4b9b2..842330d 100644 --- a/src/problems/ProblemFactory.cpp +++ b/src/problems/ProblemFactory.cpp @@ -81,11 +81,11 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new CEC2005Problem(argv[0], atoi(argv[1]), atoi(argv[2])); else { - cerr << "Incorrect number of arguments for CEC2005 problem." << endl; - cerr << "Use one of this:" << endl; - cerr << "\tCEC2005 NUMBER_OF_CEC2005_PROBLEM" << endl; - cerr << "\tCEC2005 SOLUTION_TYPE NUMBER_OF_CEC2005_PROBLEM " << endl; - cerr << "\tCEC2005 SOLUTION_TYPE NUMBER_OF_CEC2005_PROBLEM NUMBER_OF_VARIABLES" << endl; + cerr << "Incorrect number of arguments for CEC2005 problem." << std::endl; + cerr << "Use one of this:" << std::endl; + cerr << "\tCEC2005 NUMBER_OF_CEC2005_PROBLEM" << std::endl; + cerr << "\tCEC2005 SOLUTION_TYPE NUMBER_OF_CEC2005_PROBLEM " << std::endl; + cerr << "\tCEC2005 SOLUTION_TYPE NUMBER_OF_CEC2005_PROBLEM NUMBER_OF_VARIABLES" << std::endl; exit(-1); } } @@ -101,7 +101,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new DTLZ1(argv[0], atoi(argv[1]), atoi(argv[2])); else { - cerr << "Incorrect number of arguments for DTLZ1 problem." << endl; + cerr << "Incorrect number of arguments for DTLZ1 problem." << std::endl; exit(-1); } } @@ -117,7 +117,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new DTLZ2(argv[0], atoi(argv[1]), atoi(argv[2])); else { - cerr << "Incorrect number of arguments for DTLZ2 problem." << endl; + cerr << "Incorrect number of arguments for DTLZ2 problem." << std::endl; exit(-1); } } @@ -133,7 +133,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new DTLZ3(argv[0], atoi(argv[1]), atoi(argv[2])); else { - cerr << "Incorrect number of arguments for DTLZ3 problem." << endl; + cerr << "Incorrect number of arguments for DTLZ3 problem." << std::endl; exit(-1); } } @@ -149,7 +149,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new DTLZ4(argv[0], atoi(argv[1]), atoi(argv[2])); else { - cerr << "Incorrect number of arguments for DTLZ4 problem." << endl; + cerr << "Incorrect number of arguments for DTLZ4 problem." << std::endl; exit(-1); } } @@ -165,7 +165,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new DTLZ5(argv[0], atoi(argv[1]), atoi(argv[2])); else { - cerr << "Incorrect number of arguments for DTLZ5 problem." << endl; + cerr << "Incorrect number of arguments for DTLZ5 problem." << std::endl; exit(-1); } } @@ -181,7 +181,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new DTLZ6(argv[0], atoi(argv[1]), atoi(argv[2])); else { - cerr << "Incorrect number of arguments for DTLZ6 problem." << endl; + cerr << "Incorrect number of arguments for DTLZ6 problem." << std::endl; exit(-1); } } @@ -197,7 +197,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new DTLZ7(argv[0], atoi(argv[1]), atoi(argv[2])); else { - cerr << "Incorrect number of arguments for DTLZ7 problem." << endl; + cerr << "Incorrect number of arguments for DTLZ7 problem." << std::endl; exit(-1); } } @@ -209,7 +209,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new Fonseca(argv[0]); else { - cerr << "Incorrect number of arguments for Fonseca problem." << endl; + cerr << "Incorrect number of arguments for Fonseca problem." << std::endl; exit(-1); } } @@ -223,7 +223,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new Griewank(argv[0], atoi(argv[1])); else { - cerr << "Incorrect number of arguments for Griewank problem." << endl; + cerr << "Incorrect number of arguments for Griewank problem." << std::endl; exit(-1); } } @@ -237,7 +237,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new Kursawe(argv[0], atoi(argv[1])); else { - cerr << "Incorrect number of arguments for Kursawe problem." << endl; + cerr << "Incorrect number of arguments for Kursawe problem." << std::endl; exit(-1); } } @@ -255,7 +255,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new LZ09_F1(argv[0], atoi(argv[1]), atoi(argv[2]), atoi(argv[3])); else { - cerr << "Incorrect number of arguments for LZ09_F1 problem." << endl; + cerr << "Incorrect number of arguments for LZ09_F1 problem." << std::endl; exit(-1); } } @@ -273,7 +273,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new LZ09_F2(argv[0], atoi(argv[1]), atoi(argv[2]), atoi(argv[3])); else { - cerr << "Incorrect number of arguments for LZ09_F2 problem." << endl; + cerr << "Incorrect number of arguments for LZ09_F2 problem." << std::endl; exit(-1); } } @@ -291,7 +291,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new LZ09_F3(argv[0], atoi(argv[1]), atoi(argv[2]), atoi(argv[3])); else { - cerr << "Incorrect number of arguments for LZ09_F3 problem." << endl; + cerr << "Incorrect number of arguments for LZ09_F3 problem." << std::endl; exit(-1); } } @@ -309,7 +309,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new LZ09_F4(argv[0], atoi(argv[1]), atoi(argv[2]), atoi(argv[3])); else { - cerr << "Incorrect number of arguments for LZ09_F4 problem." << endl; + cerr << "Incorrect number of arguments for LZ09_F4 problem." << std::endl; exit(-1); } } @@ -327,7 +327,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new LZ09_F5(argv[0], atoi(argv[1]), atoi(argv[2]), atoi(argv[3])); else { - cerr << "Incorrect number of arguments for LZ09_F5 problem." << endl; + cerr << "Incorrect number of arguments for LZ09_F5 problem." << std::endl; exit(-1); } } @@ -345,7 +345,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new LZ09_F6(argv[0], atoi(argv[1]), atoi(argv[2]), atoi(argv[3])); else { - cerr << "Incorrect number of arguments for LZ09_F6 problem." << endl; + cerr << "Incorrect number of arguments for LZ09_F6 problem." << std::endl; exit(-1); } } @@ -363,7 +363,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new LZ09_F7(argv[0], atoi(argv[1]), atoi(argv[2]), atoi(argv[3])); else { - cerr << "Incorrect number of arguments for LZ09_F7 problem." << endl; + cerr << "Incorrect number of arguments for LZ09_F7 problem." << std::endl; exit(-1); } } @@ -381,7 +381,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new LZ09_F8(argv[0], atoi(argv[1]), atoi(argv[2]), atoi(argv[3])); else { - cerr << "Incorrect number of arguments for LZ09_F8 problem." << endl; + cerr << "Incorrect number of arguments for LZ09_F8 problem." << std::endl; exit(-1); } } @@ -399,7 +399,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new LZ09_F9(argv[0], atoi(argv[1]), atoi(argv[2]), atoi(argv[3])); else { - cerr << "Incorrect number of arguments for LZ09_F9 problem." << endl; + cerr << "Incorrect number of arguments for LZ09_F9 problem." << std::endl; exit(-1); } @@ -414,7 +414,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new OneMax(atoi(argv[0]), atoi(argv[1])); else { - cerr << "Incorrect number of arguments for OneMax problem." << endl; + cerr << "Incorrect number of arguments for OneMax problem." << std::endl; exit(-1); } @@ -429,7 +429,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new Rastrigin(argv[0], atoi(argv[1])); else { - cerr << "Incorrect number of arguments for Rastrigin problem." << endl; + cerr << "Incorrect number of arguments for Rastrigin problem." << std::endl; exit(-1); } @@ -444,7 +444,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new Rosenbrock(argv[0], atoi(argv[1])); else { - cerr << "Incorrect number of arguments for Rosenbrock problem." << endl; + cerr << "Incorrect number of arguments for Rosenbrock problem." << std::endl; exit(-1); } @@ -457,7 +457,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new Schaffer(argv[0]); else { - cerr << "Incorrect number of arguments for Schaffer problem." << endl; + cerr << "Incorrect number of arguments for Schaffer problem." << std::endl; exit(-1); } @@ -472,7 +472,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new Sphere(argv[0], atoi(argv[1])); else { - cerr << "Incorrect number of arguments for Sphere problem." << endl; + cerr << "Incorrect number of arguments for Sphere problem." << std::endl; exit(-1); } @@ -485,7 +485,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new Srinivas(argv[0]); else { - cerr << "Incorrect number of arguments for Srinivas problem." << endl; + cerr << "Incorrect number of arguments for Srinivas problem." << std::endl; exit(-1); } @@ -498,7 +498,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new Tanaka(argv[0]); else { - cerr << "Incorrect number of arguments for Tanaka problem." << endl; + cerr << "Incorrect number of arguments for Tanaka problem." << std::endl; exit(-1); } @@ -513,7 +513,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new ZDT1(argv[0], atoi(argv[1])); else { - cerr << "Incorrect number of arguments for ZDT1 problem." << endl; + cerr << "Incorrect number of arguments for ZDT1 problem." << std::endl; exit(-1); } } @@ -527,7 +527,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new ZDT2(argv[0], atoi(argv[1])); else { - cerr << "Incorrect number of arguments for ZDT3 problem." << endl; + cerr << "Incorrect number of arguments for ZDT3 problem." << std::endl; exit(-1); } } @@ -541,7 +541,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new ZDT3(argv[0], atoi(argv[1])); else { - cerr << "Incorrect number of arguments for ZDT4 problem." << endl; + cerr << "Incorrect number of arguments for ZDT4 problem." << std::endl; exit(-1); } } @@ -555,7 +555,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new ZDT4(argv[0], atoi(argv[1])); else { - cerr << "Incorrect number of arguments for ZDT4 problem." << endl; + cerr << "Incorrect number of arguments for ZDT4 problem." << std::endl; exit(-1); } } @@ -569,7 +569,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new ZDT5(argv[0], atoi(argv[1])); else { - cerr << "Incorrect number of arguments for ZDT5 problem." << endl; + cerr << "Incorrect number of arguments for ZDT5 problem." << std::endl; exit(-1); } } @@ -583,7 +583,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) return new ZDT6(argv[0], atoi(argv[1])); else { - cerr << "Incorrect number of arguments for ZDT6 problem." << endl; + cerr << "Incorrect number of arguments for ZDT6 problem." << std::endl; exit(-1); } @@ -593,7 +593,7 @@ Problem * ProblemFactory::getProblem(char * name, int argc, char ** argv) cerr << "ProblemFactory::getProblem: Problem '" << name << "' does not exist. Please, check the problem names " - << "in jmetalcpp/problems" << endl; + << "in jmetalcpp/problems" << std::endl; exit(-1); } diff --git a/src/problems/Schaffer.cpp b/src/problems/Schaffer.cpp index bb9690f..3e29797 100644 --- a/src/problems/Schaffer.cpp +++ b/src/problems/Schaffer.cpp @@ -26,7 +26,7 @@ * Creates a new instance of the Schaffer problem. * @param solutionType The solution type must "Real", "BinaryReal, and "ArrayReal". */ -Schaffer::Schaffer(string solutionType) +Schaffer::Schaffer(std::string solutionType) { numberOfVariables_ = 1; numberOfObjectives_ = 2; @@ -35,14 +35,14 @@ Schaffer::Schaffer(string solutionType) lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { - cout << "Schaffer::Schaffer. Error reserving memory for storing the array of lower limits" << endl; + std::cout << "Schaffer::Schaffer. Error reserving memory for storing the array of lower limits" << std::endl; exit(-1) ; } upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { - cout << "Schaffer::Schaffer. Error reserving memory for storing the array of upper limits" << endl; + std::cout << "Schaffer::Schaffer. Error reserving memory for storing the array of upper limits" << std::endl; exit(-1) ; } @@ -82,7 +82,7 @@ void Schaffer::evaluate(Solution *solution) fx = snew double[numberOfObjectives_]; if (fx == nullptr) { - cout << "Schaffer::evaluate: Error reserving memory while evaluating the problem" << endl; + std::cout << "Schaffer::evaluate: Error reserving memory while evaluating the problem" << std::endl; exit(-1); } diff --git a/src/problems/Schaffer.h b/src/problems/Schaffer.h index 048826e..9f7a24f 100644 --- a/src/problems/Schaffer.h +++ b/src/problems/Schaffer.h @@ -35,7 +35,7 @@ class Schaffer : public Problem { public: - Schaffer(string solutionType); + Schaffer(std::string solutionType); ~Schaffer(); void evaluate(Solution *solution); }; diff --git a/src/problems/Srinivas.cpp b/src/problems/Srinivas.cpp index 51dde68..0f4ddd9 100644 --- a/src/problems/Srinivas.cpp +++ b/src/problems/Srinivas.cpp @@ -26,7 +26,7 @@ * Creates a new instance of the Srinivas problem. * @param solutionType The solution type must "Real" or "BinaryReal */ -Srinivas::Srinivas(string solutionType) +Srinivas::Srinivas(std::string solutionType) { numberOfVariables_ = 2; numberOfObjectives_ = 2; @@ -36,14 +36,14 @@ Srinivas::Srinivas(string solutionType) lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { - cout << "Srinivas::Srinivas. Error reserving memory for storing the array of lower limits" << endl; + std::cout << "Srinivas::Srinivas. Error reserving memory for storing the array of lower limits" << std::endl; exit(-1) ; } upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { - cout << "Srinivas::Srinivas. Error reserving memory for storing the array of upper limits" << endl; + std::cout << "Srinivas::Srinivas. Error reserving memory for storing the array of upper limits" << std::endl; exit(-1) ; } @@ -63,7 +63,7 @@ Srinivas::Srinivas(string solutionType) } else { - cout << "Error: solution type " << solutionType << " invalid" << endl; + std::cout << "Error: solution type " << solutionType << " invalid" << std::endl; exit(-1); } } // Srinivas @@ -92,14 +92,14 @@ void Srinivas::evaluate(Solution *solution) double * fx = snew double[numberOfObjectives_]; if (fx == nullptr) { - cout << "Srinivas::evaluate: Error reserving memory while evaluating the problem" << endl; + std::cout << "Srinivas::evaluate: Error reserving memory while evaluating the problem" << std::endl; exit(-1); } double * x = snew double[numberOfVariables_]; if (x == nullptr) { - cout << "Srinivas::evaluate: Error reserving memory for the variable values array" << endl; + std::cout << "Srinivas::evaluate: Error reserving memory for the variable values array" << std::endl; exit(-1); } // if diff --git a/src/problems/Srinivas.h b/src/problems/Srinivas.h index eaf247a..4288b10 100644 --- a/src/problems/Srinivas.h +++ b/src/problems/Srinivas.h @@ -30,7 +30,7 @@ #include #include -using namespace std; + /** * @class Srinivas @@ -40,7 +40,7 @@ class Srinivas : public Problem { public: - Srinivas(string solutionType); + Srinivas(std::string solutionType); ~Srinivas(); void evaluate(Solution *solution); void evaluateConstraints(Solution * solution); diff --git a/src/problems/Tanaka.cpp b/src/problems/Tanaka.cpp index 5407dda..ac36576 100644 --- a/src/problems/Tanaka.cpp +++ b/src/problems/Tanaka.cpp @@ -28,7 +28,7 @@ const double Tanaka::PI = 3.141592653589793; * Creates a new instance of the Tanaka problem. * @param solutionType The solution type must "Real" or "BinaryReal */ -Tanaka::Tanaka(string solutionType) +Tanaka::Tanaka(std::string solutionType) { numberOfVariables_ = 2; numberOfObjectives_ = 2; @@ -38,14 +38,14 @@ Tanaka::Tanaka(string solutionType) lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { - cout << "Tanaka::Tanaka. Error reserving memory for storing the array of lower limits" << endl; + std::cout << "Tanaka::Tanaka. Error reserving memory for storing the array of lower limits" << std::endl; exit(-1) ; } upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { - cout << "Tanaka::Tanaka. Error reserving memory for storing the array of upper limits" << endl; + std::cout << "Tanaka::Tanaka. Error reserving memory for storing the array of upper limits" << std::endl; exit(-1) ; } @@ -65,7 +65,7 @@ Tanaka::Tanaka(string solutionType) } else { - cout << "Error: solution type " << solutionType << " invalid" << endl; + std::cout << "Error: solution type " << solutionType << " invalid" << std::endl; exit(-1); } } // Tanaka @@ -94,7 +94,7 @@ void Tanaka::evaluate(Solution *solution) double * fx = snew double[numberOfObjectives_]; if (fx == nullptr) { - cout << "Tanaka::evaluate: Error reserving memory while evaluating the problem" << endl; + std::cout << "Tanaka::evaluate: Error reserving memory while evaluating the problem" << std::endl; exit(-1); } diff --git a/src/problems/ZDT/ZDT1.cpp b/src/problems/ZDT/ZDT1.cpp index 392c280..fdc649f 100644 --- a/src/problems/ZDT/ZDT1.cpp +++ b/src/problems/ZDT/ZDT1.cpp @@ -20,7 +20,7 @@ #include -ZDT1::ZDT1(string solutionType, int numberOfVariables) +ZDT1::ZDT1(std::string solutionType, int numberOfVariables) { numberOfVariables_ = numberOfVariables; numberOfObjectives_ = 2; @@ -30,14 +30,14 @@ ZDT1::ZDT1(string solutionType, int numberOfVariables) lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } @@ -52,13 +52,13 @@ ZDT1::ZDT1(string solutionType, int numberOfVariables) else if (solutionType.compare("Real") == 0) { solutionType_ = new RealSolutionType(this) ; - //cout << "Tipo seleccionado Real" << endl; + //std::cout << "Tipo seleccionado Real" << std::endl; } else if (solutionType.compare("ArrayReal") == 0) solutionType_ = new ArrayRealSolutionType(this) ; else { - cout << "Error: solution type " << solutionType << " invalid" << endl; + std::cout << "Error: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } fx_ = snew double[numberOfObjectives_] ; diff --git a/src/problems/ZDT/ZDT1.h b/src/problems/ZDT/ZDT1.h index 6503143..7cae8b3 100644 --- a/src/problems/ZDT/ZDT1.h +++ b/src/problems/ZDT/ZDT1.h @@ -37,7 +37,7 @@ class ZDT1 : public Problem double * fx_ ; public: - ZDT1(string solutionType, int numberOfVariables = 30); + ZDT1(std::string solutionType, int numberOfVariables = 30); void evaluate(Solution *solution); ~ZDT1(); diff --git a/src/problems/ZDT/ZDT2.cpp b/src/problems/ZDT/ZDT2.cpp index b22fcdf..20dfd1e 100644 --- a/src/problems/ZDT/ZDT2.cpp +++ b/src/problems/ZDT/ZDT2.cpp @@ -20,7 +20,7 @@ #include -ZDT2::ZDT2(string solutionType, int numberOfVariables) +ZDT2::ZDT2(std::string solutionType, int numberOfVariables) { numberOfVariables_ = numberOfVariables; numberOfObjectives_ = 2; @@ -30,14 +30,14 @@ ZDT2::ZDT2(string solutionType, int numberOfVariables) lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } @@ -52,13 +52,13 @@ ZDT2::ZDT2(string solutionType, int numberOfVariables) else if (solutionType.compare("Real") == 0) { solutionType_ = new RealSolutionType(this) ; - //cout << "Tipo seleccionado Real" << endl; + //std::cout << "Tipo seleccionado Real" << std::endl; } else if (solutionType.compare("ArrayReal") == 0) solutionType_ = new ArrayRealSolutionType(this) ; else { - cout << "Error: solution type " << solutionType << " invalid" << endl; + std::cout << "Error: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } fx_ = snew double[numberOfObjectives_] ; diff --git a/src/problems/ZDT/ZDT2.h b/src/problems/ZDT/ZDT2.h index d082c8e..73801e2 100644 --- a/src/problems/ZDT/ZDT2.h +++ b/src/problems/ZDT/ZDT2.h @@ -38,7 +38,7 @@ class ZDT2 : public Problem double * fx_ ; public: - ZDT2(string solutionType, int numberOfVariables = 30); + ZDT2(std::string solutionType, int numberOfVariables = 30); void evaluate(Solution *solution); virtual ~ZDT2(); diff --git a/src/problems/ZDT/ZDT3.cpp b/src/problems/ZDT/ZDT3.cpp index 53a6316..d9725be 100644 --- a/src/problems/ZDT/ZDT3.cpp +++ b/src/problems/ZDT/ZDT3.cpp @@ -22,7 +22,7 @@ const double ZDT3::PI = 3.141592653589793; -ZDT3::ZDT3(string solutionType, int numberOfVariables) +ZDT3::ZDT3(std::string solutionType, int numberOfVariables) { numberOfVariables_ = numberOfVariables; numberOfObjectives_ = 2; @@ -32,14 +32,14 @@ ZDT3::ZDT3(string solutionType, int numberOfVariables) lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } @@ -54,13 +54,13 @@ ZDT3::ZDT3(string solutionType, int numberOfVariables) else if (solutionType.compare("Real") == 0) { solutionType_ = new RealSolutionType(this) ; - //cout << "Tipo seleccionado Real" << endl; + //std::cout << "Tipo seleccionado Real" << std::endl; } else if (solutionType.compare("ArrayReal") == 0) solutionType_ = new ArrayRealSolutionType(this) ; else { - cout << "Error: solution type " << solutionType << " invalid" << endl; + std::cout << "Error: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } fx_ = snew double[numberOfObjectives_] ; diff --git a/src/problems/ZDT/ZDT3.h b/src/problems/ZDT/ZDT3.h index e9e6131..3b71c4b 100644 --- a/src/problems/ZDT/ZDT3.h +++ b/src/problems/ZDT/ZDT3.h @@ -40,7 +40,7 @@ class ZDT3 : public Problem static const double PI ; public: - ZDT3(string solutionType, int numberOfVariables = 30); + ZDT3(std::string solutionType, int numberOfVariables = 30); void evaluate(Solution *solution); virtual ~ZDT3(); }; diff --git a/src/problems/ZDT/ZDT4.cpp b/src/problems/ZDT/ZDT4.cpp index 9f1e177..9155aa0 100644 --- a/src/problems/ZDT/ZDT4.cpp +++ b/src/problems/ZDT/ZDT4.cpp @@ -22,7 +22,7 @@ const double ZDT4::PI = 3.141592653589793; -ZDT4::ZDT4(string solutionType, int numberOfVariables) +ZDT4::ZDT4(std::string solutionType, int numberOfVariables) { numberOfVariables_ = numberOfVariables; numberOfObjectives_ = 2; @@ -32,14 +32,14 @@ ZDT4::ZDT4(string solutionType, int numberOfVariables) lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } @@ -56,13 +56,13 @@ ZDT4::ZDT4(string solutionType, int numberOfVariables) else if (solutionType.compare("Real") == 0) { solutionType_ = new RealSolutionType(this) ; - //cout << "Tipo seleccionado Real" << endl; + //std::cout << "Tipo seleccionado Real" << std::endl; } else if (solutionType.compare("ArrayReal") == 0) solutionType_ = new ArrayRealSolutionType(this) ; else { - cout << "Error: solution type " << solutionType << " invalid" << endl; + std::cout << "Error: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } fx_ = snew double[numberOfObjectives_] ; diff --git a/src/problems/ZDT/ZDT4.h b/src/problems/ZDT/ZDT4.h index 7d751b1..c7ee090 100644 --- a/src/problems/ZDT/ZDT4.h +++ b/src/problems/ZDT/ZDT4.h @@ -40,7 +40,7 @@ class ZDT4 : public Problem static const double PI ; public: - ZDT4(string solutionType, int numberOfVariables = 10); + ZDT4(std::string solutionType, int numberOfVariables = 10); void evaluate(Solution *solution); virtual ~ZDT4(); }; diff --git a/src/problems/ZDT/ZDT5.cpp b/src/problems/ZDT/ZDT5.cpp index 0d6e35d..9e6b73c 100644 --- a/src/problems/ZDT/ZDT5.cpp +++ b/src/problems/ZDT/ZDT5.cpp @@ -20,15 +20,15 @@ #include "ZDT5.h" -ZDT5::ZDT5(string solutionType, int numberOfVariables) +ZDT5::ZDT5(std::string solutionType, int numberOfVariables) { - cout << "Solutiontype: " << solutionType << endl ; + std::cout << "Solutiontype: " << solutionType << std::endl ; numberOfVariables_ = numberOfVariables; numberOfObjectives_ = 2; numberOfConstraints_ = 0; problemName_ = "ZDT5"; - cout << "Problem: " << problemName_ << endl ; + std::cout << "Problem: " << problemName_ << std::endl ; length_ = snew int[numberOfVariables_]; length_[0] = 30; @@ -41,7 +41,7 @@ ZDT5::ZDT5(string solutionType, int numberOfVariables) solutionType_ = new BinarySolutionType(this) ; else { - cout << "Error: solution type " << solutionType << " invalid" << endl; + std::cout << "Error: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } fx_ = snew double[numberOfObjectives_] ; diff --git a/src/problems/ZDT/ZDT5.h b/src/problems/ZDT/ZDT5.h index eff8874..9c1bca3 100644 --- a/src/problems/ZDT/ZDT5.h +++ b/src/problems/ZDT/ZDT5.h @@ -36,7 +36,7 @@ class ZDT5 : public Problem double * fx_ ; public: - ZDT5(string solutionType, int numberOfVariables = 11); + ZDT5(std::string solutionType, int numberOfVariables = 11); void evaluate(Solution *solution); virtual ~ZDT5(); diff --git a/src/problems/ZDT/ZDT6.cpp b/src/problems/ZDT/ZDT6.cpp index f76bef2..d9b53bc 100644 --- a/src/problems/ZDT/ZDT6.cpp +++ b/src/problems/ZDT/ZDT6.cpp @@ -22,7 +22,7 @@ const double ZDT6::PI = 3.141592653589793; -ZDT6::ZDT6(string solutionType, int numberOfVariables) +ZDT6::ZDT6(std::string solutionType, int numberOfVariables) { numberOfVariables_ = numberOfVariables; numberOfObjectives_ = 2; @@ -32,14 +32,14 @@ ZDT6::ZDT6(string solutionType, int numberOfVariables) lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (upperLimit_ == nullptr) { - cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + std::cout << "Impossible to reserve memory for storing the variable lower limits" << std::endl; exit(-1); } @@ -54,13 +54,13 @@ ZDT6::ZDT6(string solutionType, int numberOfVariables) else if (solutionType.compare("Real") == 0) { solutionType_ = new RealSolutionType(this) ; - //cout << "Tipo seleccionado Real" << endl; + //std::cout << "Tipo seleccionado Real" << std::endl; } else if (solutionType.compare("ArrayReal") == 0) solutionType_ = new ArrayRealSolutionType(this) ; else { - cout << "Error: solution type " << solutionType << " invalid" << endl; + std::cout << "Error: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } fx_ = snew double[numberOfObjectives_] ; diff --git a/src/problems/singleObjective/CEC2005Problem.cpp b/src/problems/singleObjective/CEC2005Problem.cpp index d46c7bc..46ec4a9 100644 --- a/src/problems/singleObjective/CEC2005Problem.cpp +++ b/src/problems/singleObjective/CEC2005Problem.cpp @@ -31,7 +31,7 @@ const double CEC2005Problem::PI = 3.141592653589793; * @param problemId CEC2005 problem id * @param numberOfVariables Number of variables of the problem */ -CEC2005Problem::CEC2005Problem(string solutionType, int problemID, int numberOfVariables) +CEC2005Problem::CEC2005Problem(std::string solutionType, int problemID, int numberOfVariables) { numberOfVariables_ = numberOfVariables ; numberOfObjectives_ = 1; @@ -112,7 +112,7 @@ CEC2005Problem::CEC2005Problem(string solutionType, int problemID, int numberOfV solutionType_ = snew RealSolutionType(this) ; else { - cout << "Error: solution type " << solutionType << " invalid" << endl; + std::cout << "Error: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } // if diff --git a/src/problems/singleObjective/CEC2005Problem.h b/src/problems/singleObjective/CEC2005Problem.h index d538c32..224edb3 100644 --- a/src/problems/singleObjective/CEC2005Problem.h +++ b/src/problems/singleObjective/CEC2005Problem.h @@ -44,7 +44,7 @@ class CEC2005Problem : public Problem static const double PI; public: - CEC2005Problem(string solutionType, int problemID, int numberOfVariables = 10); + CEC2005Problem(std::string solutionType, int problemID, int numberOfVariables = 10); ~CEC2005Problem(); void evaluate(Solution *solution); }; diff --git a/src/problems/singleObjective/Griewank.cpp b/src/problems/singleObjective/Griewank.cpp index 9f87895..5d1aed7 100644 --- a/src/problems/singleObjective/Griewank.cpp +++ b/src/problems/singleObjective/Griewank.cpp @@ -28,7 +28,7 @@ * @param solutionType The solution type must "Real", "BinaryReal, and "ArrayReal". * @param numberOfVariables Number of variables of the problem */ -Griewank::Griewank(string solutionType, int numberOfVariables) +Griewank::Griewank(std::string solutionType, int numberOfVariables) { numberOfVariables_ = numberOfVariables; numberOfObjectives_ = 1; @@ -38,14 +38,14 @@ Griewank::Griewank(string solutionType, int numberOfVariables) lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { - cout << "Griewank::Griewank. Error reserving memory for storing the array of lower limits" << endl; + std::cout << "Griewank::Griewank. Error reserving memory for storing the array of lower limits" << std::endl; exit(-1) ; } // if upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { - cout << "Griewank::Griewank. Error reserving memory for storing the array of upper limits" << endl; + std::cout << "Griewank::Griewank. Error reserving memory for storing the array of upper limits" << std::endl; exit(-1) ; } // if @@ -61,7 +61,7 @@ Griewank::Griewank(string solutionType, int numberOfVariables) solutionType_ = snew RealSolutionType(this) ; else { - cout << "Error: solution type " << solutionType << " invalid" << endl; + std::cout << "Error: solution type " << solutionType << " invalid" << std::endl; exit(-1) ; } // if } // Griewank diff --git a/src/problems/singleObjective/Griewank.h b/src/problems/singleObjective/Griewank.h index b2e77cf..824a5ab 100644 --- a/src/problems/singleObjective/Griewank.h +++ b/src/problems/singleObjective/Griewank.h @@ -35,7 +35,7 @@ class Griewank : public Problem { public: - Griewank(string solutionType, int numberOfVariables = 10); + Griewank(std::string solutionType, int numberOfVariables = 10); ~Griewank(); void evaluate(Solution *solution); }; diff --git a/src/problems/singleObjective/Rastrigin.cpp b/src/problems/singleObjective/Rastrigin.cpp index 451057f..343b97c 100644 --- a/src/problems/singleObjective/Rastrigin.cpp +++ b/src/problems/singleObjective/Rastrigin.cpp @@ -29,7 +29,7 @@ const double Rastrigin::PI = 3.141592653589793; * @param solutionType The solution type must "Real", "BinaryReal, and "ArrayReal". * @param numberOfVariables Number of variables of the problem */ -Rastrigin::Rastrigin(string solutionType, int numberOfVariables) +Rastrigin::Rastrigin(std::string solutionType, int numberOfVariables) { numberOfVariables_ = numberOfVariables; numberOfObjectives_ = 1; @@ -39,14 +39,14 @@ Rastrigin::Rastrigin(string solutionType, int numberOfVariables) lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { - cout << "Rastrigin::Rastrigin. Error reserving memory for storing the array of lower limits" << endl; + std::cout << "Rastrigin::Rastrigin. Error reserving memory for storing the array of lower limits" << std::endl; exit(-1) ; } upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { - cout << "Rastrigin::Rastrigin. Error reserving memory for storing the array of upper limits" << endl; + std::cout << "Rastrigin::Rastrigin. Error reserving memory for storing the array of upper limits" << std::endl; exit(-1) ; } @@ -85,14 +85,14 @@ void Rastrigin::evaluate(Solution *solution) double * fx = snew double[numberOfObjectives_]; //(double *)malloc(sizeof(double) * numberOfObjectives_); if (fx == nullptr) { - cout << "Rastrigin::evaluate: Error reserving memory while evaluating the problem" << endl; + std::cout << "Rastrigin::evaluate: Error reserving memory while evaluating the problem" << std::endl; exit(-1); } double * x = snew double[numberOfVariables_]; if (x == nullptr) { - cout << "Rastrigin::evaluate: Error reserving memory for the variable values array" << endl; + std::cout << "Rastrigin::evaluate: Error reserving memory for the variable values array" << std::endl; exit(-1); } // if diff --git a/src/problems/singleObjective/Rastrigin.h b/src/problems/singleObjective/Rastrigin.h index 9c68c04..2fea952 100644 --- a/src/problems/singleObjective/Rastrigin.h +++ b/src/problems/singleObjective/Rastrigin.h @@ -35,7 +35,7 @@ class Rastrigin : public Problem { public: - Rastrigin(string solutionType, int numberOfVariables = 10); + Rastrigin(std::string solutionType, int numberOfVariables = 10); ~Rastrigin(); void evaluate(Solution *solution); diff --git a/src/problems/singleObjective/Rosenbrock.cpp b/src/problems/singleObjective/Rosenbrock.cpp index 66338bf..4bc8b11 100644 --- a/src/problems/singleObjective/Rosenbrock.cpp +++ b/src/problems/singleObjective/Rosenbrock.cpp @@ -27,7 +27,7 @@ * @param solutionType The solution type must "Real", "BinaryReal, and "ArrayReal". * @param numberOfVariables Number of variables of the problem */ -Rosenbrock::Rosenbrock(string solutionType, int numberOfVariables) +Rosenbrock::Rosenbrock(std::string solutionType, int numberOfVariables) { numberOfVariables_ = numberOfVariables; numberOfObjectives_ = 1; @@ -37,14 +37,14 @@ Rosenbrock::Rosenbrock(string solutionType, int numberOfVariables) lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { - cout << "Rosenbrock::Rosenbrock. Error reserving memory for storing the array of lower limits" << endl; + std::cout << "Rosenbrock::Rosenbrock. Error reserving memory for storing the array of lower limits" << std::endl; exit(-1) ; } upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { - cout << "Rosenbrock::Rosenbrock. Error reserving memory for storing the array of upper limits" << endl; + std::cout << "Rosenbrock::Rosenbrock. Error reserving memory for storing the array of upper limits" << std::endl; exit(-1) ; } @@ -84,14 +84,14 @@ void Rosenbrock::evaluate(Solution *solution) double * fx = snew double[numberOfObjectives_]; //(double *)malloc(sizeof(double) * numberOfObjectives_); if (fx == nullptr) { - cout << "Rosenbrock::evaluate: Error reserving memory while evaluating the problem" << endl; + std::cout << "Rosenbrock::evaluate: Error reserving memory while evaluating the problem" << std::endl; exit(-1); } double * x = snew double[numberOfVariables_]; if (x == nullptr) { - cout << "Rosenbrock::evaluate: Error reserving memory for the variable values array" << endl; + std::cout << "Rosenbrock::evaluate: Error reserving memory for the variable values array" << std::endl; exit(-1); } // if diff --git a/src/problems/singleObjective/Rosenbrock.h b/src/problems/singleObjective/Rosenbrock.h index af062a1..a18d4a7 100644 --- a/src/problems/singleObjective/Rosenbrock.h +++ b/src/problems/singleObjective/Rosenbrock.h @@ -34,7 +34,7 @@ class Rosenbrock : public Problem { public: - Rosenbrock(string solutionType, int numberOfVariables = 10); + Rosenbrock(std::string solutionType, int numberOfVariables = 10); ~Rosenbrock(); void evaluate(Solution *solution); }; diff --git a/src/problems/singleObjective/Sphere.cpp b/src/problems/singleObjective/Sphere.cpp index 798e968..9ba7032 100644 --- a/src/problems/singleObjective/Sphere.cpp +++ b/src/problems/singleObjective/Sphere.cpp @@ -27,7 +27,7 @@ * @param solutionType The solution type must "Real", "BinaryReal, and "ArrayReal". * @param numberOfVariables Number of variables of the problem */ -Sphere::Sphere(string solutionType, int numberOfVariables) +Sphere::Sphere(std::string solutionType, int numberOfVariables) { numberOfVariables_ = numberOfVariables; numberOfObjectives_ = 1; @@ -37,14 +37,14 @@ Sphere::Sphere(string solutionType, int numberOfVariables) lowerLimit_ = snew double[numberOfVariables_]; if (lowerLimit_ == nullptr) { - cout << "Sphere::Sphere. Error reserving memory for storing the array of lower limits" << endl; + std::cout << "Sphere::Sphere. Error reserving memory for storing the array of lower limits" << std::endl; exit(-1) ; } upperLimit_ = snew double[numberOfVariables_]; if (upperLimit_ == nullptr) { - cout << "Sphere::Sphere. Error reserving memory for storing the array of upper limits" << endl; + std::cout << "Sphere::Sphere. Error reserving memory for storing the array of upper limits" << std::endl; exit(-1) ; } @@ -84,14 +84,14 @@ void Sphere::evaluate(Solution *solution) double * fx = snew double[numberOfObjectives_]; //(double *)malloc(sizeof(double) * numberOfObjectives_); if (fx == nullptr) { - cout << "Sphere::evaluate: Error reserving memory while evaluating the problem" << endl; + std::cout << "Sphere::evaluate: Error reserving memory while evaluating the problem" << std::endl; exit(-1); } double * x = snew double[numberOfVariables_]; if (x == nullptr) { - cout << "Sphere::evaluate: Error reserving memory for the variable values array" << endl; + std::cout << "Sphere::evaluate: Error reserving memory for the variable values array" << std::endl; exit(-1); } // if diff --git a/src/problems/singleObjective/cec2005Competition/Benchmark.cpp b/src/problems/singleObjective/cec2005Competition/Benchmark.cpp index 539948d..c0e91d8 100644 --- a/src/problems/singleObjective/cec2005Competition/Benchmark.cpp +++ b/src/problems/singleObjective/cec2005Competition/Benchmark.cpp @@ -22,8 +22,8 @@ #include //TODO: Cambiar ruta -//const string Benchmark::DEFAULT_FILE_BIAS = Configuration.cec2005SupportDataDirectory + "/fbias_data.txt"; -const string Benchmark::DEFAULT_FILE_BIAS = "../../data/cec2005CompetitionResources/supportData/fbias_data.txt"; +//const std::string Benchmark::DEFAULT_FILE_BIAS = Configuration.cec2005SupportDataDirectory + "/fbias_data.txt"; +const std::string Benchmark::DEFAULT_FILE_BIAS = "../../data/cec2005CompetitionResources/supportData/fbias_data.txt"; const int Benchmark::NUM_TEST_FUNC = 25; @@ -42,7 +42,7 @@ Benchmark::Benchmark() : Benchmark(DEFAULT_FILE_BIAS) {} /* * Constructor */ -Benchmark::Benchmark(string file_bias) +Benchmark::Benchmark(std::string file_bias) { m_biases = snew double[NUM_TEST_FUNC]; loadRowVectorFromFile(file_bias, NUM_TEST_FUNC, m_biases); @@ -148,7 +148,7 @@ TestFunc * Benchmark::testFunctionFactory(int func_num, int dimension) default: cerr << "Incorrect number of function. Expected an integer between " << - "1 and 25." << endl; + "1 and 25." << std::endl; exit(-1); } } @@ -527,7 +527,7 @@ void Benchmark::Ax(double * result, double ** A, double * x, int length) -void Benchmark::loadRowVectorFromFile(string file, int columns, double * row) +void Benchmark::loadRowVectorFromFile(std::string file, int columns, double * row) { // Open the file @@ -535,7 +535,7 @@ void Benchmark::loadRowVectorFromFile(string file, int columns, double * row) if( !in ) { cerr << "Benchmark::loadRowVectorFromFile: failed when reading from file : " << - file << endl; + file << std::endl; exit(-1); } else @@ -550,7 +550,7 @@ void Benchmark::loadRowVectorFromFile(string file, int columns, double * row) void Benchmark::loadRowVector(ifstream& in, int columns, double * row) { - string aux; + std::string aux; if (getline(in, aux)) { @@ -558,7 +558,7 @@ void Benchmark::loadRowVector(ifstream& in, int columns, double * row) istringstream iss(aux); for (int i = 0; i < columns; i++) { - string stToken; + std::string stToken; iss >> stToken; if (stToken.compare("")!=0) { @@ -567,7 +567,7 @@ void Benchmark::loadRowVector(ifstream& in, int columns, double * row) else { cerr << "Benchmark::loadRowVector: unexpected format encountered when " << - "reading from file (incorrect number of tokens)." << endl; + "reading from file (incorrect number of tokens)." << std::endl; exit(-1); } } @@ -575,18 +575,18 @@ void Benchmark::loadRowVector(ifstream& in, int columns, double * row) else { cerr << "Benchmark::loadRowVector: unexpected format encountered when " << - "reading from file (zero lines found)." << endl; + "reading from file (zero lines found)." << std::endl; exit(-1); } } -void Benchmark::loadNMatrixFromFile(string file, int N, int rows, int columns, double*** matrix) +void Benchmark::loadNMatrixFromFile(std::string file, int N, int rows, int columns, double*** matrix) { ifstream in(file.c_str()); if (!in) { cerr << "Benchmark::loadNMatrixFromFile: failed when reading from file : " << - file << endl; + file << std::endl; exit(-1); } else @@ -599,14 +599,14 @@ void Benchmark::loadNMatrixFromFile(string file, int N, int rows, int columns, d } } -void Benchmark::loadMatrixFromFile(string file, int rows, int columns, double ** matrix) +void Benchmark::loadMatrixFromFile(std::string file, int rows, int columns, double ** matrix) { // Open the file ifstream in(file.c_str()); if( !in ) { cerr << "Benchmark::loadRowVectorFromFile: failed when reading from file : " << - file << endl; + file << std::endl; exit(-1); } else diff --git a/src/problems/singleObjective/cec2005Competition/Benchmark.h b/src/problems/singleObjective/cec2005Competition/Benchmark.h index 49971cf..4ea2604 100644 --- a/src/problems/singleObjective/cec2005Competition/Benchmark.h +++ b/src/problems/singleObjective/cec2005Competition/Benchmark.h @@ -58,7 +58,7 @@ #include #include -using namespace std; + template int sgn(T val) { @@ -69,7 +69,7 @@ class Benchmark { private: - static const string DEFAULT_FILE_BIAS; + static const std::string DEFAULT_FILE_BIAS; static const int NUM_TEST_FUNC; @@ -84,7 +84,7 @@ class Benchmark public: Benchmark(); - Benchmark(string file_bias); + Benchmark(std::string file_bias); ~Benchmark(); // Random number generator @@ -125,10 +125,10 @@ class Benchmark static void Ax(double * result, double ** A, double * x, int length); // Utility functions for loading data from given text files - static void loadRowVectorFromFile(string file, int columns, double * row); + static void loadRowVectorFromFile(std::string file, int columns, double * row); static void loadRowVector(ifstream& brSrc, int columns, double * row); - static void loadNMatrixFromFile(string file, int N, int rows, int columns, double*** matrix); - static void loadMatrixFromFile(string file, int rows, int columns, double ** matrix); + static void loadNMatrixFromFile(std::string file, int N, int rows, int columns, double*** matrix); + static void loadMatrixFromFile(std::string file, int rows, int columns, double ** matrix); static void loadMatrix(ifstream& brSrc, int rows, int columns, double ** matrix); }; // Benchmark diff --git a/src/problems/singleObjective/cec2005Competition/F01ShiftedSphere.cpp b/src/problems/singleObjective/cec2005Competition/F01ShiftedSphere.cpp index a4b9386..af8a2d5 100644 --- a/src/problems/singleObjective/cec2005Competition/F01ShiftedSphere.cpp +++ b/src/problems/singleObjective/cec2005Competition/F01ShiftedSphere.cpp @@ -23,9 +23,9 @@ #include // Fixed (class) parameters -const string F01ShiftedSphere::FUNCTION_NAME = "Shifted Sphere Function"; +const std::string F01ShiftedSphere::FUNCTION_NAME = "Shifted Sphere Function"; // TODO: Cambiar ruta -const string F01ShiftedSphere::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/sphere_func_data.txt"; +const std::string F01ShiftedSphere::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/sphere_func_data.txt"; /** @@ -40,7 +40,7 @@ F01ShiftedSphere::F01ShiftedSphere(int dimension, double bias) /** * Constructor */ -F01ShiftedSphere::F01ShiftedSphere(int dimension, double bias, string file_data) +F01ShiftedSphere::F01ShiftedSphere(int dimension, double bias, std::string file_data) : TestFunc(dimension, bias, FUNCTION_NAME) { diff --git a/src/problems/singleObjective/cec2005Competition/F01ShiftedSphere.h b/src/problems/singleObjective/cec2005Competition/F01ShiftedSphere.h index c4d43d1..c786db6 100644 --- a/src/problems/singleObjective/cec2005Competition/F01ShiftedSphere.h +++ b/src/problems/singleObjective/cec2005Competition/F01ShiftedSphere.h @@ -31,8 +31,8 @@ class F01ShiftedSphere : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; // Shifted global optimum double * m_o; @@ -44,7 +44,7 @@ class F01ShiftedSphere : public TestFunc public: F01ShiftedSphere(int dimension, double bias); - F01ShiftedSphere(int dimension, double bias, string file_data); + F01ShiftedSphere(int dimension, double bias, std::string file_data); ~F01ShiftedSphere(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F02ShiftedSchwefel.cpp b/src/problems/singleObjective/cec2005Competition/F02ShiftedSchwefel.cpp index a70fb8e..b66ac50 100644 --- a/src/problems/singleObjective/cec2005Competition/F02ShiftedSchwefel.cpp +++ b/src/problems/singleObjective/cec2005Competition/F02ShiftedSchwefel.cpp @@ -23,9 +23,9 @@ #include // Fixed (class) parameters -const string F02ShiftedSchwefel::FUNCTION_NAME = "Shifted Schwefel's Problem 1.2"; +const std::string F02ShiftedSchwefel::FUNCTION_NAME = "Shifted Schwefel's Problem 1.2"; // TODO: Cambiar ruta -const string F02ShiftedSchwefel::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/schwefel_102_data.txt"; +const std::string F02ShiftedSchwefel::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/schwefel_102_data.txt"; /** @@ -40,7 +40,7 @@ F02ShiftedSchwefel::F02ShiftedSchwefel(int dimension, double bias) /** * Constructor */ -F02ShiftedSchwefel::F02ShiftedSchwefel(int dimension, double bias, string file_data) +F02ShiftedSchwefel::F02ShiftedSchwefel(int dimension, double bias, std::string file_data) : TestFunc(dimension, bias, FUNCTION_NAME) { diff --git a/src/problems/singleObjective/cec2005Competition/F02ShiftedSchwefel.h b/src/problems/singleObjective/cec2005Competition/F02ShiftedSchwefel.h index 52c078c..4013e7d 100644 --- a/src/problems/singleObjective/cec2005Competition/F02ShiftedSchwefel.h +++ b/src/problems/singleObjective/cec2005Competition/F02ShiftedSchwefel.h @@ -31,8 +31,8 @@ class F02ShiftedSchwefel : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; // Shifted global optimum double * m_o; @@ -44,7 +44,7 @@ class F02ShiftedSchwefel : public TestFunc public: F02ShiftedSchwefel(int dimension, double bias); - F02ShiftedSchwefel(int dimension, double bias, string file_data); + F02ShiftedSchwefel(int dimension, double bias, std::string file_data); ~F02ShiftedSchwefel(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F03ShiftedRotatedHighCondElliptic.cpp b/src/problems/singleObjective/cec2005Competition/F03ShiftedRotatedHighCondElliptic.cpp index 585c5b7..abb4b7c 100644 --- a/src/problems/singleObjective/cec2005Competition/F03ShiftedRotatedHighCondElliptic.cpp +++ b/src/problems/singleObjective/cec2005Competition/F03ShiftedRotatedHighCondElliptic.cpp @@ -24,11 +24,11 @@ #include "JMetalHeader.h" // Fixed (class) parameters -const string F03ShiftedRotatedHighCondElliptic::FUNCTION_NAME = "Shifted Rotated High Conditioned Elliptic Function"; +const std::string F03ShiftedRotatedHighCondElliptic::FUNCTION_NAME = "Shifted Rotated High Conditioned Elliptic Function"; // TODO: Cambiar ruta -const string F03ShiftedRotatedHighCondElliptic::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/high_cond_elliptic_rot_data.txt"; -const string F03ShiftedRotatedHighCondElliptic::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/Elliptic_M_D"; -const string F03ShiftedRotatedHighCondElliptic::DEFAULT_FILE_MX_SUFFIX = ".txt"; +const std::string F03ShiftedRotatedHighCondElliptic::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/high_cond_elliptic_rot_data.txt"; +const std::string F03ShiftedRotatedHighCondElliptic::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/Elliptic_M_D"; +const std::string F03ShiftedRotatedHighCondElliptic::DEFAULT_FILE_MX_SUFFIX = ".txt"; /** @@ -43,7 +43,7 @@ F03ShiftedRotatedHighCondElliptic::F03ShiftedRotatedHighCondElliptic(int dimensi /** * Constructor */ -F03ShiftedRotatedHighCondElliptic::F03ShiftedRotatedHighCondElliptic(int dimension, double bias, string file_data, string file_m) +F03ShiftedRotatedHighCondElliptic::F03ShiftedRotatedHighCondElliptic(int dimension, double bias, std::string file_data, std::string file_m) : TestFunc(dimension, bias, FUNCTION_NAME) { @@ -106,7 +106,7 @@ double F03ShiftedRotatedHighCondElliptic::f(double * x) } -string F03ShiftedRotatedHighCondElliptic::getFileMxName(string prefix, int dimension, string suffix) +std::string F03ShiftedRotatedHighCondElliptic::getFileMxName(std::string prefix, int dimension, std::string suffix) { std::stringstream sstm; sstm << prefix << dimension << suffix; diff --git a/src/problems/singleObjective/cec2005Competition/F03ShiftedRotatedHighCondElliptic.h b/src/problems/singleObjective/cec2005Competition/F03ShiftedRotatedHighCondElliptic.h index 09a57fd..aa026df 100644 --- a/src/problems/singleObjective/cec2005Competition/F03ShiftedRotatedHighCondElliptic.h +++ b/src/problems/singleObjective/cec2005Competition/F03ShiftedRotatedHighCondElliptic.h @@ -31,10 +31,10 @@ class F03ShiftedRotatedHighCondElliptic : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; + static const std::string DEFAULT_FILE_MX_PREFIX; + static const std::string DEFAULT_FILE_MX_SUFFIX; // Shifted global optimum double * m_o; @@ -47,12 +47,12 @@ class F03ShiftedRotatedHighCondElliptic : public TestFunc double constant; - string getFileMxName(string prefix, int dimension, string suffix); + std::string getFileMxName(std::string prefix, int dimension, std::string suffix); public: F03ShiftedRotatedHighCondElliptic(int dimension, double bias); - F03ShiftedRotatedHighCondElliptic(int dimension, double bias, string file_data, string file_m); + F03ShiftedRotatedHighCondElliptic(int dimension, double bias, std::string file_data, std::string file_m); ~F03ShiftedRotatedHighCondElliptic(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F04ShiftedSchwefelNoise.cpp b/src/problems/singleObjective/cec2005Competition/F04ShiftedSchwefelNoise.cpp index 3655823..fec44e8 100644 --- a/src/problems/singleObjective/cec2005Competition/F04ShiftedSchwefelNoise.cpp +++ b/src/problems/singleObjective/cec2005Competition/F04ShiftedSchwefelNoise.cpp @@ -23,9 +23,9 @@ #include // Fixed (class) parameters -const string F04ShiftedSchwefelNoise::FUNCTION_NAME = "Shifted Schwefel's Problem 1.2 with Noise in Fitness"; +const std::string F04ShiftedSchwefelNoise::FUNCTION_NAME = "Shifted Schwefel's Problem 1.2 with Noise in Fitness"; // TODO: Cambiar ruta -const string F04ShiftedSchwefelNoise::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/schwefel_102_data.txt"; +const std::string F04ShiftedSchwefelNoise::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/schwefel_102_data.txt"; /** @@ -40,7 +40,7 @@ F04ShiftedSchwefelNoise::F04ShiftedSchwefelNoise(int dimension, double bias) /** * Constructor */ -F04ShiftedSchwefelNoise::F04ShiftedSchwefelNoise(int dimension, double bias, string file_data) +F04ShiftedSchwefelNoise::F04ShiftedSchwefelNoise(int dimension, double bias, std::string file_data) : TestFunc(dimension, bias, FUNCTION_NAME) { diff --git a/src/problems/singleObjective/cec2005Competition/F04ShiftedSchwefelNoise.h b/src/problems/singleObjective/cec2005Competition/F04ShiftedSchwefelNoise.h index 546c326..9a6bb1f 100644 --- a/src/problems/singleObjective/cec2005Competition/F04ShiftedSchwefelNoise.h +++ b/src/problems/singleObjective/cec2005Competition/F04ShiftedSchwefelNoise.h @@ -31,8 +31,8 @@ class F04ShiftedSchwefelNoise : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; // Shifted global optimum double * m_o; @@ -44,7 +44,7 @@ class F04ShiftedSchwefelNoise : public TestFunc public: F04ShiftedSchwefelNoise(int dimension, double bias); - F04ShiftedSchwefelNoise(int dimension, double bias, string file_data); + F04ShiftedSchwefelNoise(int dimension, double bias, std::string file_data); ~F04ShiftedSchwefelNoise(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F05SchwefelGlobalOptBound.cpp b/src/problems/singleObjective/cec2005Competition/F05SchwefelGlobalOptBound.cpp index b1b6ab9..878791a 100644 --- a/src/problems/singleObjective/cec2005Competition/F05SchwefelGlobalOptBound.cpp +++ b/src/problems/singleObjective/cec2005Competition/F05SchwefelGlobalOptBound.cpp @@ -24,9 +24,9 @@ #include "JMetalHeader.h" // Fixed (class) parameters -const string F05SchwefelGlobalOptBound::FUNCTION_NAME = "Schwefel's Problem 2.6 with Global Optimum on Bounds"; +const std::string F05SchwefelGlobalOptBound::FUNCTION_NAME = "Schwefel's Problem 2.6 with Global Optimum on Bounds"; // TODO: Cambiar ruta -const string F05SchwefelGlobalOptBound::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/schwefel_206_data.txt"; +const std::string F05SchwefelGlobalOptBound::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/schwefel_206_data.txt"; /** @@ -41,7 +41,7 @@ F05SchwefelGlobalOptBound::F05SchwefelGlobalOptBound(int dimension, double bias) /** * Constructor */ -F05SchwefelGlobalOptBound::F05SchwefelGlobalOptBound(int dimension, double bias, string file_data) +F05SchwefelGlobalOptBound::F05SchwefelGlobalOptBound(int dimension, double bias, std::string file_data) : TestFunc(dimension, bias, FUNCTION_NAME) { diff --git a/src/problems/singleObjective/cec2005Competition/F05SchwefelGlobalOptBound.h b/src/problems/singleObjective/cec2005Competition/F05SchwefelGlobalOptBound.h index b6215c9..2f7a3fc 100644 --- a/src/problems/singleObjective/cec2005Competition/F05SchwefelGlobalOptBound.h +++ b/src/problems/singleObjective/cec2005Competition/F05SchwefelGlobalOptBound.h @@ -31,8 +31,8 @@ class F05SchwefelGlobalOptBound : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; // Shifted global optimum double * m_o; @@ -46,7 +46,7 @@ class F05SchwefelGlobalOptBound : public TestFunc public: F05SchwefelGlobalOptBound(int dimension, double bias); - F05SchwefelGlobalOptBound(int dimension, double bias, string file_data); + F05SchwefelGlobalOptBound(int dimension, double bias, std::string file_data); ~F05SchwefelGlobalOptBound(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F06ShiftedRosenbrock.cpp b/src/problems/singleObjective/cec2005Competition/F06ShiftedRosenbrock.cpp index 4187a60..11df9d8 100644 --- a/src/problems/singleObjective/cec2005Competition/F06ShiftedRosenbrock.cpp +++ b/src/problems/singleObjective/cec2005Competition/F06ShiftedRosenbrock.cpp @@ -23,9 +23,9 @@ #include // Fixed (class) parameters -const string F06ShiftedRosenbrock::FUNCTION_NAME = "Shifted Rosenbrock's Function"; +const std::string F06ShiftedRosenbrock::FUNCTION_NAME = "Shifted Rosenbrock's Function"; // TODO: Cambiar ruta -const string F06ShiftedRosenbrock::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/rosenbrock_func_data.txt"; +const std::string F06ShiftedRosenbrock::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/rosenbrock_func_data.txt"; /** @@ -40,7 +40,7 @@ F06ShiftedRosenbrock::F06ShiftedRosenbrock(int dimension, double bias) /** * Constructor */ -F06ShiftedRosenbrock::F06ShiftedRosenbrock(int dimension, double bias, string file_data) +F06ShiftedRosenbrock::F06ShiftedRosenbrock(int dimension, double bias, std::string file_data) : TestFunc(dimension, bias, FUNCTION_NAME) { diff --git a/src/problems/singleObjective/cec2005Competition/F06ShiftedRosenbrock.h b/src/problems/singleObjective/cec2005Competition/F06ShiftedRosenbrock.h index 8eb2bd5..c9b14f3 100644 --- a/src/problems/singleObjective/cec2005Competition/F06ShiftedRosenbrock.h +++ b/src/problems/singleObjective/cec2005Competition/F06ShiftedRosenbrock.h @@ -31,8 +31,8 @@ class F06ShiftedRosenbrock : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; // Shifted global optimum double * m_o; @@ -44,7 +44,7 @@ class F06ShiftedRosenbrock : public TestFunc public: F06ShiftedRosenbrock(int dimension, double bias); - F06ShiftedRosenbrock(int dimension, double bias, string file_data); + F06ShiftedRosenbrock(int dimension, double bias, std::string file_data); ~F06ShiftedRosenbrock(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F07ShiftedRotatedGriewank.cpp b/src/problems/singleObjective/cec2005Competition/F07ShiftedRotatedGriewank.cpp index 9c5fe3f..9c19171 100644 --- a/src/problems/singleObjective/cec2005Competition/F07ShiftedRotatedGriewank.cpp +++ b/src/problems/singleObjective/cec2005Competition/F07ShiftedRotatedGriewank.cpp @@ -24,11 +24,11 @@ #include "JMetalHeader.h" // Fixed (class) parameters -const string F07ShiftedRotatedGriewank::FUNCTION_NAME = "Shifted Rotated Griewank's Function without Bounds"; +const std::string F07ShiftedRotatedGriewank::FUNCTION_NAME = "Shifted Rotated Griewank's Function without Bounds"; // TODO: Cambiar ruta -const string F07ShiftedRotatedGriewank::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/griewank_func_data.txt"; -const string F07ShiftedRotatedGriewank::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/griewank_M_D"; -const string F07ShiftedRotatedGriewank::DEFAULT_FILE_MX_SUFFIX = ".txt"; +const std::string F07ShiftedRotatedGriewank::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/griewank_func_data.txt"; +const std::string F07ShiftedRotatedGriewank::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/griewank_M_D"; +const std::string F07ShiftedRotatedGriewank::DEFAULT_FILE_MX_SUFFIX = ".txt"; /** @@ -43,7 +43,7 @@ F07ShiftedRotatedGriewank::F07ShiftedRotatedGriewank(int dimension, double bias) /** * Constructor */ -F07ShiftedRotatedGriewank::F07ShiftedRotatedGriewank(int dimension, double bias, string file_data, string file_m) +F07ShiftedRotatedGriewank::F07ShiftedRotatedGriewank(int dimension, double bias, std::string file_data, std::string file_m) : TestFunc(dimension, bias, FUNCTION_NAME) { @@ -99,7 +99,7 @@ double F07ShiftedRotatedGriewank::f(double * x) } -string F07ShiftedRotatedGriewank::getFileMxName(string prefix, int dimension, string suffix) +std::string F07ShiftedRotatedGriewank::getFileMxName(std::string prefix, int dimension, std::string suffix) { std::stringstream sstm; sstm << prefix << dimension << suffix; diff --git a/src/problems/singleObjective/cec2005Competition/F07ShiftedRotatedGriewank.h b/src/problems/singleObjective/cec2005Competition/F07ShiftedRotatedGriewank.h index 3d5cb5b..69bd7e6 100644 --- a/src/problems/singleObjective/cec2005Competition/F07ShiftedRotatedGriewank.h +++ b/src/problems/singleObjective/cec2005Competition/F07ShiftedRotatedGriewank.h @@ -31,10 +31,10 @@ class F07ShiftedRotatedGriewank : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; + static const std::string DEFAULT_FILE_MX_PREFIX; + static const std::string DEFAULT_FILE_MX_SUFFIX; // Shifted global optimum double * m_o; @@ -45,12 +45,12 @@ class F07ShiftedRotatedGriewank : public TestFunc double * m_z; double * m_zM; - string getFileMxName(string prefix, int dimension, string suffix); + std::string getFileMxName(std::string prefix, int dimension, std::string suffix); public: F07ShiftedRotatedGriewank(int dimension, double bias); - F07ShiftedRotatedGriewank(int dimension, double bias, string file_data, string file_m); + F07ShiftedRotatedGriewank(int dimension, double bias, std::string file_data, std::string file_m); ~F07ShiftedRotatedGriewank(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F08ShiftedRotatedAckleyGlobalOptBound.cpp b/src/problems/singleObjective/cec2005Competition/F08ShiftedRotatedAckleyGlobalOptBound.cpp index 22fbfb6..46242d4 100644 --- a/src/problems/singleObjective/cec2005Competition/F08ShiftedRotatedAckleyGlobalOptBound.cpp +++ b/src/problems/singleObjective/cec2005Competition/F08ShiftedRotatedAckleyGlobalOptBound.cpp @@ -24,11 +24,11 @@ #include "JMetalHeader.h" // Fixed (class) parameters -const string F08ShiftedRotatedAckleyGlobalOptBound::FUNCTION_NAME = "Shifted Rotated Ackley's Function with Global Optimum on Bounds"; +const std::string F08ShiftedRotatedAckleyGlobalOptBound::FUNCTION_NAME = "Shifted Rotated Ackley's Function with Global Optimum on Bounds"; // TODO: Cambiar ruta -const string F08ShiftedRotatedAckleyGlobalOptBound::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/ackley_func_data.txt"; -const string F08ShiftedRotatedAckleyGlobalOptBound::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/ackley_M_D"; -const string F08ShiftedRotatedAckleyGlobalOptBound::DEFAULT_FILE_MX_SUFFIX = ".txt"; +const std::string F08ShiftedRotatedAckleyGlobalOptBound::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/ackley_func_data.txt"; +const std::string F08ShiftedRotatedAckleyGlobalOptBound::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/ackley_M_D"; +const std::string F08ShiftedRotatedAckleyGlobalOptBound::DEFAULT_FILE_MX_SUFFIX = ".txt"; /** @@ -43,7 +43,7 @@ F08ShiftedRotatedAckleyGlobalOptBound::F08ShiftedRotatedAckleyGlobalOptBound(int /** * Constructor */ -F08ShiftedRotatedAckleyGlobalOptBound::F08ShiftedRotatedAckleyGlobalOptBound(int dimension, double bias, string file_data, string file_m) +F08ShiftedRotatedAckleyGlobalOptBound::F08ShiftedRotatedAckleyGlobalOptBound(int dimension, double bias, std::string file_data, std::string file_m) : TestFunc(dimension, bias, FUNCTION_NAME) { @@ -104,7 +104,7 @@ double F08ShiftedRotatedAckleyGlobalOptBound::f(double * x) } -string F08ShiftedRotatedAckleyGlobalOptBound::getFileMxName(string prefix, int dimension, string suffix) +std::string F08ShiftedRotatedAckleyGlobalOptBound::getFileMxName(std::string prefix, int dimension, std::string suffix) { std::stringstream sstm; sstm << prefix << dimension << suffix; diff --git a/src/problems/singleObjective/cec2005Competition/F08ShiftedRotatedAckleyGlobalOptBound.h b/src/problems/singleObjective/cec2005Competition/F08ShiftedRotatedAckleyGlobalOptBound.h index bfa3f8b..95d3c40 100644 --- a/src/problems/singleObjective/cec2005Competition/F08ShiftedRotatedAckleyGlobalOptBound.h +++ b/src/problems/singleObjective/cec2005Competition/F08ShiftedRotatedAckleyGlobalOptBound.h @@ -31,10 +31,10 @@ class F08ShiftedRotatedAckleyGlobalOptBound : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; + static const std::string DEFAULT_FILE_MX_PREFIX; + static const std::string DEFAULT_FILE_MX_SUFFIX; // Shifted global optimum double * m_o; @@ -45,12 +45,12 @@ class F08ShiftedRotatedAckleyGlobalOptBound : public TestFunc double * m_z; double * m_zM; - string getFileMxName(string prefix, int dimension, string suffix); + std::string getFileMxName(std::string prefix, int dimension, std::string suffix); public: F08ShiftedRotatedAckleyGlobalOptBound(int dimension, double bias); - F08ShiftedRotatedAckleyGlobalOptBound(int dimension, double bias, string file_data, string file_m); + F08ShiftedRotatedAckleyGlobalOptBound(int dimension, double bias, std::string file_data, std::string file_m); ~F08ShiftedRotatedAckleyGlobalOptBound(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F09ShiftedRastrigin.cpp b/src/problems/singleObjective/cec2005Competition/F09ShiftedRastrigin.cpp index 14df80e..3596391 100644 --- a/src/problems/singleObjective/cec2005Competition/F09ShiftedRastrigin.cpp +++ b/src/problems/singleObjective/cec2005Competition/F09ShiftedRastrigin.cpp @@ -23,9 +23,9 @@ #include // Fixed (class) parameters -const string F09ShiftedRastrigin::FUNCTION_NAME = "Shifted Rastrigin's Function"; +const std::string F09ShiftedRastrigin::FUNCTION_NAME = "Shifted Rastrigin's Function"; // TODO: Cambiar ruta -const string F09ShiftedRastrigin::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/rastrigin_func_data.txt"; +const std::string F09ShiftedRastrigin::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/rastrigin_func_data.txt"; /** @@ -40,7 +40,7 @@ F09ShiftedRastrigin::F09ShiftedRastrigin(int dimension, double bias) /** * Constructor */ -F09ShiftedRastrigin::F09ShiftedRastrigin(int dimension, double bias, string file_data) +F09ShiftedRastrigin::F09ShiftedRastrigin(int dimension, double bias, std::string file_data) : TestFunc(dimension, bias, FUNCTION_NAME) { diff --git a/src/problems/singleObjective/cec2005Competition/F09ShiftedRastrigin.h b/src/problems/singleObjective/cec2005Competition/F09ShiftedRastrigin.h index 3fd4923..2442a73 100644 --- a/src/problems/singleObjective/cec2005Competition/F09ShiftedRastrigin.h +++ b/src/problems/singleObjective/cec2005Competition/F09ShiftedRastrigin.h @@ -31,8 +31,8 @@ class F09ShiftedRastrigin : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; // Shifted global optimum double * m_o; @@ -44,7 +44,7 @@ class F09ShiftedRastrigin : public TestFunc public: F09ShiftedRastrigin(int dimension, double bias); - F09ShiftedRastrigin(int dimension, double bias, string file_data); + F09ShiftedRastrigin(int dimension, double bias, std::string file_data); ~F09ShiftedRastrigin(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F10ShiftedRotatedRastrigin.cpp b/src/problems/singleObjective/cec2005Competition/F10ShiftedRotatedRastrigin.cpp index 9ad9afe..9c38489 100644 --- a/src/problems/singleObjective/cec2005Competition/F10ShiftedRotatedRastrigin.cpp +++ b/src/problems/singleObjective/cec2005Competition/F10ShiftedRotatedRastrigin.cpp @@ -24,11 +24,11 @@ #include "JMetalHeader.h" // Fixed (class) parameters -const string F10ShiftedRotatedRastrigin::FUNCTION_NAME = "Shifted Rotated Rastrigin's Function"; +const std::string F10ShiftedRotatedRastrigin::FUNCTION_NAME = "Shifted Rotated Rastrigin's Function"; // TODO: Cambiar ruta -const string F10ShiftedRotatedRastrigin::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/rastrigin_func_data.txt"; -const string F10ShiftedRotatedRastrigin::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/rastrigin_M_D"; -const string F10ShiftedRotatedRastrigin::DEFAULT_FILE_MX_SUFFIX = ".txt"; +const std::string F10ShiftedRotatedRastrigin::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/rastrigin_func_data.txt"; +const std::string F10ShiftedRotatedRastrigin::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/rastrigin_M_D"; +const std::string F10ShiftedRotatedRastrigin::DEFAULT_FILE_MX_SUFFIX = ".txt"; /** @@ -43,7 +43,7 @@ F10ShiftedRotatedRastrigin::F10ShiftedRotatedRastrigin(int dimension, double bia /** * Constructor */ -F10ShiftedRotatedRastrigin::F10ShiftedRotatedRastrigin(int dimension, double bias, string file_data, string file_m) +F10ShiftedRotatedRastrigin::F10ShiftedRotatedRastrigin(int dimension, double bias, std::string file_data, std::string file_m) : TestFunc(dimension, bias, FUNCTION_NAME) { @@ -99,7 +99,7 @@ double F10ShiftedRotatedRastrigin::f(double * x) } -string F10ShiftedRotatedRastrigin::getFileMxName(string prefix, int dimension, string suffix) +std::string F10ShiftedRotatedRastrigin::getFileMxName(std::string prefix, int dimension, std::string suffix) { std::stringstream sstm; sstm << prefix << dimension << suffix; diff --git a/src/problems/singleObjective/cec2005Competition/F10ShiftedRotatedRastrigin.h b/src/problems/singleObjective/cec2005Competition/F10ShiftedRotatedRastrigin.h index 5f99773..5126989 100644 --- a/src/problems/singleObjective/cec2005Competition/F10ShiftedRotatedRastrigin.h +++ b/src/problems/singleObjective/cec2005Competition/F10ShiftedRotatedRastrigin.h @@ -31,10 +31,10 @@ class F10ShiftedRotatedRastrigin : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; + static const std::string DEFAULT_FILE_MX_PREFIX; + static const std::string DEFAULT_FILE_MX_SUFFIX; // Shifted global optimum double * m_o; @@ -45,12 +45,12 @@ class F10ShiftedRotatedRastrigin : public TestFunc double * m_z; double * m_zM; - string getFileMxName(string prefix, int dimension, string suffix); + std::string getFileMxName(std::string prefix, int dimension, std::string suffix); public: F10ShiftedRotatedRastrigin(int dimension, double bias); - F10ShiftedRotatedRastrigin(int dimension, double bias, string file_data, string file_m); + F10ShiftedRotatedRastrigin(int dimension, double bias, std::string file_data, std::string file_m); ~F10ShiftedRotatedRastrigin(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F11ShiftedRotatedWeierstrass.cpp b/src/problems/singleObjective/cec2005Competition/F11ShiftedRotatedWeierstrass.cpp index e3a8bb5..52e78e5 100644 --- a/src/problems/singleObjective/cec2005Competition/F11ShiftedRotatedWeierstrass.cpp +++ b/src/problems/singleObjective/cec2005Competition/F11ShiftedRotatedWeierstrass.cpp @@ -24,11 +24,11 @@ #include "JMetalHeader.h" // Fixed (class) parameters -const string F11ShiftedRotatedWeierstrass::FUNCTION_NAME = "Shifted Rotated Weierstrass Function"; +const std::string F11ShiftedRotatedWeierstrass::FUNCTION_NAME = "Shifted Rotated Weierstrass Function"; // TODO: Cambiar ruta -const string F11ShiftedRotatedWeierstrass::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/weierstrass_data.txt"; -const string F11ShiftedRotatedWeierstrass::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/weierstrass_M_D"; -const string F11ShiftedRotatedWeierstrass::DEFAULT_FILE_MX_SUFFIX = ".txt"; +const std::string F11ShiftedRotatedWeierstrass::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/weierstrass_data.txt"; +const std::string F11ShiftedRotatedWeierstrass::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/weierstrass_M_D"; +const std::string F11ShiftedRotatedWeierstrass::DEFAULT_FILE_MX_SUFFIX = ".txt"; const int F11ShiftedRotatedWeierstrass::Kmax = 20; const double F11ShiftedRotatedWeierstrass::a = 0.5; @@ -47,7 +47,7 @@ F11ShiftedRotatedWeierstrass::F11ShiftedRotatedWeierstrass(int dimension, double /** * Constructor */ -F11ShiftedRotatedWeierstrass::F11ShiftedRotatedWeierstrass(int dimension, double bias, string file_data, string file_m) +F11ShiftedRotatedWeierstrass::F11ShiftedRotatedWeierstrass(int dimension, double bias, std::string file_data, std::string file_m) : TestFunc(dimension, bias, FUNCTION_NAME) { @@ -103,7 +103,7 @@ double F11ShiftedRotatedWeierstrass::f(double * x) } -string F11ShiftedRotatedWeierstrass::getFileMxName(string prefix, int dimension, string suffix) +std::string F11ShiftedRotatedWeierstrass::getFileMxName(std::string prefix, int dimension, std::string suffix) { std::stringstream sstm; sstm << prefix << dimension << suffix; diff --git a/src/problems/singleObjective/cec2005Competition/F11ShiftedRotatedWeierstrass.h b/src/problems/singleObjective/cec2005Competition/F11ShiftedRotatedWeierstrass.h index cee750e..64e05c4 100644 --- a/src/problems/singleObjective/cec2005Competition/F11ShiftedRotatedWeierstrass.h +++ b/src/problems/singleObjective/cec2005Competition/F11ShiftedRotatedWeierstrass.h @@ -31,10 +31,10 @@ class F11ShiftedRotatedWeierstrass : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; + static const std::string DEFAULT_FILE_MX_PREFIX; + static const std::string DEFAULT_FILE_MX_SUFFIX; static const int Kmax; static const double a; @@ -49,12 +49,12 @@ class F11ShiftedRotatedWeierstrass : public TestFunc double * m_z; double * m_zM; - string getFileMxName(string prefix, int dimension, string suffix); + std::string getFileMxName(std::string prefix, int dimension, std::string suffix); public: F11ShiftedRotatedWeierstrass(int dimension, double bias); - F11ShiftedRotatedWeierstrass(int dimension, double bias, string file_data, string file_m); + F11ShiftedRotatedWeierstrass(int dimension, double bias, std::string file_data, std::string file_m); ~F11ShiftedRotatedWeierstrass(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F12Schwefel.cpp b/src/problems/singleObjective/cec2005Competition/F12Schwefel.cpp index 504a73f..4e7dbc9 100644 --- a/src/problems/singleObjective/cec2005Competition/F12Schwefel.cpp +++ b/src/problems/singleObjective/cec2005Competition/F12Schwefel.cpp @@ -24,9 +24,9 @@ #include "JMetalHeader.h" // Fixed (class) parameters -const string F12Schwefel::FUNCTION_NAME = "Schwefel's Problem 2.13"; +const std::string F12Schwefel::FUNCTION_NAME = "Schwefel's Problem 2.13"; // TODO: Cambiar ruta -const string F12Schwefel::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/schwefel_213_data.txt"; +const std::string F12Schwefel::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/schwefel_213_data.txt"; /** @@ -41,7 +41,7 @@ F12Schwefel::F12Schwefel(int dimension, double bias) /** * Constructor */ -F12Schwefel::F12Schwefel(int dimension, double bias, string file_data) +F12Schwefel::F12Schwefel(int dimension, double bias, std::string file_data) : TestFunc(dimension, bias, FUNCTION_NAME) { diff --git a/src/problems/singleObjective/cec2005Competition/F12Schwefel.h b/src/problems/singleObjective/cec2005Competition/F12Schwefel.h index cf4c3b4..7b547e3 100644 --- a/src/problems/singleObjective/cec2005Competition/F12Schwefel.h +++ b/src/problems/singleObjective/cec2005Competition/F12Schwefel.h @@ -31,8 +31,8 @@ class F12Schwefel : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; // Shifted global optimum double * m_o; @@ -47,7 +47,7 @@ class F12Schwefel : public TestFunc public: F12Schwefel(int dimension, double bias); - F12Schwefel(int dimension, double bias, string file_data); + F12Schwefel(int dimension, double bias, std::string file_data); ~F12Schwefel(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F13ShiftedExpandedGriewankRosenbrock.cpp b/src/problems/singleObjective/cec2005Competition/F13ShiftedExpandedGriewankRosenbrock.cpp index 64fb886..ae03be4 100644 --- a/src/problems/singleObjective/cec2005Competition/F13ShiftedExpandedGriewankRosenbrock.cpp +++ b/src/problems/singleObjective/cec2005Competition/F13ShiftedExpandedGriewankRosenbrock.cpp @@ -23,9 +23,9 @@ #include // Fixed (class) parameters -const string F13ShiftedExpandedGriewankRosenbrock::FUNCTION_NAME = "Shifted Expanded Griewank's plus Rosenbrock's Function"; +const std::string F13ShiftedExpandedGriewankRosenbrock::FUNCTION_NAME = "Shifted Expanded Griewank's plus Rosenbrock's Function"; // TODO: Cambiar ruta -const string F13ShiftedExpandedGriewankRosenbrock::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/EF8F2_func_data.txt"; +const std::string F13ShiftedExpandedGriewankRosenbrock::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/EF8F2_func_data.txt"; /** @@ -40,7 +40,7 @@ F13ShiftedExpandedGriewankRosenbrock::F13ShiftedExpandedGriewankRosenbrock(int d /** * Constructor */ -F13ShiftedExpandedGriewankRosenbrock::F13ShiftedExpandedGriewankRosenbrock(int dimension, double bias, string file_data) +F13ShiftedExpandedGriewankRosenbrock::F13ShiftedExpandedGriewankRosenbrock(int dimension, double bias, std::string file_data) : TestFunc(dimension, bias, FUNCTION_NAME) { diff --git a/src/problems/singleObjective/cec2005Competition/F13ShiftedExpandedGriewankRosenbrock.h b/src/problems/singleObjective/cec2005Competition/F13ShiftedExpandedGriewankRosenbrock.h index daf5b7a..60565c5 100644 --- a/src/problems/singleObjective/cec2005Competition/F13ShiftedExpandedGriewankRosenbrock.h +++ b/src/problems/singleObjective/cec2005Competition/F13ShiftedExpandedGriewankRosenbrock.h @@ -31,8 +31,8 @@ class F13ShiftedExpandedGriewankRosenbrock : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; // Shifted global optimum double * m_o; @@ -44,7 +44,7 @@ class F13ShiftedExpandedGriewankRosenbrock : public TestFunc public: F13ShiftedExpandedGriewankRosenbrock(int dimension, double bias); - F13ShiftedExpandedGriewankRosenbrock(int dimension, double bias, string file_data); + F13ShiftedExpandedGriewankRosenbrock(int dimension, double bias, std::string file_data); ~F13ShiftedExpandedGriewankRosenbrock(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F14ShiftedRotatedExpandedScaffer.cpp b/src/problems/singleObjective/cec2005Competition/F14ShiftedRotatedExpandedScaffer.cpp index cabcd4b..4b190c9 100644 --- a/src/problems/singleObjective/cec2005Competition/F14ShiftedRotatedExpandedScaffer.cpp +++ b/src/problems/singleObjective/cec2005Competition/F14ShiftedRotatedExpandedScaffer.cpp @@ -24,11 +24,11 @@ #include "JMetalHeader.h" // Fixed (class) parameters -const string F14ShiftedRotatedExpandedScaffer::FUNCTION_NAME = "Shifted Rotated Expanded Scaffer's F6 Function"; +const std::string F14ShiftedRotatedExpandedScaffer::FUNCTION_NAME = "Shifted Rotated Expanded Scaffer's F6 Function"; // TODO: Cambiar ruta -const string F14ShiftedRotatedExpandedScaffer::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/E_ScafferF6_func_data.txt"; -const string F14ShiftedRotatedExpandedScaffer::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/E_ScafferF6_M_D"; -const string F14ShiftedRotatedExpandedScaffer::DEFAULT_FILE_MX_SUFFIX = ".txt"; +const std::string F14ShiftedRotatedExpandedScaffer::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/E_ScafferF6_func_data.txt"; +const std::string F14ShiftedRotatedExpandedScaffer::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/E_ScafferF6_M_D"; +const std::string F14ShiftedRotatedExpandedScaffer::DEFAULT_FILE_MX_SUFFIX = ".txt"; /** @@ -43,7 +43,7 @@ F14ShiftedRotatedExpandedScaffer::F14ShiftedRotatedExpandedScaffer(int dimension /** * Constructor */ -F14ShiftedRotatedExpandedScaffer::F14ShiftedRotatedExpandedScaffer(int dimension, double bias, string file_data, string file_m) +F14ShiftedRotatedExpandedScaffer::F14ShiftedRotatedExpandedScaffer(int dimension, double bias, std::string file_data, std::string file_m) : TestFunc(dimension, bias, FUNCTION_NAME) { @@ -99,7 +99,7 @@ double F14ShiftedRotatedExpandedScaffer::f(double * x) } -string F14ShiftedRotatedExpandedScaffer::getFileMxName(string prefix, int dimension, string suffix) +std::string F14ShiftedRotatedExpandedScaffer::getFileMxName(std::string prefix, int dimension, std::string suffix) { std::stringstream sstm; sstm << prefix << dimension << suffix; diff --git a/src/problems/singleObjective/cec2005Competition/F14ShiftedRotatedExpandedScaffer.h b/src/problems/singleObjective/cec2005Competition/F14ShiftedRotatedExpandedScaffer.h index d81c734..8e970a4 100644 --- a/src/problems/singleObjective/cec2005Competition/F14ShiftedRotatedExpandedScaffer.h +++ b/src/problems/singleObjective/cec2005Competition/F14ShiftedRotatedExpandedScaffer.h @@ -31,10 +31,10 @@ class F14ShiftedRotatedExpandedScaffer : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; + static const std::string DEFAULT_FILE_MX_PREFIX; + static const std::string DEFAULT_FILE_MX_SUFFIX; // Shifted global optimum double * m_o; @@ -45,12 +45,12 @@ class F14ShiftedRotatedExpandedScaffer : public TestFunc double * m_z; double * m_zM; - string getFileMxName(string prefix, int dimension, string suffix); + std::string getFileMxName(std::string prefix, int dimension, std::string suffix); public: F14ShiftedRotatedExpandedScaffer(int dimension, double bias); - F14ShiftedRotatedExpandedScaffer(int dimension, double bias, string file_data, string file_m); + F14ShiftedRotatedExpandedScaffer(int dimension, double bias, std::string file_data, std::string file_m); ~F14ShiftedRotatedExpandedScaffer(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F15HybridComposition1.cpp b/src/problems/singleObjective/cec2005Competition/F15HybridComposition1.cpp index 3b95631..3fb8db7 100644 --- a/src/problems/singleObjective/cec2005Competition/F15HybridComposition1.cpp +++ b/src/problems/singleObjective/cec2005Competition/F15HybridComposition1.cpp @@ -24,9 +24,9 @@ #include "JMetalHeader.h" // Fixed (class) parameters -const string F15HybridComposition1::FUNCTION_NAME = "Hybrid Composition Function 1"; +const std::string F15HybridComposition1::FUNCTION_NAME = "Hybrid Composition Function 1"; // TODO: Cambiar ruta -const string F15HybridComposition1::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/hybrid_func1_data.txt"; +const std::string F15HybridComposition1::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/hybrid_func1_data.txt"; const double F15HybridComposition1::m_sigma[NUM_FUNC] = @@ -61,7 +61,7 @@ F15HybridComposition1::F15HybridComposition1(int dimension, double bias) /** * Constructor */ -F15HybridComposition1::F15HybridComposition1(int dimension, double bias, string file_data) +F15HybridComposition1::F15HybridComposition1(int dimension, double bias, std::string file_data) : TestFunc(dimension, bias, FUNCTION_NAME) { @@ -200,7 +200,7 @@ double F15HybridComposition1::MyHCJob::basic_func(int func_no, double* x, int le result = Benchmark::sphere(x, length); break; default: - cerr << "func_no is out of range." << endl; + cerr << "func_no is out of range." << std::endl; exit(-1); } return (result); diff --git a/src/problems/singleObjective/cec2005Competition/F15HybridComposition1.h b/src/problems/singleObjective/cec2005Competition/F15HybridComposition1.h index f97a705..9c652b3 100644 --- a/src/problems/singleObjective/cec2005Competition/F15HybridComposition1.h +++ b/src/problems/singleObjective/cec2005Competition/F15HybridComposition1.h @@ -32,8 +32,8 @@ class F15HybridComposition1 : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; // Number of functions static const int NUM_FUNC = 10; @@ -66,7 +66,7 @@ class F15HybridComposition1 : public TestFunc public: F15HybridComposition1(int dimension, double bias); - F15HybridComposition1(int dimension, double bias, string file_data); + F15HybridComposition1(int dimension, double bias, std::string file_data); ~F15HybridComposition1(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F16RotatedHybridComposition1.cpp b/src/problems/singleObjective/cec2005Competition/F16RotatedHybridComposition1.cpp index becd332..5bd01e2 100644 --- a/src/problems/singleObjective/cec2005Competition/F16RotatedHybridComposition1.cpp +++ b/src/problems/singleObjective/cec2005Competition/F16RotatedHybridComposition1.cpp @@ -24,11 +24,11 @@ #include "JMetalHeader.h" // Fixed (class) parameters -const string F16RotatedHybridComposition1::FUNCTION_NAME = "Rotated Hybrid Composition Function 1"; +const std::string F16RotatedHybridComposition1::FUNCTION_NAME = "Rotated Hybrid Composition Function 1"; // TODO: Cambiar ruta -const string F16RotatedHybridComposition1::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/hybrid_func1_data.txt"; -const string F16RotatedHybridComposition1::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func1_M_D"; -const string F16RotatedHybridComposition1::DEFAULT_FILE_MX_SUFFIX = ".txt"; +const std::string F16RotatedHybridComposition1::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/hybrid_func1_data.txt"; +const std::string F16RotatedHybridComposition1::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func1_M_D"; +const std::string F16RotatedHybridComposition1::DEFAULT_FILE_MX_SUFFIX = ".txt"; const double F16RotatedHybridComposition1::m_sigma[NUM_FUNC] = { @@ -62,7 +62,7 @@ F16RotatedHybridComposition1::F16RotatedHybridComposition1(int dimension, double /** * Constructor */ -F16RotatedHybridComposition1::F16RotatedHybridComposition1(int dimension, double bias, string file_data, string file_m) +F16RotatedHybridComposition1::F16RotatedHybridComposition1(int dimension, double bias, std::string file_data, std::string file_m) : TestFunc(dimension, bias, FUNCTION_NAME) { @@ -191,7 +191,7 @@ double F16RotatedHybridComposition1::MyHCJob::basic_func(int func_no, double* x, result = Benchmark::sphere(x, length); break; default: - cerr << "func_no is out of range." << endl; + cerr << "func_no is out of range." << std::endl; exit(-1); } return (result); @@ -213,7 +213,7 @@ double F16RotatedHybridComposition1::f(double * x) } -string F16RotatedHybridComposition1::getFileMxName(string prefix, int dimension, string suffix) +std::string F16RotatedHybridComposition1::getFileMxName(std::string prefix, int dimension, std::string suffix) { std::stringstream sstm; sstm << prefix << dimension << suffix; diff --git a/src/problems/singleObjective/cec2005Competition/F16RotatedHybridComposition1.h b/src/problems/singleObjective/cec2005Competition/F16RotatedHybridComposition1.h index 5c9e896..971208a 100644 --- a/src/problems/singleObjective/cec2005Competition/F16RotatedHybridComposition1.h +++ b/src/problems/singleObjective/cec2005Competition/F16RotatedHybridComposition1.h @@ -32,10 +32,10 @@ class F16RotatedHybridComposition1 : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; + static const std::string DEFAULT_FILE_MX_PREFIX; + static const std::string DEFAULT_FILE_MX_SUFFIX; // Number of functions static const int NUM_FUNC = 10; @@ -65,12 +65,12 @@ class F16RotatedHybridComposition1 : public TestFunc MyHCJob * theJob; - string getFileMxName(string prefix, int dimension, string suffix); + std::string getFileMxName(std::string prefix, int dimension, std::string suffix); public: F16RotatedHybridComposition1(int dimension, double bias); - F16RotatedHybridComposition1(int dimension, double bias, string file_data, string file_m); + F16RotatedHybridComposition1(int dimension, double bias, std::string file_data, std::string file_m); ~F16RotatedHybridComposition1(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F17RotatedHybridComposition1Noise.cpp b/src/problems/singleObjective/cec2005Competition/F17RotatedHybridComposition1Noise.cpp index cf5e227..42478a6 100644 --- a/src/problems/singleObjective/cec2005Competition/F17RotatedHybridComposition1Noise.cpp +++ b/src/problems/singleObjective/cec2005Competition/F17RotatedHybridComposition1Noise.cpp @@ -24,11 +24,11 @@ #include "JMetalHeader.h" // Fixed (class) parameters -const string F17RotatedHybridComposition1Noise::FUNCTION_NAME = "Rotated Hybrid Composition Function 1 with Noise in Fitness"; +const std::string F17RotatedHybridComposition1Noise::FUNCTION_NAME = "Rotated Hybrid Composition Function 1 with Noise in Fitness"; // TODO: Cambiar ruta -const string F17RotatedHybridComposition1Noise::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/hybrid_func1_data.txt"; -const string F17RotatedHybridComposition1Noise::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func1_M_D"; -const string F17RotatedHybridComposition1Noise::DEFAULT_FILE_MX_SUFFIX = ".txt"; +const std::string F17RotatedHybridComposition1Noise::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/hybrid_func1_data.txt"; +const std::string F17RotatedHybridComposition1Noise::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func1_M_D"; +const std::string F17RotatedHybridComposition1Noise::DEFAULT_FILE_MX_SUFFIX = ".txt"; const double F17RotatedHybridComposition1Noise::m_sigma[NUM_FUNC] = { @@ -62,7 +62,7 @@ F17RotatedHybridComposition1Noise::F17RotatedHybridComposition1Noise(int dimensi /** * Constructor */ -F17RotatedHybridComposition1Noise::F17RotatedHybridComposition1Noise(int dimension, double bias, string file_data, string file_m) +F17RotatedHybridComposition1Noise::F17RotatedHybridComposition1Noise(int dimension, double bias, std::string file_data, std::string file_m) : TestFunc(dimension, bias, FUNCTION_NAME) { @@ -191,7 +191,7 @@ double F17RotatedHybridComposition1Noise::MyHCJob::basic_func(int func_no, doubl result = Benchmark::sphere(x, length); break; default: - cerr << "func_no is out of range." << endl; + cerr << "func_no is out of range." << std::endl; exit(-1); } return (result); @@ -217,7 +217,7 @@ double F17RotatedHybridComposition1Noise::f(double * x) } -string F17RotatedHybridComposition1Noise::getFileMxName(string prefix, int dimension, string suffix) +std::string F17RotatedHybridComposition1Noise::getFileMxName(std::string prefix, int dimension, std::string suffix) { std::stringstream sstm; sstm << prefix << dimension << suffix; diff --git a/src/problems/singleObjective/cec2005Competition/F17RotatedHybridComposition1Noise.h b/src/problems/singleObjective/cec2005Competition/F17RotatedHybridComposition1Noise.h index c4d38ad..8ef5eb9 100644 --- a/src/problems/singleObjective/cec2005Competition/F17RotatedHybridComposition1Noise.h +++ b/src/problems/singleObjective/cec2005Competition/F17RotatedHybridComposition1Noise.h @@ -32,10 +32,10 @@ class F17RotatedHybridComposition1Noise : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; + static const std::string DEFAULT_FILE_MX_PREFIX; + static const std::string DEFAULT_FILE_MX_SUFFIX; // Number of functions static const int NUM_FUNC = 10; @@ -65,12 +65,12 @@ class F17RotatedHybridComposition1Noise : public TestFunc MyHCJob * theJob; - string getFileMxName(string prefix, int dimension, string suffix); + std::string getFileMxName(std::string prefix, int dimension, std::string suffix); public: F17RotatedHybridComposition1Noise(int dimension, double bias); - F17RotatedHybridComposition1Noise(int dimension, double bias, string file_data, string file_m); + F17RotatedHybridComposition1Noise(int dimension, double bias, std::string file_data, std::string file_m); ~F17RotatedHybridComposition1Noise(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F18RotatedHybridComposition2.cpp b/src/problems/singleObjective/cec2005Competition/F18RotatedHybridComposition2.cpp index 4d2a1d2..0291440 100644 --- a/src/problems/singleObjective/cec2005Competition/F18RotatedHybridComposition2.cpp +++ b/src/problems/singleObjective/cec2005Competition/F18RotatedHybridComposition2.cpp @@ -24,11 +24,11 @@ #include "JMetalHeader.h" // Fixed (class) parameters -const string F18RotatedHybridComposition2::FUNCTION_NAME = "Rotated Hybrid Composition Function 2"; +const std::string F18RotatedHybridComposition2::FUNCTION_NAME = "Rotated Hybrid Composition Function 2"; // TODO: Cambiar ruta -const string F18RotatedHybridComposition2::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/hybrid_func2_data.txt"; -const string F18RotatedHybridComposition2::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func2_M_D"; -const string F18RotatedHybridComposition2::DEFAULT_FILE_MX_SUFFIX = ".txt"; +const std::string F18RotatedHybridComposition2::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/hybrid_func2_data.txt"; +const std::string F18RotatedHybridComposition2::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func2_M_D"; +const std::string F18RotatedHybridComposition2::DEFAULT_FILE_MX_SUFFIX = ".txt"; const double F18RotatedHybridComposition2::m_sigma[NUM_FUNC] = { @@ -61,7 +61,7 @@ F18RotatedHybridComposition2::F18RotatedHybridComposition2(int dimension, double /** * Constructor */ -F18RotatedHybridComposition2::F18RotatedHybridComposition2(int dimension, double bias, string file_data, string file_m) +F18RotatedHybridComposition2::F18RotatedHybridComposition2(int dimension, double bias, std::string file_data, std::string file_m) : TestFunc(dimension, bias, FUNCTION_NAME) { @@ -194,7 +194,7 @@ double F18RotatedHybridComposition2::MyHCJob::basic_func(int func_no, double* x, result = Benchmark::griewank(x, length); break; default: - cerr << "func_no is out of range." << endl; + cerr << "func_no is out of range." << std::endl; exit(-1); } return (result); @@ -216,7 +216,7 @@ double F18RotatedHybridComposition2::f(double * x) } -string F18RotatedHybridComposition2::getFileMxName(string prefix, int dimension, string suffix) +std::string F18RotatedHybridComposition2::getFileMxName(std::string prefix, int dimension, std::string suffix) { std::stringstream sstm; sstm << prefix << dimension << suffix; diff --git a/src/problems/singleObjective/cec2005Competition/F18RotatedHybridComposition2.h b/src/problems/singleObjective/cec2005Competition/F18RotatedHybridComposition2.h index aefd199..9740878 100644 --- a/src/problems/singleObjective/cec2005Competition/F18RotatedHybridComposition2.h +++ b/src/problems/singleObjective/cec2005Competition/F18RotatedHybridComposition2.h @@ -32,10 +32,10 @@ class F18RotatedHybridComposition2 : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; + static const std::string DEFAULT_FILE_MX_PREFIX; + static const std::string DEFAULT_FILE_MX_SUFFIX; // Number of functions static const int NUM_FUNC = 10; @@ -65,12 +65,12 @@ class F18RotatedHybridComposition2 : public TestFunc MyHCJob * theJob; - string getFileMxName(string prefix, int dimension, string suffix); + std::string getFileMxName(std::string prefix, int dimension, std::string suffix); public: F18RotatedHybridComposition2(int dimension, double bias); - F18RotatedHybridComposition2(int dimension, double bias, string file_data, string file_m); + F18RotatedHybridComposition2(int dimension, double bias, std::string file_data, std::string file_m); ~F18RotatedHybridComposition2(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F19RotatedHybridComposition2NarrowBasinGlobalOpt.cpp b/src/problems/singleObjective/cec2005Competition/F19RotatedHybridComposition2NarrowBasinGlobalOpt.cpp index bc8caf8..a0c761f 100644 --- a/src/problems/singleObjective/cec2005Competition/F19RotatedHybridComposition2NarrowBasinGlobalOpt.cpp +++ b/src/problems/singleObjective/cec2005Competition/F19RotatedHybridComposition2NarrowBasinGlobalOpt.cpp @@ -24,11 +24,11 @@ #include "JMetalHeader.h" // Fixed (class) parameters -const string F19RotatedHybridComposition2NarrowBasinGlobalOpt::FUNCTION_NAME = "Rotated Hybrid Composition Function 2 with narrow basin global optimum"; +const std::string F19RotatedHybridComposition2NarrowBasinGlobalOpt::FUNCTION_NAME = "Rotated Hybrid Composition Function 2 with narrow basin global optimum"; // TODO: Cambiar ruta -const string F19RotatedHybridComposition2NarrowBasinGlobalOpt::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/hybrid_func2_data.txt"; -const string F19RotatedHybridComposition2NarrowBasinGlobalOpt::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func2_M_D"; -const string F19RotatedHybridComposition2NarrowBasinGlobalOpt::DEFAULT_FILE_MX_SUFFIX = ".txt"; +const std::string F19RotatedHybridComposition2NarrowBasinGlobalOpt::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/hybrid_func2_data.txt"; +const std::string F19RotatedHybridComposition2NarrowBasinGlobalOpt::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func2_M_D"; +const std::string F19RotatedHybridComposition2NarrowBasinGlobalOpt::DEFAULT_FILE_MX_SUFFIX = ".txt"; const double F19RotatedHybridComposition2NarrowBasinGlobalOpt::m_sigma[NUM_FUNC] = { @@ -61,7 +61,7 @@ F19RotatedHybridComposition2NarrowBasinGlobalOpt::F19RotatedHybridComposition2Na /** * Constructor */ -F19RotatedHybridComposition2NarrowBasinGlobalOpt::F19RotatedHybridComposition2NarrowBasinGlobalOpt(int dimension, double bias, string file_data, string file_m) +F19RotatedHybridComposition2NarrowBasinGlobalOpt::F19RotatedHybridComposition2NarrowBasinGlobalOpt(int dimension, double bias, std::string file_data, std::string file_m) : TestFunc(dimension, bias, FUNCTION_NAME) { @@ -194,7 +194,7 @@ double F19RotatedHybridComposition2NarrowBasinGlobalOpt::MyHCJob::basic_func(int result = Benchmark::griewank(x, length); break; default: - cerr << "func_no is out of range." << endl; + cerr << "func_no is out of range." << std::endl; exit(-1); } return (result); @@ -216,7 +216,7 @@ double F19RotatedHybridComposition2NarrowBasinGlobalOpt::f(double * x) } -string F19RotatedHybridComposition2NarrowBasinGlobalOpt::getFileMxName(string prefix, int dimension, string suffix) +std::string F19RotatedHybridComposition2NarrowBasinGlobalOpt::getFileMxName(std::string prefix, int dimension, std::string suffix) { std::stringstream sstm; sstm << prefix << dimension << suffix; diff --git a/src/problems/singleObjective/cec2005Competition/F19RotatedHybridComposition2NarrowBasinGlobalOpt.h b/src/problems/singleObjective/cec2005Competition/F19RotatedHybridComposition2NarrowBasinGlobalOpt.h index 1c3416c..555e3c9 100644 --- a/src/problems/singleObjective/cec2005Competition/F19RotatedHybridComposition2NarrowBasinGlobalOpt.h +++ b/src/problems/singleObjective/cec2005Competition/F19RotatedHybridComposition2NarrowBasinGlobalOpt.h @@ -32,10 +32,10 @@ class F19RotatedHybridComposition2NarrowBasinGlobalOpt : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; + static const std::string DEFAULT_FILE_MX_PREFIX; + static const std::string DEFAULT_FILE_MX_SUFFIX; // Number of functions static const int NUM_FUNC = 10; @@ -65,12 +65,12 @@ class F19RotatedHybridComposition2NarrowBasinGlobalOpt : public TestFunc MyHCJob * theJob; - string getFileMxName(string prefix, int dimension, string suffix); + std::string getFileMxName(std::string prefix, int dimension, std::string suffix); public: F19RotatedHybridComposition2NarrowBasinGlobalOpt(int dimension, double bias); - F19RotatedHybridComposition2NarrowBasinGlobalOpt(int dimension, double bias, string file_data, string file_m); + F19RotatedHybridComposition2NarrowBasinGlobalOpt(int dimension, double bias, std::string file_data, std::string file_m); ~F19RotatedHybridComposition2NarrowBasinGlobalOpt(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F20RotatedHybridComposition2GlobalOptBound.cpp b/src/problems/singleObjective/cec2005Competition/F20RotatedHybridComposition2GlobalOptBound.cpp index 40d4786..ebe88a0 100644 --- a/src/problems/singleObjective/cec2005Competition/F20RotatedHybridComposition2GlobalOptBound.cpp +++ b/src/problems/singleObjective/cec2005Competition/F20RotatedHybridComposition2GlobalOptBound.cpp @@ -24,11 +24,11 @@ #include "JMetalHeader.h" // Fixed (class) parameters -const string F20RotatedHybridComposition2GlobalOptBound::FUNCTION_NAME = "Rotated Hybrid Composition Function 2 with Global Optimum on the Bounds"; +const std::string F20RotatedHybridComposition2GlobalOptBound::FUNCTION_NAME = "Rotated Hybrid Composition Function 2 with Global Optimum on the Bounds"; // TODO: Cambiar ruta -const string F20RotatedHybridComposition2GlobalOptBound::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/hybrid_func2_data.txt"; -const string F20RotatedHybridComposition2GlobalOptBound::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func2_M_D"; -const string F20RotatedHybridComposition2GlobalOptBound::DEFAULT_FILE_MX_SUFFIX = ".txt"; +const std::string F20RotatedHybridComposition2GlobalOptBound::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/hybrid_func2_data.txt"; +const std::string F20RotatedHybridComposition2GlobalOptBound::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func2_M_D"; +const std::string F20RotatedHybridComposition2GlobalOptBound::DEFAULT_FILE_MX_SUFFIX = ".txt"; const double F20RotatedHybridComposition2GlobalOptBound::m_sigma[NUM_FUNC] = { @@ -61,7 +61,7 @@ F20RotatedHybridComposition2GlobalOptBound::F20RotatedHybridComposition2GlobalOp /** * Constructor */ -F20RotatedHybridComposition2GlobalOptBound::F20RotatedHybridComposition2GlobalOptBound(int dimension, double bias, string file_data, string file_m) +F20RotatedHybridComposition2GlobalOptBound::F20RotatedHybridComposition2GlobalOptBound(int dimension, double bias, std::string file_data, std::string file_m) : TestFunc(dimension, bias, FUNCTION_NAME) { @@ -198,7 +198,7 @@ double F20RotatedHybridComposition2GlobalOptBound::MyHCJob::basic_func(int func_ result = Benchmark::griewank(x, length); break; default: - cerr << "func_no is out of range." << endl; + cerr << "func_no is out of range." << std::endl; exit(-1); } return (result); @@ -220,7 +220,7 @@ double F20RotatedHybridComposition2GlobalOptBound::f(double * x) } -string F20RotatedHybridComposition2GlobalOptBound::getFileMxName(string prefix, int dimension, string suffix) +std::string F20RotatedHybridComposition2GlobalOptBound::getFileMxName(std::string prefix, int dimension, std::string suffix) { std::stringstream sstm; sstm << prefix << dimension << suffix; diff --git a/src/problems/singleObjective/cec2005Competition/F20RotatedHybridComposition2GlobalOptBound.h b/src/problems/singleObjective/cec2005Competition/F20RotatedHybridComposition2GlobalOptBound.h index 6dec391..0745922 100644 --- a/src/problems/singleObjective/cec2005Competition/F20RotatedHybridComposition2GlobalOptBound.h +++ b/src/problems/singleObjective/cec2005Competition/F20RotatedHybridComposition2GlobalOptBound.h @@ -32,10 +32,10 @@ class F20RotatedHybridComposition2GlobalOptBound : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; + static const std::string DEFAULT_FILE_MX_PREFIX; + static const std::string DEFAULT_FILE_MX_SUFFIX; // Number of functions static const int NUM_FUNC = 10; @@ -65,12 +65,12 @@ class F20RotatedHybridComposition2GlobalOptBound : public TestFunc MyHCJob * theJob; - string getFileMxName(string prefix, int dimension, string suffix); + std::string getFileMxName(std::string prefix, int dimension, std::string suffix); public: F20RotatedHybridComposition2GlobalOptBound(int dimension, double bias); - F20RotatedHybridComposition2GlobalOptBound(int dimension, double bias, string file_data, string file_m); + F20RotatedHybridComposition2GlobalOptBound(int dimension, double bias, std::string file_data, std::string file_m); ~F20RotatedHybridComposition2GlobalOptBound(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F21RotatedHybridComposition3.cpp b/src/problems/singleObjective/cec2005Competition/F21RotatedHybridComposition3.cpp index b67e030..5005f57 100644 --- a/src/problems/singleObjective/cec2005Competition/F21RotatedHybridComposition3.cpp +++ b/src/problems/singleObjective/cec2005Competition/F21RotatedHybridComposition3.cpp @@ -24,11 +24,11 @@ #include "JMetalHeader.h" // Fixed (class) parameters -const string F21RotatedHybridComposition3::FUNCTION_NAME = "Rotated Hybrid Composition Function 3"; +const std::string F21RotatedHybridComposition3::FUNCTION_NAME = "Rotated Hybrid Composition Function 3"; // TODO: Cambiar ruta -const string F21RotatedHybridComposition3::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/hybrid_func3_data.txt"; -const string F21RotatedHybridComposition3::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func3_M_D"; -const string F21RotatedHybridComposition3::DEFAULT_FILE_MX_SUFFIX = ".txt"; +const std::string F21RotatedHybridComposition3::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/hybrid_func3_data.txt"; +const std::string F21RotatedHybridComposition3::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func3_M_D"; +const std::string F21RotatedHybridComposition3::DEFAULT_FILE_MX_SUFFIX = ".txt"; const double F21RotatedHybridComposition3::m_sigma[NUM_FUNC] = { @@ -61,7 +61,7 @@ F21RotatedHybridComposition3::F21RotatedHybridComposition3(int dimension, double /** * Constructor */ -F21RotatedHybridComposition3::F21RotatedHybridComposition3(int dimension, double bias, string file_data, string file_m) +F21RotatedHybridComposition3::F21RotatedHybridComposition3(int dimension, double bias, std::string file_data, std::string file_m) : TestFunc(dimension, bias, FUNCTION_NAME) { @@ -190,7 +190,7 @@ double F21RotatedHybridComposition3::MyHCJob::basic_func(int func_no, double* x, result = Benchmark::griewank(x, length); break; default: - cerr << "func_no is out of range." << endl; + cerr << "func_no is out of range." << std::endl; exit(-1); } return (result); @@ -212,7 +212,7 @@ double F21RotatedHybridComposition3::f(double * x) } -string F21RotatedHybridComposition3::getFileMxName(string prefix, int dimension, string suffix) +std::string F21RotatedHybridComposition3::getFileMxName(std::string prefix, int dimension, std::string suffix) { std::stringstream sstm; sstm << prefix << dimension << suffix; diff --git a/src/problems/singleObjective/cec2005Competition/F21RotatedHybridComposition3.h b/src/problems/singleObjective/cec2005Competition/F21RotatedHybridComposition3.h index b432ecb..a087b03 100644 --- a/src/problems/singleObjective/cec2005Competition/F21RotatedHybridComposition3.h +++ b/src/problems/singleObjective/cec2005Competition/F21RotatedHybridComposition3.h @@ -32,10 +32,10 @@ class F21RotatedHybridComposition3 : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; + static const std::string DEFAULT_FILE_MX_PREFIX; + static const std::string DEFAULT_FILE_MX_SUFFIX; // Number of functions static const int NUM_FUNC = 10; @@ -65,12 +65,12 @@ class F21RotatedHybridComposition3 : public TestFunc MyHCJob * theJob; - string getFileMxName(string prefix, int dimension, string suffix); + std::string getFileMxName(std::string prefix, int dimension, std::string suffix); public: F21RotatedHybridComposition3(int dimension, double bias); - F21RotatedHybridComposition3(int dimension, double bias, string file_data, string file_m); + F21RotatedHybridComposition3(int dimension, double bias, std::string file_data, std::string file_m); ~F21RotatedHybridComposition3(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F22RotatedHybridComposition3HighCondNumMatrix.cpp b/src/problems/singleObjective/cec2005Competition/F22RotatedHybridComposition3HighCondNumMatrix.cpp index 1cfb29d..3ce148c 100644 --- a/src/problems/singleObjective/cec2005Competition/F22RotatedHybridComposition3HighCondNumMatrix.cpp +++ b/src/problems/singleObjective/cec2005Competition/F22RotatedHybridComposition3HighCondNumMatrix.cpp @@ -24,11 +24,11 @@ #include "JMetalHeader.h" // Fixed (class) parameters -const string F22RotatedHybridComposition3HighCondNumMatrix::FUNCTION_NAME = "Rotated Hybrid Composition Function 3 with High Condition Number Matrix"; +const std::string F22RotatedHybridComposition3HighCondNumMatrix::FUNCTION_NAME = "Rotated Hybrid Composition Function 3 with High Condition Number Matrix"; // TODO: Cambiar ruta -const string F22RotatedHybridComposition3HighCondNumMatrix::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/hybrid_func3_data.txt"; -const string F22RotatedHybridComposition3HighCondNumMatrix::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func3_HM_D"; -const string F22RotatedHybridComposition3HighCondNumMatrix::DEFAULT_FILE_MX_SUFFIX = ".txt"; +const std::string F22RotatedHybridComposition3HighCondNumMatrix::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/hybrid_func3_data.txt"; +const std::string F22RotatedHybridComposition3HighCondNumMatrix::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func3_HM_D"; +const std::string F22RotatedHybridComposition3HighCondNumMatrix::DEFAULT_FILE_MX_SUFFIX = ".txt"; const double F22RotatedHybridComposition3HighCondNumMatrix::m_sigma[NUM_FUNC] = { @@ -61,7 +61,7 @@ F22RotatedHybridComposition3HighCondNumMatrix::F22RotatedHybridComposition3HighC /** * Constructor */ -F22RotatedHybridComposition3HighCondNumMatrix::F22RotatedHybridComposition3HighCondNumMatrix(int dimension, double bias, string file_data, string file_m) +F22RotatedHybridComposition3HighCondNumMatrix::F22RotatedHybridComposition3HighCondNumMatrix(int dimension, double bias, std::string file_data, std::string file_m) : TestFunc(dimension, bias, FUNCTION_NAME) { @@ -190,7 +190,7 @@ double F22RotatedHybridComposition3HighCondNumMatrix::MyHCJob::basic_func(int fu result = Benchmark::griewank(x, length); break; default: - cerr << "func_no is out of range." << endl; + cerr << "func_no is out of range." << std::endl; exit(-1); } return (result); @@ -212,7 +212,7 @@ double F22RotatedHybridComposition3HighCondNumMatrix::f(double * x) } -string F22RotatedHybridComposition3HighCondNumMatrix::getFileMxName(string prefix, int dimension, string suffix) +std::string F22RotatedHybridComposition3HighCondNumMatrix::getFileMxName(std::string prefix, int dimension, std::string suffix) { std::stringstream sstm; sstm << prefix << dimension << suffix; diff --git a/src/problems/singleObjective/cec2005Competition/F22RotatedHybridComposition3HighCondNumMatrix.h b/src/problems/singleObjective/cec2005Competition/F22RotatedHybridComposition3HighCondNumMatrix.h index 742e915..00d0d5e 100644 --- a/src/problems/singleObjective/cec2005Competition/F22RotatedHybridComposition3HighCondNumMatrix.h +++ b/src/problems/singleObjective/cec2005Competition/F22RotatedHybridComposition3HighCondNumMatrix.h @@ -32,10 +32,10 @@ class F22RotatedHybridComposition3HighCondNumMatrix : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; + static const std::string DEFAULT_FILE_MX_PREFIX; + static const std::string DEFAULT_FILE_MX_SUFFIX; // Number of functions static const int NUM_FUNC = 10; @@ -65,12 +65,12 @@ class F22RotatedHybridComposition3HighCondNumMatrix : public TestFunc MyHCJob * theJob; - string getFileMxName(string prefix, int dimension, string suffix); + std::string getFileMxName(std::string prefix, int dimension, std::string suffix); public: F22RotatedHybridComposition3HighCondNumMatrix(int dimension, double bias); - F22RotatedHybridComposition3HighCondNumMatrix(int dimension, double bias, string file_data, string file_m); + F22RotatedHybridComposition3HighCondNumMatrix(int dimension, double bias, std::string file_data, std::string file_m); ~F22RotatedHybridComposition3HighCondNumMatrix(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F23NoncontinuousRotatedHybridComposition3.cpp b/src/problems/singleObjective/cec2005Competition/F23NoncontinuousRotatedHybridComposition3.cpp index 4b8e6ff..9d8a541 100644 --- a/src/problems/singleObjective/cec2005Competition/F23NoncontinuousRotatedHybridComposition3.cpp +++ b/src/problems/singleObjective/cec2005Competition/F23NoncontinuousRotatedHybridComposition3.cpp @@ -24,11 +24,11 @@ #include "JMetalHeader.h" // Fixed (class) parameters -const string F23NoncontinuousRotatedHybridComposition3::FUNCTION_NAME = "Non-Continuous Rotated Hybrid Composition Function 3"; +const std::string F23NoncontinuousRotatedHybridComposition3::FUNCTION_NAME = "Non-Continuous Rotated Hybrid Composition Function 3"; // TODO: Cambiar ruta -const string F23NoncontinuousRotatedHybridComposition3::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/hybrid_func3_data.txt"; -const string F23NoncontinuousRotatedHybridComposition3::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func3_M_D"; -const string F23NoncontinuousRotatedHybridComposition3::DEFAULT_FILE_MX_SUFFIX = ".txt"; +const std::string F23NoncontinuousRotatedHybridComposition3::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/hybrid_func3_data.txt"; +const std::string F23NoncontinuousRotatedHybridComposition3::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func3_M_D"; +const std::string F23NoncontinuousRotatedHybridComposition3::DEFAULT_FILE_MX_SUFFIX = ".txt"; const double F23NoncontinuousRotatedHybridComposition3::m_sigma[NUM_FUNC] = { @@ -61,7 +61,7 @@ F23NoncontinuousRotatedHybridComposition3::F23NoncontinuousRotatedHybridComposit /** * Constructor */ -F23NoncontinuousRotatedHybridComposition3::F23NoncontinuousRotatedHybridComposition3(int dimension, double bias, string file_data, string file_m) +F23NoncontinuousRotatedHybridComposition3::F23NoncontinuousRotatedHybridComposition3(int dimension, double bias, std::string file_data, std::string file_m) : TestFunc(dimension, bias, FUNCTION_NAME) { @@ -190,7 +190,7 @@ double F23NoncontinuousRotatedHybridComposition3::MyHCJob::basic_func(int func_n result = Benchmark::griewank(x, length); break; default: - cerr << "func_no is out of range." << endl; + cerr << "func_no is out of range." << std::endl; exit(-1); } return (result); @@ -217,7 +217,7 @@ double F23NoncontinuousRotatedHybridComposition3::f(double * x) } -string F23NoncontinuousRotatedHybridComposition3::getFileMxName(string prefix, int dimension, string suffix) +std::string F23NoncontinuousRotatedHybridComposition3::getFileMxName(std::string prefix, int dimension, std::string suffix) { std::stringstream sstm; sstm << prefix << dimension << suffix; diff --git a/src/problems/singleObjective/cec2005Competition/F23NoncontinuousRotatedHybridComposition3.h b/src/problems/singleObjective/cec2005Competition/F23NoncontinuousRotatedHybridComposition3.h index a498148..70572aa 100644 --- a/src/problems/singleObjective/cec2005Competition/F23NoncontinuousRotatedHybridComposition3.h +++ b/src/problems/singleObjective/cec2005Competition/F23NoncontinuousRotatedHybridComposition3.h @@ -32,10 +32,10 @@ class F23NoncontinuousRotatedHybridComposition3 : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; + static const std::string DEFAULT_FILE_MX_PREFIX; + static const std::string DEFAULT_FILE_MX_SUFFIX; // Number of functions static const int NUM_FUNC = 10; @@ -65,12 +65,12 @@ class F23NoncontinuousRotatedHybridComposition3 : public TestFunc MyHCJob * theJob; - string getFileMxName(string prefix, int dimension, string suffix); + std::string getFileMxName(std::string prefix, int dimension, std::string suffix); public: F23NoncontinuousRotatedHybridComposition3(int dimension, double bias); - F23NoncontinuousRotatedHybridComposition3(int dimension, double bias, string file_data, string file_m); + F23NoncontinuousRotatedHybridComposition3(int dimension, double bias, std::string file_data, std::string file_m); ~F23NoncontinuousRotatedHybridComposition3(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F24RotatedHybridComposition4.cpp b/src/problems/singleObjective/cec2005Competition/F24RotatedHybridComposition4.cpp index 731f4aa..54066c3 100644 --- a/src/problems/singleObjective/cec2005Competition/F24RotatedHybridComposition4.cpp +++ b/src/problems/singleObjective/cec2005Competition/F24RotatedHybridComposition4.cpp @@ -24,11 +24,11 @@ #include "JMetalHeader.h" // Fixed (class) parameters -const string F24RotatedHybridComposition4::FUNCTION_NAME = "Rotated Hybrid Composition Function 4"; +const std::string F24RotatedHybridComposition4::FUNCTION_NAME = "Rotated Hybrid Composition Function 4"; // TODO: Cambiar ruta -const string F24RotatedHybridComposition4::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/hybrid_func4_data.txt"; -const string F24RotatedHybridComposition4::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func4_M_D"; -const string F24RotatedHybridComposition4::DEFAULT_FILE_MX_SUFFIX = ".txt"; +const std::string F24RotatedHybridComposition4::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/hybrid_func4_data.txt"; +const std::string F24RotatedHybridComposition4::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func4_M_D"; +const std::string F24RotatedHybridComposition4::DEFAULT_FILE_MX_SUFFIX = ".txt"; const double F24RotatedHybridComposition4::m_sigma[NUM_FUNC] = { @@ -61,7 +61,7 @@ F24RotatedHybridComposition4::F24RotatedHybridComposition4(int dimension, double /** * Constructor */ -F24RotatedHybridComposition4::F24RotatedHybridComposition4(int dimension, double bias, string file_data, string file_m) +F24RotatedHybridComposition4::F24RotatedHybridComposition4(int dimension, double bias, std::string file_data, std::string file_m) : TestFunc(dimension, bias, FUNCTION_NAME) { @@ -200,7 +200,7 @@ double F24RotatedHybridComposition4::MyHCJob::basic_func(int func_no, double* x, result = Benchmark::sphere_noise(x,length); break; default: - cerr << "func_no is out of range." << endl; + cerr << "func_no is out of range." << std::endl; exit(-1); } return (result); @@ -222,7 +222,7 @@ double F24RotatedHybridComposition4::f(double * x) } -string F24RotatedHybridComposition4::getFileMxName(string prefix, int dimension, string suffix) +std::string F24RotatedHybridComposition4::getFileMxName(std::string prefix, int dimension, std::string suffix) { std::stringstream sstm; sstm << prefix << dimension << suffix; diff --git a/src/problems/singleObjective/cec2005Competition/F24RotatedHybridComposition4.h b/src/problems/singleObjective/cec2005Competition/F24RotatedHybridComposition4.h index 7a9cb65..3e9a730 100644 --- a/src/problems/singleObjective/cec2005Competition/F24RotatedHybridComposition4.h +++ b/src/problems/singleObjective/cec2005Competition/F24RotatedHybridComposition4.h @@ -32,10 +32,10 @@ class F24RotatedHybridComposition4 : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; + static const std::string DEFAULT_FILE_MX_PREFIX; + static const std::string DEFAULT_FILE_MX_SUFFIX; // Number of functions static const int NUM_FUNC = 10; @@ -65,12 +65,12 @@ class F24RotatedHybridComposition4 : public TestFunc MyHCJob * theJob; - string getFileMxName(string prefix, int dimension, string suffix); + std::string getFileMxName(std::string prefix, int dimension, std::string suffix); public: F24RotatedHybridComposition4(int dimension, double bias); - F24RotatedHybridComposition4(int dimension, double bias, string file_data, string file_m); + F24RotatedHybridComposition4(int dimension, double bias, std::string file_data, std::string file_m); ~F24RotatedHybridComposition4(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/F25RotatedHybridComposition4Bound.cpp b/src/problems/singleObjective/cec2005Competition/F25RotatedHybridComposition4Bound.cpp index 3285435..06cbed5 100644 --- a/src/problems/singleObjective/cec2005Competition/F25RotatedHybridComposition4Bound.cpp +++ b/src/problems/singleObjective/cec2005Competition/F25RotatedHybridComposition4Bound.cpp @@ -24,11 +24,11 @@ #include "JMetalHeader.h" // Fixed (class) parameters -const string F25RotatedHybridComposition4Bound::FUNCTION_NAME = "Rotated Hybrid Composition Function 4 without bounds"; +const std::string F25RotatedHybridComposition4Bound::FUNCTION_NAME = "Rotated Hybrid Composition Function 4 without bounds"; // TODO: Cambiar ruta -const string F25RotatedHybridComposition4Bound::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/hybrid_func4_data.txt"; -const string F25RotatedHybridComposition4Bound::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func4_M_D"; -const string F25RotatedHybridComposition4Bound::DEFAULT_FILE_MX_SUFFIX = ".txt"; +const std::string F25RotatedHybridComposition4Bound::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/hybrid_func4_data.txt"; +const std::string F25RotatedHybridComposition4Bound::DEFAULT_FILE_MX_PREFIX = "../../data/cec2005CompetitionResources/supportData/hybrid_func4_M_D"; +const std::string F25RotatedHybridComposition4Bound::DEFAULT_FILE_MX_SUFFIX = ".txt"; const double F25RotatedHybridComposition4Bound::m_sigma[NUM_FUNC] = { @@ -61,7 +61,7 @@ F25RotatedHybridComposition4Bound::F25RotatedHybridComposition4Bound(int dimensi /** * Constructor */ -F25RotatedHybridComposition4Bound::F25RotatedHybridComposition4Bound(int dimension, double bias, string file_data, string file_m) +F25RotatedHybridComposition4Bound::F25RotatedHybridComposition4Bound(int dimension, double bias, std::string file_data, std::string file_m) : TestFunc(dimension, bias, FUNCTION_NAME) { @@ -200,7 +200,7 @@ double F25RotatedHybridComposition4Bound::MyHCJob::basic_func(int func_no, doubl result = Benchmark::sphere_noise(x,length); break; default: - cerr << "func_no is out of range." << endl; + cerr << "func_no is out of range." << std::endl; exit(-1); } return (result); @@ -222,7 +222,7 @@ double F25RotatedHybridComposition4Bound::f(double * x) } -string F25RotatedHybridComposition4Bound::getFileMxName(string prefix, int dimension, string suffix) +std::string F25RotatedHybridComposition4Bound::getFileMxName(std::string prefix, int dimension, std::string suffix) { std::stringstream sstm; sstm << prefix << dimension << suffix; diff --git a/src/problems/singleObjective/cec2005Competition/F25RotatedHybridComposition4Bound.h b/src/problems/singleObjective/cec2005Competition/F25RotatedHybridComposition4Bound.h index ffee212..31ca0a2 100644 --- a/src/problems/singleObjective/cec2005Competition/F25RotatedHybridComposition4Bound.h +++ b/src/problems/singleObjective/cec2005Competition/F25RotatedHybridComposition4Bound.h @@ -32,10 +32,10 @@ class F25RotatedHybridComposition4Bound : public TestFunc private: // Fixed (class) parameters - static const string FUNCTION_NAME; - static const string DEFAULT_FILE_DATA; - static const string DEFAULT_FILE_MX_PREFIX; - static const string DEFAULT_FILE_MX_SUFFIX; + static const std::string FUNCTION_NAME; + static const std::string DEFAULT_FILE_DATA; + static const std::string DEFAULT_FILE_MX_PREFIX; + static const std::string DEFAULT_FILE_MX_SUFFIX; // Number of functions static const int NUM_FUNC = 10; @@ -65,12 +65,12 @@ class F25RotatedHybridComposition4Bound : public TestFunc MyHCJob * theJob; - string getFileMxName(string prefix, int dimension, string suffix); + std::string getFileMxName(std::string prefix, int dimension, std::string suffix); public: F25RotatedHybridComposition4Bound(int dimension, double bias); - F25RotatedHybridComposition4Bound(int dimension, double bias, string file_data, string file_m); + F25RotatedHybridComposition4Bound(int dimension, double bias, std::string file_data, std::string file_m); ~F25RotatedHybridComposition4Bound(); double f (double * x); diff --git a/src/problems/singleObjective/cec2005Competition/TestFunc.cpp b/src/problems/singleObjective/cec2005Competition/TestFunc.cpp index b3cbed0..6f0d157 100644 --- a/src/problems/singleObjective/cec2005Competition/TestFunc.cpp +++ b/src/problems/singleObjective/cec2005Competition/TestFunc.cpp @@ -32,7 +32,7 @@ TestFunc::TestFunc(int dimension, double bias) : TestFunc(dimension, bias, "unde /** * Constructor */ -TestFunc::TestFunc(int dimension, double bias, string func_name) +TestFunc::TestFunc(int dimension, double bias, std::string func_name) { m_dimension = dimension; m_bias = bias; @@ -56,7 +56,7 @@ double TestFunc::bias() return (m_bias); } // bias -string TestFunc::name() +std::string TestFunc::name() { return (m_func_name); } // name diff --git a/src/qualityIndicator/Epsilon.cpp b/src/qualityIndicator/Epsilon.cpp index 367156b..5e70952 100644 --- a/src/qualityIndicator/Epsilon.cpp +++ b/src/qualityIndicator/Epsilon.cpp @@ -47,7 +47,7 @@ Epsilon::~Epsilon() * @param a. Solution front * @return the value of the epsilon indicator */ -double Epsilon::epsilon(vector > b, vector > a, +double Epsilon::epsilon(std::vector > b, std::vector > a, int dim) { @@ -86,7 +86,7 @@ double Epsilon::epsilon(vector > b, vector > a, //if ( (a[i * dim_ + k] < 0 && b[j * dim_ + k] > 0) || // (a[i * dim_ + k] > 0 && b[j * dim_ + k] < 0) || // (a[i * dim_ + k] == 0 || b[j * dim_ + k] == 0)) { - cout << "error in data file" << endl; + std::cout << "error in data file" << std::endl; exit(-1); } if (obj_[k] == 0) diff --git a/src/qualityIndicator/Epsilon.h b/src/qualityIndicator/Epsilon.h index b54a673..1d89f39 100644 --- a/src/qualityIndicator/Epsilon.h +++ b/src/qualityIndicator/Epsilon.h @@ -54,7 +54,7 @@ class Epsilon Epsilon(); ~Epsilon(); - double epsilon(vector > b, vector< vector > a, int dim); + double epsilon(std::vector > b, std::vector< std::vector > a, int dim); }; // Epsilon diff --git a/src/qualityIndicator/Fitness.cpp b/src/qualityIndicator/Fitness.cpp index 4ef8664..a914d88 100644 --- a/src/qualityIndicator/Fitness.cpp +++ b/src/qualityIndicator/Fitness.cpp @@ -47,7 +47,7 @@ Fitness::~Fitness() * @param a. Solution front * @return the value of the epsilon indicator */ -void Fitness::fitness(vector > a, string file) +void Fitness::fitness(std::vector > a, std::string file) { std::fstream out(file.c_str(), std::ios::out | std::ios::app); for (int i=0; i > a, string file) } out << a[i][j]; } - out << endl; + out << std::endl; } out.close(); diff --git a/src/qualityIndicator/Fitness.h b/src/qualityIndicator/Fitness.h index ceb9be1..26f6ebc 100644 --- a/src/qualityIndicator/Fitness.h +++ b/src/qualityIndicator/Fitness.h @@ -26,7 +26,7 @@ #include #include -using namespace std; + class Fitness { @@ -39,7 +39,7 @@ class Fitness Fitness(); ~Fitness(); - void fitness(vector > a, string file); + void fitness(std::vector > a, std::string file); }; // Fitness diff --git a/src/qualityIndicator/GenerationalDistance.cpp b/src/qualityIndicator/GenerationalDistance.cpp index ad25de1..3b216e0 100644 --- a/src/qualityIndicator/GenerationalDistance.cpp +++ b/src/qualityIndicator/GenerationalDistance.cpp @@ -51,29 +51,29 @@ GenerationalDistance::~GenerationalDistance() * @param front The front * @param trueParetoFront The true pareto front */ -double GenerationalDistance::generationalDistance(vector< vector > front, - vector< vector > trueParetoFront, int numberOfObjectives) +double GenerationalDistance::generationalDistance(std::vector< std::vector > front, + std::vector< std::vector > trueParetoFront, int numberOfObjectives) { /** * Stores the maximum values of true pareto front. */ - vector maximumValue; + std::vector maximumValue; /** * Stores the minimum values of the true pareto front. */ - vector minimumValue; + std::vector minimumValue; /** * Stores the normalized front. */ - vector< vector > normalizedFront; + std::vector< std::vector > normalizedFront; /** * Stores the normalized true Pareto front. */ - vector< vector > normalizedParetoFront ; + std::vector< std::vector > normalizedParetoFront ; // STEP 1. Obtain the maximum and minimum values of the Pareto front maximumValue = utils_->getMaximumValues(trueParetoFront, numberOfObjectives); diff --git a/src/qualityIndicator/GenerationalDistance.h b/src/qualityIndicator/GenerationalDistance.h index 00d1508..11f1979 100644 --- a/src/qualityIndicator/GenerationalDistance.h +++ b/src/qualityIndicator/GenerationalDistance.h @@ -48,8 +48,8 @@ class GenerationalDistance GenerationalDistance(); ~GenerationalDistance(); - double generationalDistance(vector< vector > front, - vector< vector > trueParetoFront, int numberOfObjectives); + double generationalDistance(std::vector< std::vector > front, + std::vector< std::vector > trueParetoFront, int numberOfObjectives); }; diff --git a/src/qualityIndicator/Hypervolume.cpp b/src/qualityIndicator/Hypervolume.cpp index fb567e0..2adb59a 100644 --- a/src/qualityIndicator/Hypervolume.cpp +++ b/src/qualityIndicator/Hypervolume.cpp @@ -135,7 +135,7 @@ double Hypervolume::surfaceUnchangedTo(double** front, int noPoints, if (noPoints < 1) { - cout << "run-time error" << endl; + std::cout << "run-time error" << std::endl; exit(-1); } @@ -204,7 +204,7 @@ double Hypervolume::calculateHypervolume(double** front, int noPoints, { if (noNondominatedPoints < 1) { - cout << "run-time error" << endl; + std::cout << "run-time error" << std::endl; exit(-1); } // if tempVolume = front[0][0]; @@ -276,29 +276,29 @@ double** Hypervolume::mergeFronts(double** front1, int sizeFront1, * @param paretoTrueFront The true pareto front * @param numberOfObjectives Number of objectives of the pareto front */ -double Hypervolume::hypervolume(vector< vector > paretoFront, - vector< vector > paretoTrueFront, int numberOfObjectives) +double Hypervolume::hypervolume(std::vector< std::vector > paretoFront, + std::vector< std::vector > paretoTrueFront, int numberOfObjectives) { /** * Stores the maximum values of true pareto front. */ - vector maximumValues; + std::vector maximumValues; /** * Stores the minimum values of the true pareto front. */ - vector minimumValues; + std::vector minimumValues; /** * Stores the normalized front. */ - vector< vector > normalizedFront; + std::vector< std::vector > normalizedFront; /** * Stores the inverted front. Needed for minimization problems */ - vector< vector > invertedFront; + std::vector< std::vector > invertedFront; // STEP 1. Obtain the maximum and minimum values of the Pareto front maximumValues = utils_->getMaximumValues(paretoTrueFront, numberOfObjectives); diff --git a/src/qualityIndicator/Hypervolume.h b/src/qualityIndicator/Hypervolume.h index 6ee0b7e..21ec725 100644 --- a/src/qualityIndicator/Hypervolume.h +++ b/src/qualityIndicator/Hypervolume.h @@ -26,7 +26,7 @@ #include #include -using namespace std; + /** * This class implements the hypervolume indicator. The code is a C++ version @@ -60,8 +60,8 @@ class Hypervolume ~Hypervolume(); double calculateHypervolume(double** front, int noPoints, int noObjectives); - double hypervolume(vector< vector > paretoFront, - vector< vector > paretoTrueFront, int numberOfObjectives); + double hypervolume(std::vector< std::vector > paretoFront, + std::vector< std::vector > paretoTrueFront, int numberOfObjectives); }; diff --git a/src/qualityIndicator/InvertedGenerationalDistance.cpp b/src/qualityIndicator/InvertedGenerationalDistance.cpp index 717740b..3a09fa2 100644 --- a/src/qualityIndicator/InvertedGenerationalDistance.cpp +++ b/src/qualityIndicator/InvertedGenerationalDistance.cpp @@ -52,29 +52,29 @@ InvertedGenerationalDistance::~InvertedGenerationalDistance() * @param trueParetoFront The true pareto front */ double InvertedGenerationalDistance::invertedGenerationalDistance( - vector< vector > front, vector< vector > trueParetoFront, + std::vector< std::vector > front, std::vector< std::vector > trueParetoFront, int numberOfObjectives) { /** * Stores the maximum values of true pareto front. */ - vector maximumValue; + std::vector maximumValue; /** * Stores the minimum values of the true pareto front. */ - vector minimumValue; + std::vector minimumValue; /** * Stores the normalized front. */ - vector< vector > normalizedFront; + std::vector< std::vector > normalizedFront; /** * Stores the normalized true Pareto front. */ - vector< vector > normalizedParetoFront ; + std::vector< std::vector > normalizedParetoFront ; // STEP 1. Obtain the maximum and minimum values of the Pareto front maximumValue = utils_->getMaximumValues(trueParetoFront, numberOfObjectives); diff --git a/src/qualityIndicator/InvertedGenerationalDistance.h b/src/qualityIndicator/InvertedGenerationalDistance.h index 2bcc7d3..3d372bd 100644 --- a/src/qualityIndicator/InvertedGenerationalDistance.h +++ b/src/qualityIndicator/InvertedGenerationalDistance.h @@ -48,8 +48,8 @@ class InvertedGenerationalDistance InvertedGenerationalDistance(); ~InvertedGenerationalDistance(); - double invertedGenerationalDistance(vector< vector > front, - vector< vector > trueParetoFront, int numberOfObjectives); + double invertedGenerationalDistance(std::vector< std::vector > front, + std::vector< std::vector > trueParetoFront, int numberOfObjectives); }; diff --git a/src/qualityIndicator/QualityIndicator.cpp b/src/qualityIndicator/QualityIndicator.cpp index bf99932..2b529f3 100644 --- a/src/qualityIndicator/QualityIndicator.cpp +++ b/src/qualityIndicator/QualityIndicator.cpp @@ -27,7 +27,7 @@ * @param paretoFrontFile */ QualityIndicator::QualityIndicator(Problem * problem, - string paretoFrontFile) + std::string paretoFrontFile) { problem_ = problem; dim_ = problem_->getNumberOfObjectives(); diff --git a/src/qualityIndicator/QualityIndicator.h b/src/qualityIndicator/QualityIndicator.h index b3c525b..82be59b 100644 --- a/src/qualityIndicator/QualityIndicator.h +++ b/src/qualityIndicator/QualityIndicator.h @@ -42,7 +42,7 @@ class QualityIndicator MetricsUtil * utilities_; public: - QualityIndicator(Problem * problem, string paretoFrontFile); + QualityIndicator(Problem * problem, std::string paretoFrontFile); ~QualityIndicator(); double getHypervolume(SolutionSet * solutionSet); double getTrueParetoFrontHypervolume(); diff --git a/src/qualityIndicator/Spread.cpp b/src/qualityIndicator/Spread.cpp index 386b1bc..70c4ca3 100644 --- a/src/qualityIndicator/Spread.cpp +++ b/src/qualityIndicator/Spread.cpp @@ -41,7 +41,7 @@ Spread::~Spread() } // ~Spread -bool Spread::compareFront(vector pointOne, vector pointTwo) +bool Spread::compareFront(std::vector pointOne, std::vector pointTwo) { int value; @@ -68,29 +68,29 @@ bool Spread::compareFront(vector pointOne, vector pointTwo) * @param trueParetoFront The true pareto front. * @param numberOfObjectives The number of objectives. */ -double Spread::spread(vector > front, - vector > trueParetoFront, int numberOfObjectives) +double Spread::spread(std::vector > front, + std::vector > trueParetoFront, int numberOfObjectives) { /** * Stores the maximum values of true pareto front. */ - vector maximumValue ; + std::vector maximumValue ; /** * Stores the minimum values of the true pareto front. */ - vector minimumValue ; + std::vector minimumValue ; /** * Stores the normalized front. */ - vector > normalizedFront ; + std::vector > normalizedFront ; /** * Stores the normalized true Pareto front. */ - vector > normalizedParetoFront ; + std::vector > normalizedParetoFront ; // STEP 1. Obtain the maximum and minimum values of the Pareto front maximumValue = utils_->getMaximumValues(trueParetoFront, numberOfObjectives); diff --git a/src/qualityIndicator/fastHypervolume/FastHypervolume.cpp b/src/qualityIndicator/fastHypervolume/FastHypervolume.cpp index 438d2ae..e25a52f 100644 --- a/src/qualityIndicator/fastHypervolume/FastHypervolume.cpp +++ b/src/qualityIndicator/fastHypervolume/FastHypervolume.cpp @@ -74,7 +74,7 @@ double FastHypervolume::computeHypervolume(SolutionSet* solutionSet) Front front = new Front(solutionSet.size(), numberOfObjectives_, solutionSet); hv = new WFGHV(numberOfObjectives_, solutionSet.size(), referencePoint_).getHV(front); */ - cerr << "Fast Hypervolume only works with two objectives for now." << endl; + cerr << "Fast Hypervolume only works with two objectives for now." << std::endl; } } @@ -166,7 +166,7 @@ void FastHypervolume::computeHVContributions(SolutionSet * solutionSet) new WFGHV(numberOfObjectives_, solutionSet.size(), referencePoint_).getHV(front); contributions[i] = solutionSetHV - hv; */ - cerr << "Fast Hypervolume only works with two objectives for now." << endl; + cerr << "Fast Hypervolume only works with two objectives for now." << std::endl; } solutionSet->add(i, currentPoint); } diff --git a/src/qualityIndicator/fastHypervolume/FastHypervolume.h b/src/qualityIndicator/fastHypervolume/FastHypervolume.h index 6757c4b..61b31db 100644 --- a/src/qualityIndicator/fastHypervolume/FastHypervolume.h +++ b/src/qualityIndicator/fastHypervolume/FastHypervolume.h @@ -27,7 +27,7 @@ //#include #include -using namespace std; + class FastHypervolume { diff --git a/src/qualityIndicator/fastHypervolume/FastHypervolumeArchive.cpp b/src/qualityIndicator/fastHypervolume/FastHypervolumeArchive.cpp index ba2e9d0..c897862 100644 --- a/src/qualityIndicator/fastHypervolume/FastHypervolumeArchive.cpp +++ b/src/qualityIndicator/fastHypervolume/FastHypervolumeArchive.cpp @@ -53,7 +53,7 @@ FastHypervolumeArchive::FastHypervolumeArchive(int maxSize, int numberOfObjectiv */ FastHypervolumeArchive::~FastHypervolumeArchive() { - cout << "DELETING FASTHYPERVOLUMEARCHIVE" << endl; + std::cout << "DELETING FASTHYPERVOLUMEARCHIVE" << std::endl; delete dominance; delete equals; delete referencePoint; diff --git a/src/qualityIndicator/main/Epsilon_main.cpp b/src/qualityIndicator/main/Epsilon_main.cpp index 3b3b467..b395ab2 100644 --- a/src/qualityIndicator/main/Epsilon_main.cpp +++ b/src/qualityIndicator/main/Epsilon_main.cpp @@ -23,7 +23,7 @@ #include -using namespace std; + /** * This method can be invoked from the command line. Three params are required: @@ -36,16 +36,16 @@ int main(int argc, char ** argv) if (argc < 4) { cerr << "Error using delta. Type: \n Epsilon " << - " " << endl; + " " << std::endl; exit(-1); } //Create a new instance of the metric Epsilon * qualityIndicator = snew Epsilon(); //Read the front from the files - vector< vector > solutionFront = + std::vector< std::vector > solutionFront = qualityIndicator->utils_->readFront(argv[1]); - vector< vector > trueFront = + std::vector< std::vector > trueFront = qualityIndicator->utils_->readFront(argv[2]); //Obtain delta value @@ -54,5 +54,5 @@ int main(int argc, char ** argv) delete qualityIndicator; - cout << value << endl; + std::cout << value << std::endl; } // main diff --git a/src/qualityIndicator/main/GenerationalDistance_main.cpp b/src/qualityIndicator/main/GenerationalDistance_main.cpp index 592f641..4599b67 100644 --- a/src/qualityIndicator/main/GenerationalDistance_main.cpp +++ b/src/qualityIndicator/main/GenerationalDistance_main.cpp @@ -23,7 +23,7 @@ #include -using namespace std; + /** * This method can be invoked from the command line. Three params are required: @@ -36,16 +36,16 @@ int main(int argc, char ** argv) if (argc < 4) { cerr << "Error using delta. Type: \n GenerationalDistance " << - " " << endl; + " " << std::endl; exit(-1); } //Create a new instance of the metric GenerationalDistance * qualityIndicator = snew GenerationalDistance(); //Read the front from the files - vector< vector > solutionFront = + std::vector< std::vector > solutionFront = qualityIndicator->utils_->readFront(argv[1]); - vector< vector > trueFront = + std::vector< std::vector > trueFront = qualityIndicator->utils_->readFront(argv[2]); //Obtain delta value @@ -54,5 +54,5 @@ int main(int argc, char ** argv) delete qualityIndicator; - cout << value << endl; + std::cout << value << std::endl; } // main diff --git a/src/qualityIndicator/main/Hypervolume_main.cpp b/src/qualityIndicator/main/Hypervolume_main.cpp index 9210bd6..180d55f 100644 --- a/src/qualityIndicator/main/Hypervolume_main.cpp +++ b/src/qualityIndicator/main/Hypervolume_main.cpp @@ -23,7 +23,7 @@ #include -using namespace std; + /** * This method can be invoked from the command line. Three params are required: @@ -36,16 +36,16 @@ int main(int argc, char ** argv) if (argc < 4) { cerr << "Error using delta. Type: \n Hypervolume " << - " " << endl; + " " << std::endl; exit(-1); } //Create a new instance of the metric Hypervolume * qualityIndicator = snew Hypervolume(); //Read the front from the files - vector< vector > solutionFront = + std::vector< std::vector > solutionFront = qualityIndicator->utils_->readFront(argv[1]); - vector< vector > trueFront = + std::vector< std::vector > trueFront = qualityIndicator->utils_->readFront(argv[2]); //Obtain delta value @@ -54,5 +54,5 @@ int main(int argc, char ** argv) delete qualityIndicator; - cout << value << endl; + std::cout << value << std::endl; } // main diff --git a/src/qualityIndicator/main/InvertedGenerationalDistance_main.cpp b/src/qualityIndicator/main/InvertedGenerationalDistance_main.cpp index 959effc..7f861d3 100644 --- a/src/qualityIndicator/main/InvertedGenerationalDistance_main.cpp +++ b/src/qualityIndicator/main/InvertedGenerationalDistance_main.cpp @@ -23,7 +23,7 @@ #include -using namespace std; + /** * This method can be invoked from the command line. Three params are required: @@ -36,7 +36,7 @@ int main(int argc, char ** argv) if (argc < 4) { cerr << "Error using delta. Type: \n InvertedGenerationalDistance " << - " " << endl; + " " << std::endl; exit(-1); } @@ -44,9 +44,9 @@ int main(int argc, char ** argv) InvertedGenerationalDistance * qualityIndicator = snew InvertedGenerationalDistance(); //Read the front from the files - vector< vector > solutionFront = + std::vector< std::vector > solutionFront = qualityIndicator->utils_->readFront(argv[1]); - vector< vector > trueFront = + std::vector< std::vector > trueFront = qualityIndicator->utils_->readFront(argv[2]); //Obtain delta value @@ -55,5 +55,5 @@ int main(int argc, char ** argv) delete qualityIndicator; - cout << value << endl; + std::cout << value << std::endl; } // main diff --git a/src/qualityIndicator/util/LexicoGraphicalComparator.cpp b/src/qualityIndicator/util/LexicoGraphicalComparator.cpp index 4694e07..9ca0cfc 100644 --- a/src/qualityIndicator/util/LexicoGraphicalComparator.cpp +++ b/src/qualityIndicator/util/LexicoGraphicalComparator.cpp @@ -30,9 +30,9 @@ */ int LexicoGraphicalComparator::compare(void * o1, void * o2) { - //Cast to vector o1 and o2. - vector pointOne = * (vector *) o1; - vector pointTwo = * (vector *) o2; + //Cast to std::vector o1 and o2. + std::vector pointOne = * (std::vector *) o1; + std::vector pointTwo = * (std::vector *) o2; //To determine the first i, that pointOne[i] != pointTwo[i]; int index = 0; diff --git a/src/qualityIndicator/util/MetricsUtil.cpp b/src/qualityIndicator/util/MetricsUtil.cpp index 8fe6e6c..c6e5a6a 100644 --- a/src/qualityIndicator/util/MetricsUtil.cpp +++ b/src/qualityIndicator/util/MetricsUtil.cpp @@ -22,7 +22,7 @@ #include -using namespace std; + /** @@ -30,33 +30,33 @@ using namespace std; * @param path The path to the file that contains the pareto front * @return double [][] whit the pareto front **/ -vector< vector > MetricsUtil::readFront(string path) +std::vector< std::vector > MetricsUtil::readFront(std::string path) { - vector< vector > front; + std::vector< std::vector > front; std::ifstream in(path.c_str()); if( !in ) { - cout << "Error trying to read Pareto Front file: " << path << endl; + std::cout << "Error trying to read Pareto Front file: " << path << std::endl; exit(-1); } - string line; + std::string line; while( getline(in, line ) ) { - vector list; + std::vector list; istringstream iss(line); while (iss) { - string token; + std::string token; iss >> token; if (token.compare("")!=0) { - //cout << "Substring: " << token << endl; + //std::cout << "Substring: " << token << std::endl; list.push_back(atof(token.c_str())); } } @@ -75,14 +75,14 @@ vector< vector > MetricsUtil::readFront(string path) * front * @param front The pareto front * @param noObjectives Number of objectives in the pareto front - * @return vector A vector of noOjectives values with the maximum values + * @return std::vector A vector of noOjectives values with the maximum values * for each objective **/ -vector MetricsUtil::getMaximumValues(vector< vector > front, +std::vector MetricsUtil::getMaximumValues(std::vector< std::vector > front, int noObjectives) { - vector maximumValue; + std::vector maximumValue; for (int i = 0; i < noObjectives; i++) { @@ -109,14 +109,14 @@ vector MetricsUtil::getMaximumValues(vector< vector > front, * front * @param front The pareto front * @param noObjectives Number of objectives in the pareto front - * @return vector A vector of noOjectives values with the minimum values + * @return std::vector A vector of noOjectives values with the minimum values * for each objective **/ -vector MetricsUtil::getMinimumValues(vector< vector > front, +std::vector MetricsUtil::getMinimumValues(std::vector< std::vector > front, int noObjectives) { - vector minimumValue; + std::vector minimumValue; for (int i = 0; i < noObjectives; i++) { @@ -146,7 +146,7 @@ vector MetricsUtil::getMinimumValues(vector< vector > front, * @param b A point * @return The euclidean distance between the points **/ -double MetricsUtil::distance(vector a, vector b) +double MetricsUtil::distance(std::vector a, std::vector b) { double distance = 0.0; @@ -162,14 +162,14 @@ double MetricsUtil::distance(vector a, vector b) /** * Gets the distance between a point and the nearest one in - * a given front (the front is given as vector< vector >) + * a given front (the front is given as std::vector< std::vector >) * @param point The point * @param front The front that contains the other points to calculate the * distances * @return The minimum distance between the point and the front **/ -double MetricsUtil::distanceToClosedPoint(vector point, - vector< vector > front) +double MetricsUtil::distanceToClosedPoint(std::vector point, + std::vector< std::vector > front) { double minDistance = distance(point,front[0]); @@ -197,8 +197,8 @@ double MetricsUtil::distanceToClosedPoint(vector point, * @return The minimun distances greater than zero between the point and * the front */ -double MetricsUtil::distanceToNearestPoint(vector point, - vector< vector > front) +double MetricsUtil::distanceToNearestPoint(std::vector point, + std::vector< std::vector > front) { double minDistance = std::numeric_limits::max(); @@ -226,15 +226,15 @@ double MetricsUtil::distanceToNearestPoint(vector point, * @param minimumValue The minimum values allowed * @return the normalized pareto front **/ -vector< vector > MetricsUtil::getNormalizedFront(vector< vector > front, - vector maximumValue, vector minimumValue) +std::vector< std::vector > MetricsUtil::getNormalizedFront(std::vector< std::vector > front, + std::vector maximumValue, std::vector minimumValue) { - vector< vector > normalizedFront; + std::vector< std::vector > normalizedFront; for (int i = 0; i < front.size(); i++) { - vector list; + std::vector list; for (int j = 0; j < front[i].size(); j++) { //normalizedFront[i][j] = (front[i][j] - minimumValue[j]) / @@ -255,14 +255,14 @@ vector< vector > MetricsUtil::getNormalizedFront(vector< vector * @param front The pareto front to inverse * @return The inverted pareto front **/ -vector< vector > MetricsUtil::invertedFront(vector< vector > front) +std::vector< std::vector > MetricsUtil::invertedFront(std::vector< std::vector > front) { - vector< vector > invertedFront; + std::vector< std::vector > invertedFront; for (int i = 0; i < front.size(); i++) { - vector list; + std::vector list; for (int j = 0; j < front[i].size(); j++) { if (front[i][j] <= 1.0 && front[i][j]>= 0.0) @@ -291,32 +291,32 @@ vector< vector > MetricsUtil::invertedFront(vector< vector > fro * @param path The path of the file containing the data * @return A solution set */ -SolutionSet * MetricsUtil::readNonDominatedSolutionSet(string path) +SolutionSet * MetricsUtil::readNonDominatedSolutionSet(std::string path) { std::ifstream in(path.c_str()); if( !in ) { - cout << "Error trying to read non dominated solutions file: " - << path << endl; + std::cout << "Error trying to read non dominated solutions file: " + << path << std::endl; exit(-1); } // if NonDominatedSolutionList * solutionSet = snew NonDominatedSolutionList(); - string line; + std::string line; while( getline(in, line ) ) { - vector list; + std::vector list; istringstream iss(line); while (iss) { - string token; + std::string token; iss >> token; if (token.compare("")!=0) { - //cout << "Substring: " << token << endl; + //std::cout << "Substring: " << token << std::endl; list.push_back(atof(token.c_str())); } // if } // while @@ -342,31 +342,31 @@ SolutionSet * MetricsUtil::readNonDominatedSolutionSet(string path) * @param path The path of the file containing the data * @return A solution set */ -void MetricsUtil::readNonDominatedSolutionSet(string path, NonDominatedSolutionList * solutionSet) +void MetricsUtil::readNonDominatedSolutionSet(std::string path, NonDominatedSolutionList * solutionSet) { std::ifstream in(path.c_str()); if( !in ) { - cout << "Error trying to read non dominated solutions file: " - << path << endl; + std::cout << "Error trying to read non dominated solutions file: " + << path << std::endl; exit(-1); } // if - string line; + std::string line; while( getline(in, line ) ) { - vector list; + std::vector list; istringstream iss(line); while (iss) { - string token; + std::string token; iss >> token; if (token.compare("")!=0) { - //cout << "Substring: " << token << endl; + //std::cout << "Substring: " << token << std::endl; list.push_back(atof(token.c_str())); } // if } // while diff --git a/src/util/AdaptiveGrid.cpp b/src/util/AdaptiveGrid.cpp index 47158dd..59af53c 100644 --- a/src/util/AdaptiveGrid.cpp +++ b/src/util/AdaptiveGrid.cpp @@ -19,7 +19,7 @@ // along with this program. If not, see . #include "AdaptiveGrid.h" -using namespace std; + /** * Constructor. @@ -305,7 +305,7 @@ int AdaptiveGrid::getBisections() * Retunrns a String representing the grid. * @return The String. */ -string AdaptiveGrid::toString() +std::string AdaptiveGrid::toString() { stringstream result; result << "Grid\n"; diff --git a/src/util/AdaptiveGrid.h b/src/util/AdaptiveGrid.h index 1a1b2d3..d9d631d 100644 --- a/src/util/AdaptiveGrid.h +++ b/src/util/AdaptiveGrid.h @@ -95,7 +95,7 @@ class AdaptiveGrid void removeSolution(int location); void addSolution(int location); int getBisections(); - string toString(); + std::string toString(); int rouletteWheel(); int calculateOccupied(); int occupiedHypercubes(); diff --git a/src/util/AdaptiveRandomNeighborhood.cpp b/src/util/AdaptiveRandomNeighborhood.cpp index b5340e0..5b2d052 100644 --- a/src/util/AdaptiveRandomNeighborhood.cpp +++ b/src/util/AdaptiveRandomNeighborhood.cpp @@ -42,7 +42,7 @@ AdaptiveRandomNeighborhood::AdaptiveRandomNeighborhood(SolutionSet * solutionSet for (int i = 0; i < solutionSet_->size(); i++) { //list_[i] = snew int [] - vector list_i; + std::vector list_i; list_i.push_back(i); list_.push_back(list_i); } @@ -53,14 +53,14 @@ AdaptiveRandomNeighborhood::AdaptiveRandomNeighborhood(SolutionSet * solutionSet // /* v does not contain x */ // } - //cout << "list: " << list_ << endl; + //std::cout << "list: " << list_ << std::endl; for (int i = 0; i < solutionSet_->size(); i++) { //list_.at(i).push_back(i); for (int j = 0; j < numberOfRandomNeighbours_; j++) { int random = PseudoRandom::randInt(0, solutionSet_->size() - 1); - //cout << "i: " << i >> " random: " << random << " listb: " << list_at(random) << endl; + //std::cout << "i: " << i >> " random: " << random << " listb: " << list_at(random) << std::endl; //if (!list_.at(random).contains((Integer) i)) if (find(list_.at(random).begin(), list_.at(random).end(), i) == list_.at(random).end()) { @@ -68,34 +68,34 @@ AdaptiveRandomNeighborhood::AdaptiveRandomNeighborhood(SolutionSet * solutionSet } } } - //cout << "L: " << list_ << endl; - cout << "L:" << endl; + //std::cout << "L: " << list_ << std::endl; + std::cout << "L:" << std::endl; for (int i = 0; i < list_.size(); i++) { - cout << "\t["; + std::cout << "\t["; for (int j = 0; j < list_.at(i).size(); j++) { - cout << list_.at(i).at(j); + std::cout << list_.at(i).at(j); if (j < list_.at(i).size()-1) { - cout << ","; + std::cout << ","; } else { - cout << "]" << endl; + std::cout << "]" << std::endl; } } } } -vector AdaptiveRandomNeighborhood::getNeighbors(int i) +std::vector AdaptiveRandomNeighborhood::getNeighbors(int i) { if (i > list_.size()) { cerr << "Error in AdaptiveRandomNeighborhood.getNeighbors" << "the parameter " << i << " is less than " << list_.size() - << endl; + << std::endl; exit(-1); } return list_.at(i); @@ -128,7 +128,7 @@ SolutionSet * AdaptiveRandomNeighborhood::getBestFitnessSolutionInNeighborhood(C } -vector> AdaptiveRandomNeighborhood::getNeighborhood() +std::vector> AdaptiveRandomNeighborhood::getNeighborhood() { return list_; } @@ -141,7 +141,7 @@ void AdaptiveRandomNeighborhood::recompute() for (int i = 0; i < solutionSet_->size(); i++) { //list_[i] = snew int [] - vector list_i; + std::vector list_i; list_i.push_back(i); list_.push_back(list_i); } diff --git a/src/util/AdaptiveRandomNeighborhood.h b/src/util/AdaptiveRandomNeighborhood.h index 318e7ce..e93bcae 100644 --- a/src/util/AdaptiveRandomNeighborhood.h +++ b/src/util/AdaptiveRandomNeighborhood.h @@ -30,7 +30,7 @@ #include //#include -using namespace std; + /** * Class representing an adaptive random neighborhood @@ -41,18 +41,18 @@ class AdaptiveRandomNeighborhood private: SolutionSet * solutionSet_; - vector> list_; + std::vector> list_; int numberOfRandomNeighbours_; public: AdaptiveRandomNeighborhood(SolutionSet * solutionSet, int numberOfRandomNeighbours); - vector getNeighbors(int i); + std::vector getNeighbors(int i); int getNumberOfRandomNeighbours(); SolutionSet * getBestFitnessSolutionInNeighborhood(Comparator * comparator); - vector> getNeighborhood(); + std::vector> getNeighborhood(); void recompute(); - //string toString(); + //std::string toString(); }; // AdaptiveRandomNeighborhood diff --git a/src/util/Distance.h b/src/util/Distance.h index 171d227..ea0e470 100644 --- a/src/util/Distance.h +++ b/src/util/Distance.h @@ -29,7 +29,7 @@ #include #include -using namespace std; + /** diff --git a/src/util/PseudoRandom.cpp b/src/util/PseudoRandom.cpp index 03d5d65..e506966 100644 --- a/src/util/PseudoRandom.cpp +++ b/src/util/PseudoRandom.cpp @@ -22,7 +22,7 @@ #include -using namespace std; + /** * This file is aimed at defining the interface for the random generator. diff --git a/src/util/RandomGenerator.cpp b/src/util/RandomGenerator.cpp index d45068b..318bcd5 100644 --- a/src/util/RandomGenerator.cpp +++ b/src/util/RandomGenerator.cpp @@ -35,15 +35,15 @@ RandomGenerator::RandomGenerator() { srand(time(nullptr)); //srand(0); - //cout << (unsigned)time(0) << endl; + //std::cout << (unsigned)time(0) << std::endl; seed_ = ((double) rand() / (double) (RAND_MAX )); - //cout << "Seed value is: " << seed_ << endl; + //std::cout << "Seed value is: " << seed_ << std::endl; // seed_ = RAND_MAX; - // cout << "Seed value is: " << seed_ << endl; + // std::cout << "Seed value is: " << seed_ << std::endl; // seed_ = (double) ((float) (float) seed_ / (float) RAND_MAX); - // cout << "Seed value is: " << seed_ << endl; + // std::cout << "Seed value is: " << seed_ << std::endl; randomize(); } // RandomGenerator diff --git a/src/util/Ranking.cpp b/src/util/Ranking.cpp index 8272b2d..fb7c58f 100644 --- a/src/util/Ranking.cpp +++ b/src/util/Ranking.cpp @@ -51,15 +51,15 @@ Ranking::Ranking (SolutionSet * solutionSet) if (dominateMe == nullptr) { - cout << "Fatal Problem: Cannot reserve memory in class Ranking" << endl; + std::cout << "Fatal Problem: Cannot reserve memory in class Ranking" << std::endl; exit(-1); } // iDominate[k] contains the list of solutions dominated by k - vector * iDominate = new vector[solutionSet_->size()]; + std::vector * iDominate = new std::vector[solutionSet_->size()]; // front[i] contains the list of individuals belonging to the front i - vector * front = new vector[solutionSet_->size()+1]; + std::vector * front = new std::vector[solutionSet_->size()+1]; // flagDominate is an auxiliar variable int flagDominate; @@ -109,7 +109,7 @@ Ranking::Ranking (SolutionSet * solutionSet) // Obtain the rest of fronts int i = 0; - vector::iterator it1, it2; + std::vector::iterator it1, it2; while (front[i].size()!=0) { i++; @@ -130,7 +130,7 @@ Ranking::Ranking (SolutionSet * solutionSet) ranking_ = new SolutionSet*[i]; if (ranking_ == nullptr) { - cout << "Fatal Error: Impossible to reserve memory in Ranking" << endl; + std::cout << "Fatal Error: Impossible to reserve memory in Ranking" << std::endl; exit(-1); } diff --git a/src/util/wrapper/XReal.cpp b/src/util/wrapper/XReal.cpp index ce8dafe..49776cf 100644 --- a/src/util/wrapper/XReal.cpp +++ b/src/util/wrapper/XReal.cpp @@ -62,8 +62,8 @@ double XReal::getValue(int index) } else { - cout << "ERROR GRAVE: solution type " - << typeid(*type_).name() << " invalid" << endl; + std::cout << "ERROR GRAVE: solution type " + << typeid(*type_).name() << " invalid" << std::endl; exit(-1); } return 0.0; @@ -89,8 +89,8 @@ void XReal::setValue(int index, double value) } else { - cout << "ERROR GRAVE: solution type " - << typeid(*type_).name() << " invalid" << endl; + std::cout << "ERROR GRAVE: solution type " + << typeid(*type_).name() << " invalid" << std::endl; exit(-1); } } // setValue @@ -111,8 +111,8 @@ double XReal::getLowerBound(int index) return ((ArrayReal*)(solution_->getDecisionVariables()[0]))->getLowerBound(index); else { - cout << "ERROR GRAVE: solution type " - << typeid(*type_).name() << " invalid" << endl; + std::cout << "ERROR GRAVE: solution type " + << typeid(*type_).name() << " invalid" << std::endl; exit(-1); } return 0.0; @@ -134,8 +134,8 @@ double XReal::getUpperBound(int index) return ((ArrayReal*)(solution_->getDecisionVariables()[0]))->getUpperBound(index); else { - cout << "ERROR GRAVE: solution type " - << typeid(*type_).name() << " invalid" << endl; + std::cout << "ERROR GRAVE: solution type " + << typeid(*type_).name() << " invalid" << std::endl; exit(-1); } return 0.0; @@ -156,8 +156,8 @@ int XReal::getNumberOfDecisionVariables() return ((ArrayReal*)(solution_->getDecisionVariables()[0]))->getLength() ; else { - cout << "ERROR GRAVE: solution type " - << typeid(*type_).name() << " invalid" << endl; + std::cout << "ERROR GRAVE: solution type " + << typeid(*type_).name() << " invalid" << std::endl; exit(-1); } return 0 ; @@ -177,8 +177,8 @@ int XReal::size() return ((ArrayReal*)(solution_->getDecisionVariables()[0]))->getLength(); else { - cout << "ERROR GRAVE: solution type " - << typeid(*type_).name() << " invalid" << endl; + std::cout << "ERROR GRAVE: solution type " + << typeid(*type_).name() << " invalid" << std::endl; exit(-1); } return 0 ; From c9b6924d6b154cf109f34af325476d2851d3f140 Mon Sep 17 00:00:00 2001 From: Sergio Vieira Date: Fri, 28 Jul 2017 15:31:36 -0300 Subject: [PATCH 11/29] - Adds aliases to common data structures --- src/core/Algorithm.h | 11 +++-- src/core/JMetalHeader.h | 23 +++++++++ src/core/Operator.cpp | 2 +- src/core/Operator.h | 12 ++--- src/core/SolutionSet.cpp | 6 +-- src/core/SolutionSet.h | 7 +-- src/encodings/variable/Binary.cpp | 8 ++-- src/encodings/variable/Binary.h | 6 ++- src/experiments/Experiment.h | 14 ++---- src/experiments/ExperimentExecution.h | 2 +- src/experiments/ExperimentReport.cpp | 33 +++++++------ src/experiments/ExperimentReport.h | 17 ++++--- src/experiments/Settings.cpp | 2 +- src/experiments/settings/DE_Settings.cpp | 2 +- src/experiments/settings/GDE3_Settings.cpp | 2 +- src/experiments/settings/NSGAII_Settings.cpp | 2 +- src/experiments/settings/PSO_Settings.cpp | 2 +- src/experiments/settings/SMPSO_Settings.cpp | 2 +- src/experiments/settings/gGA_Settings.cpp | 2 +- src/experiments/settings/ssGA_Settings.cpp | 2 +- src/experiments/util/RBoxplot.cpp | 2 +- src/experiments/util/RBoxplot.h | 6 ++- src/experiments/util/RWilcoxon.cpp | 2 +- src/experiments/util/RWilcoxon.h | 6 ++- src/experiments/util/RunExperiment.cpp | 6 +-- src/experiments/util/RunExperiment.h | 8 ++-- src/experiments/util/Statistics.cpp | 4 +- src/experiments/util/Statistics.h | 8 ++-- src/main/OMOPSO_main.cpp | 2 +- src/metaheuristics/moead/MOEAD.cpp | 4 +- src/metaheuristics/moead/MOEAD.h | 2 +- .../singleObjective/geneticAlgorithm/ssGA.cpp | 2 +- .../particleSwarmOptimization/PSO.cpp | 2 +- .../StandardPSO2007.cpp | 2 +- .../StandardPSO2011.cpp | 2 +- src/metaheuristics/smpso/SMPSO.h | 2 +- src/metaheuristics/smsemoa/FastSMSEMOA.h | 16 +++---- src/metaheuristics/smsemoa/SMSEMOA.cpp | 24 +++++----- src/operators/crossover/Crossover.cpp | 2 +- src/operators/crossover/Crossover.h | 2 +- .../DifferentialEvolutionCrossover.cpp | 2 +- .../DifferentialEvolutionCrossover.h | 2 +- src/operators/crossover/HUXCrossover.cpp | 2 +- src/operators/crossover/HUXCrossover.h | 2 +- src/operators/crossover/SBXCrossover.cpp | 2 +- src/operators/crossover/SBXCrossover.h | 2 +- .../crossover/SinglePointCrossover.cpp | 2 +- src/operators/mutation/BitFlipMutation.cpp | 2 +- src/operators/mutation/BitFlipMutation.h | 2 +- src/operators/mutation/Mutation.cpp | 2 +- src/operators/mutation/Mutation.h | 2 +- src/operators/mutation/NonUniformMutation.cpp | 2 +- src/operators/mutation/NonUniformMutation.h | 2 +- src/operators/mutation/PolynomialMutation.cpp | 2 +- src/operators/mutation/PolynomialMutation.h | 2 +- src/operators/mutation/UniformMutation.cpp | 2 +- .../selection/BestSolutionSelection.cpp | 2 +- .../selection/BestSolutionSelection.h | 2 +- src/operators/selection/BinaryTournament.cpp | 2 +- src/operators/selection/BinaryTournament.h | 2 +- src/operators/selection/BinaryTournament2.cpp | 2 +- src/operators/selection/BinaryTournament2.h | 2 +- .../DifferentialEvolutionSelection.cpp | 2 +- .../DifferentialEvolutionSelection.h | 2 +- src/operators/selection/RandomSelection.cpp | 2 +- src/operators/selection/RandomSelection.h | 2 +- src/operators/selection/Selection.cpp | 2 +- src/operators/selection/Selection.h | 2 +- .../selection/WorstSolutionSelection.cpp | 2 +- src/problems/LZ09/LZ09.cpp | 44 ++++++++--------- src/problems/LZ09/LZ09.h | 10 ++-- src/problems/LZ09/LZ09_F1.cpp | 4 +- src/problems/LZ09/LZ09_F2.cpp | 4 +- src/problems/LZ09/LZ09_F3.cpp | 4 +- src/problems/LZ09/LZ09_F4.cpp | 4 +- src/problems/LZ09/LZ09_F5.cpp | 4 +- src/problems/LZ09/LZ09_F6.cpp | 4 +- src/problems/LZ09/LZ09_F7.cpp | 4 +- src/problems/LZ09/LZ09_F8.cpp | 4 +- src/problems/LZ09/LZ09_F9.cpp | 4 +- src/qualityIndicator/Epsilon.cpp | 2 +- src/qualityIndicator/Epsilon.h | 5 +- src/qualityIndicator/Fitness.cpp | 2 +- src/qualityIndicator/Fitness.h | 2 +- src/qualityIndicator/GenerationalDistance.cpp | 12 ++--- src/qualityIndicator/GenerationalDistance.h | 4 +- src/qualityIndicator/Hypervolume.cpp | 12 ++--- src/qualityIndicator/Hypervolume.h | 4 +- .../InvertedGenerationalDistance.cpp | 10 ++-- .../InvertedGenerationalDistance.h | 4 +- src/qualityIndicator/Spread.cpp | 14 +++--- src/qualityIndicator/main/Epsilon_main.cpp | 4 +- .../main/GenerationalDistance_main.cpp | 4 +- .../main/Hypervolume_main.cpp | 4 +- .../InvertedGenerationalDistance_main.cpp | 4 +- .../util/LexicoGraphicalComparator.cpp | 8 ++-- .../util/LexicoGraphicalComparator.h | 1 - src/qualityIndicator/util/MetricsUtil.cpp | 48 +++++++++---------- src/qualityIndicator/util/MetricsUtil.h | 27 +++++------ src/util/AdaptiveRandomNeighborhood.cpp | 8 ++-- src/util/AdaptiveRandomNeighborhood.h | 21 ++------ src/util/Ranking.cpp | 6 +-- 102 files changed, 315 insertions(+), 300 deletions(-) diff --git a/src/core/Algorithm.h b/src/core/Algorithm.h index a7f40a1..59937c5 100644 --- a/src/core/Algorithm.h +++ b/src/core/Algorithm.h @@ -36,6 +36,9 @@ * The class declares an abstract method called execute, which * defines the behavior of the algorithm. **/ + +using namespace JMetal; + class Algorithm { @@ -53,10 +56,10 @@ class Algorithm Problem * getProblem(); protected: - Problem *problem_; - std::map operators_; - std::map inputParameters_; - std::map outputParameters_; + Problem *problem_ = nullptr; + MapOfStringOperatorPtr operators_; + MapOfStringFunct inputParameters_; + MapOfStringFunct outputParameters_; }; // Algorithm diff --git a/src/core/JMetalHeader.h b/src/core/JMetalHeader.h index ffaeefb..92e6d72 100644 --- a/src/core/JMetalHeader.h +++ b/src/core/JMetalHeader.h @@ -9,4 +9,27 @@ #define snew new #endif +#include +#include +#include + +class Operator; +class Solution; + +namespace JMetal +{ + using MapOfStringFunct = std::map; + using MapOfStringOperatorPtr = std::map; + using MapOfStringDouble = std::map; + using MapOfStringBool = std::map; + using VectorOfSolutionPtr = std::vector; + using VectorOfDouble = std::vector; + using MatrixOfDouble = std::vector; + using VectorOfInteger = std::vector; + using MatrixOfInteger = std::vector; + using VectorOfBoolean = std::vector; + using MatrixOfBoolean = std::vector; + using VectorOfString = std::vector; +} + #endif \ No newline at end of file diff --git a/src/core/Operator.cpp b/src/core/Operator.cpp index 10479f2..6487052 100644 --- a/src/core/Operator.cpp +++ b/src/core/Operator.cpp @@ -35,7 +35,7 @@ Operator::Operator() /** * Constructor. **/ -Operator::Operator(std::map parameters) +Operator::Operator(MapOfStringFunct parameters) { parameters_ = parameters; } // Operator diff --git a/src/core/Operator.h b/src/core/Operator.h index 3537fb5..bd555fb 100644 --- a/src/core/Operator.h +++ b/src/core/Operator.h @@ -23,27 +23,27 @@ #ifndef __OPERATOR__ #define __OPERATOR__ -#include -#include +#include "JMetalHeader.h" #include - - /** * Stores the current operator parameters. * It is defined as a Map of pairs <String, Object>, * and it allow objects to be accessed by their names, which are specified * by the string. **/ + +using namespace JMetal; + class Operator { protected: - std::map parameters_; + MapOfStringFunct parameters_; public: Operator (); - Operator (std::map parameters); + Operator (MapOfStringFunct parameters); virtual ~Operator() = 0; virtual void *execute(void *) = 0; void setParameter(std::string name, void *value); diff --git a/src/core/SolutionSet.cpp b/src/core/SolutionSet.cpp index ae8e8cd..b4edde1 100644 --- a/src/core/SolutionSet.cpp +++ b/src/core/SolutionSet.cpp @@ -415,13 +415,13 @@ void SolutionSet::replace(int position, Solution *solution) * Copies the objectives of the solution set to a matrix * @return A matrix containing the objectives */ -std::vector > SolutionSet::writeObjectivesToMatrix() +std::vector SolutionSet::writeObjectivesToMatrix() { - std::vector > objectives; + std::vector objectives; //objectives = snew double[size()][get(0).numberOfObjectives()]; for (int i = 0; i < size(); i++) { - std::vector list; + VectorOfDouble list; for (int j = 0; j < get(0)->getNumberOfObjectives(); j++) { list.push_back(get(i)->getObjective(j)); diff --git a/src/core/SolutionSet.h b/src/core/SolutionSet.h index 7d7f747..b2ad35b 100644 --- a/src/core/SolutionSet.h +++ b/src/core/SolutionSet.h @@ -23,6 +23,7 @@ #ifndef __SOLUTION_SET__ #define __SOLUTION_SET__ +#include "JMetalHeader.h" #include #include #include @@ -33,7 +34,7 @@ #include #include - +using namespace JMetal; //class Solution ; class Comparator; @@ -46,7 +47,7 @@ class SolutionSet { protected: - std::vector solutionsList_; + VectorOfSolutionPtr solutionsList_; int capacity_; public: @@ -76,7 +77,7 @@ class SolutionSet SolutionSet * join(SolutionSet * another); void replace(int position, Solution * solution); void replace(int position, Solution * solution, bool del); - std::vector > writeObjectivesToMatrix(); + std::vector writeObjectivesToMatrix(); void printObjectives(); //void reset() ; diff --git a/src/encodings/variable/Binary.cpp b/src/encodings/variable/Binary.cpp index 1cb772c..8929987 100644 --- a/src/encodings/variable/Binary.cpp +++ b/src/encodings/variable/Binary.cpp @@ -41,7 +41,7 @@ Binary::Binary(int numberOfBits) { numberOfBits_ = numberOfBits; - bits_ = snew std::vector(numberOfBits_, false) ; + bits_ = snew VectorOfBoolean(numberOfBits_, false) ; for (int i = 0; i < numberOfBits_; i++) { @@ -64,7 +64,7 @@ Binary::Binary(int numberOfBits) Binary::Binary(Binary * variable) { numberOfBits_ = variable->getNumberOfBits(); - bits_ = snew std::vector(numberOfBits_, false) ; + bits_ = snew VectorOfBoolean(numberOfBits_, false) ; for (int i = 0; i < numberOfBits_; i++) { (*bits_)[i] = (*variable->bits_)[i] ; @@ -171,7 +171,7 @@ int Binary::hammingDistance(Binary * other) */ std::string Binary::toString() { - std::vector::iterator it; + VectorOfBoolean::iterator it; std::string str = "" ; for(it = bits_->begin(); it != bits_->end(); it++) { @@ -189,7 +189,7 @@ std::string Binary::toString() int Binary::cardinality() { int counter = 0 ; - std::vector::iterator it; + VectorOfBoolean::iterator it; for(it = bits_->begin(); it != bits_->end(); it++) if (*it == true) counter ++ ; diff --git a/src/encodings/variable/Binary.h b/src/encodings/variable/Binary.h index ed10e10..ad21695 100644 --- a/src/encodings/variable/Binary.h +++ b/src/encodings/variable/Binary.h @@ -23,12 +23,14 @@ #ifndef Binary_h #define Binary_h +#include "JMetalHeader.h" #include #include -#include #include #include +using namespace JMetal; + /** * This class implements a generic binary std::string variable.It can be used as * a base class other binary std::string based classes (e.g., binary coded integer @@ -60,7 +62,7 @@ class Binary : public Variable double getUpperBound(); protected: - std::vector * bits_; + VectorOfBoolean * bits_ = nullptr; int numberOfBits_; }; diff --git a/src/experiments/Experiment.h b/src/experiments/Experiment.h index 4528b89..5e3e0ce 100644 --- a/src/experiments/Experiment.h +++ b/src/experiments/Experiment.h @@ -22,13 +22,12 @@ #ifndef __EXPERIMENT__ #define __EXPERIMENT__ -#include -#include +#include "JMetalHeader.h" #include #include #include - +using namespace JMetal; /** * Abstract class representing jMetal experiments @@ -36,22 +35,17 @@ class Experiment { - public: - std::string experimentName_; - std::vector algorithmNameList_; // List of the names of the algorithms to + VectorOfString algorithmNameList_; // List of the names of the algorithms to // be executed - std::vector problemList_; // List of problems to be solved + VectorOfString problemList_; // List of problems to be solved std::string experimentBaseDirectory_; // Directory to store the results int independentRuns_; // Number of independent runs per algorithm bool isSingleObjective_; // If this experiment is a singleObjective one or not - Experiment(); - void checkExperimentDirectory(); void resetFile(std::string file); - }; #endif /* __EXPERIMENT__ */ diff --git a/src/experiments/ExperimentExecution.h b/src/experiments/ExperimentExecution.h index 6cabef1..6071a3f 100644 --- a/src/experiments/ExperimentExecution.h +++ b/src/experiments/ExperimentExecution.h @@ -41,7 +41,7 @@ class ExperimentExecution : public Experiment private: - std::map map_; // Map used to send experiment parameters to threads + MapOfStringFunct map_; // Map used to send experiment parameters to threads public: diff --git a/src/experiments/ExperimentReport.cpp b/src/experiments/ExperimentReport.cpp index 0ca836f..89a14d7 100644 --- a/src/experiments/ExperimentReport.cpp +++ b/src/experiments/ExperimentReport.cpp @@ -110,8 +110,7 @@ void ExperimentReport::generateQualityIndicators() std::string qualityIndicatorFile = problemDirectory; Fitness * indicators = snew Fitness(); - std::vector< std::vector > solutionFront = - indicators->utils_->readFront(solutionFrontFile); + MatrixOfDouble solutionFront = indicators->utils_->readFront(solutionFrontFile); qualityIndicatorFile = qualityIndicatorFile + "/FIT"; indicators->fitness(solutionFront, qualityIndicatorFile); delete indicators; @@ -135,9 +134,9 @@ void ExperimentReport::generateQualityIndicators() { Hypervolume * indicators = snew Hypervolume(); - std::vector< std::vector > solutionFront = + MatrixOfDouble solutionFront = indicators->utils_->readFront(solutionFrontFile); - std::vector< std::vector > trueFront = + MatrixOfDouble trueFront = indicators->utils_->readFront(paretoFrontPath); value = indicators->hypervolume(solutionFront, trueFront, trueFront[0].size()); delete indicators; @@ -146,9 +145,9 @@ void ExperimentReport::generateQualityIndicators() if (indicatorList_[indicatorIndex].compare("SPREAD")==0) { Spread * indicators = snew Spread(); - std::vector< std::vector > solutionFront = + MatrixOfDouble solutionFront = indicators->utils_->readFront(solutionFrontFile); - std::vector< std::vector > trueFront = + MatrixOfDouble trueFront = indicators->utils_->readFront(paretoFrontPath); value = indicators->spread(solutionFront, trueFront, trueFront[0].size()); delete indicators; @@ -157,9 +156,9 @@ void ExperimentReport::generateQualityIndicators() if (indicatorList_[indicatorIndex].compare("IGD")==0) { InvertedGenerationalDistance * indicators = snew InvertedGenerationalDistance(); - std::vector< std::vector > solutionFront = + MatrixOfDouble solutionFront = indicators->utils_->readFront(solutionFrontFile); - std::vector< std::vector > trueFront = + MatrixOfDouble trueFront = indicators->utils_->readFront(paretoFrontPath); value = indicators->invertedGenerationalDistance(solutionFront, trueFront, trueFront[0].size()); delete indicators; @@ -168,9 +167,9 @@ void ExperimentReport::generateQualityIndicators() if (indicatorList_[indicatorIndex].compare("EPSILON")==0) { Epsilon * indicators = snew Epsilon(); - std::vector< std::vector > solutionFront = + MatrixOfDouble solutionFront = indicators->utils_->readFront(solutionFrontFile); - std::vector< std::vector > trueFront = + MatrixOfDouble trueFront = indicators->utils_->readFront(paretoFrontPath); value = indicators->epsilon(solutionFront, trueFront, trueFront[0].size()); delete indicators; @@ -251,15 +250,15 @@ void ExperimentReport::generateLatexTables() latexDirectory_ = experimentBaseDirectory_ + "/" + latexDirectory_; std::cout << "latex directory: " << latexDirectory_ << std::endl; - std::vector *** data = snew std::vector**[indicatorList_.size()]; + VectorOfDouble *** data = snew VectorOfDouble**[indicatorList_.size()]; for (int indicator = 0; indicator < indicatorList_.size(); indicator++) { // A data vector per problem - data[indicator] = snew std::vector*[problemList_.size()]; + data[indicator] = snew VectorOfDouble*[problemList_.size()]; for (int problem = 0; problem < problemList_.size(); problem++) { - data[indicator][problem] = snew std::vector[algorithmNameList_.size()]; + data[indicator][problem] = snew VectorOfDouble[algorithmNameList_.size()]; for (int algorithm = 0; algorithm < algorithmNameList_.size(); algorithm++) { @@ -294,7 +293,7 @@ void ExperimentReport::generateLatexTables() double *** min; int *** numberOfValues; - std::map statValues; + MapOfStringDouble statValues; statValues["mean"] = 0.0; statValues["median"] = 0.0; @@ -425,7 +424,7 @@ void ExperimentReport::generateLatexTables() /** * Calculates statistical values from a vector of Double objects */ -void ExperimentReport::calculateStatistics(std::vector vector,std::map * values) +void ExperimentReport::calculateStatistics(VectorOfDouble vector, MapOfStringDouble * values) { if (vector.size() > 0) { @@ -788,7 +787,7 @@ void ExperimentReport::printMedianIQR(std::string fileName, int indicator, doubl /** * Invoking the generateScripts method on the RBoxplot class */ -void ExperimentReport::generateRBoxplotScripts (int rows, int cols, std::vector problems, +void ExperimentReport::generateRBoxplotScripts (int rows, int cols, VectorOfString problems, std::string prefix, bool notch, ExperimentReport * experiment) { RBoxplot::generateScripts(rows, cols, problems, prefix, notch, this); @@ -798,7 +797,7 @@ void ExperimentReport::generateRBoxplotScripts (int rows, int cols, std::vector< /** * Invoking the generateScripts method on the RWilcoxon class */ -void ExperimentReport::generateRWilcoxonScripts(std::vector problems, std::string prefix, +void ExperimentReport::generateRWilcoxonScripts(VectorOfString problems, std::string prefix, ExperimentReport * experiment) { RWilcoxon::generateScripts(problems, prefix, this); diff --git a/src/experiments/ExperimentReport.h b/src/experiments/ExperimentReport.h index 2229a31..576963b 100644 --- a/src/experiments/ExperimentReport.h +++ b/src/experiments/ExperimentReport.h @@ -22,9 +22,7 @@ #ifndef __EXPERIMENT_REPORT__ #define __EXPERIMENT_REPORT__ -#include -#include -#include +#include "JMetalHeader.h" #include #include #include @@ -47,6 +45,7 @@ #include +using namespace JMetal; /** * Abstract class generating jMetal experiments reports @@ -58,7 +57,7 @@ class ExperimentReport : public Experiment private: void generateReferenceFronts(); - void calculateStatistics(std::vector vector_,std::map * values); + void calculateStatistics(VectorOfDouble vector_, MapOfStringDouble * values); void printHeaderLatexCommands(std::string fileName); void printEndLatexCommands(std::string fileName); void printMeanStdDev(std::string fileName, int indicator, double*** mean, @@ -68,13 +67,13 @@ class ExperimentReport : public Experiment public: - std::vector paretoFrontFile_; // List of the files containing the pareto + VectorOfString paretoFrontFile_; // List of the files containing the pareto // fronts corresponding to the problems in // problemList_ - std::vector indicatorList_; // List of the quality indicators to be applied + VectorOfString indicatorList_; // List of the quality indicators to be applied std::string latexDirectory_; // Directory to store the latex files std::string paretoFrontDirectory_; // Directory containing the Pareto front files - std::map indicatorMinimize_; // To indicate whether an indicator + MapOfStringBool indicatorMinimize_; // To indicate whether an indicator // is to be minimized. Hard-coded // in the constructor @@ -82,9 +81,9 @@ class ExperimentReport : public Experiment void generateQualityIndicators(); void generateLatexTables(); - void generateRBoxplotScripts(int rows, int cols, std::vector problems, + void generateRBoxplotScripts(int rows, int cols, VectorOfString problems, std::string prefix, bool notch, ExperimentReport * experiment); - void generateRWilcoxonScripts(std::vector problems, std::string prefix, + void generateRWilcoxonScripts(VectorOfString problems, std::string prefix, ExperimentReport * experiment); }; // ExperimentReport diff --git a/src/experiments/Settings.cpp b/src/experiments/Settings.cpp index 12a265f..3eea38e 100644 --- a/src/experiments/Settings.cpp +++ b/src/experiments/Settings.cpp @@ -45,7 +45,7 @@ Settings::~Settings() { /* do nothing */ } * * To be implemented. Missing the reflection features of Java here */ -Algorithm * Settings::configure(std::map settings) +Algorithm * Settings::configure(MapOfStringFunct settings) { return nullptr ; } // configure diff --git a/src/experiments/settings/DE_Settings.cpp b/src/experiments/settings/DE_Settings.cpp index 4ec766f..6685cbd 100644 --- a/src/experiments/settings/DE_Settings.cpp +++ b/src/experiments/settings/DE_Settings.cpp @@ -66,7 +66,7 @@ Algorithm * DE_Settings::configure() algorithm->setInputParameter("populationSize",&populationSize_); algorithm->setInputParameter("maxEvaluations",&maxEvaluations_); - std::map parameters; + MapOfStringFunct parameters; // Crossover operator double crParameter = crParameter_; diff --git a/src/experiments/settings/GDE3_Settings.cpp b/src/experiments/settings/GDE3_Settings.cpp index 14764e2..54a2c4b 100644 --- a/src/experiments/settings/GDE3_Settings.cpp +++ b/src/experiments/settings/GDE3_Settings.cpp @@ -72,7 +72,7 @@ Algorithm * GDE3_Settings::configure() algorithm->setInputParameter("maxIterations",&maxIterations_); // Mutation and Crossover for Real codification - std::map parameters; + MapOfStringFunct parameters; double CR = CR_; double F = F_; diff --git a/src/experiments/settings/NSGAII_Settings.cpp b/src/experiments/settings/NSGAII_Settings.cpp index 46eecfa..b9c6c93 100644 --- a/src/experiments/settings/NSGAII_Settings.cpp +++ b/src/experiments/settings/NSGAII_Settings.cpp @@ -68,7 +68,7 @@ Algorithm * NSGAII_Settings::configure() algorithm->setInputParameter("maxEvaluations",&maxEvaluations_); // Mutation and Crossover for Real codification - std::map parameters; + MapOfStringFunct parameters; double crossoverProbability = crossoverProbability_; double crossoverDistributionIndex = crossoverDistributionIndex_ ; diff --git a/src/experiments/settings/PSO_Settings.cpp b/src/experiments/settings/PSO_Settings.cpp index 90df0bc..d6032e9 100644 --- a/src/experiments/settings/PSO_Settings.cpp +++ b/src/experiments/settings/PSO_Settings.cpp @@ -70,7 +70,7 @@ Algorithm * PSO_Settings::configure() algorithm->setInputParameter("swarmSize", &swarmSize_); algorithm->setInputParameter("maxIterations", &maxIterations_); - std::map parameters; + MapOfStringFunct parameters; // Mutation operator double mutationProbability = mutationProbability_; diff --git a/src/experiments/settings/SMPSO_Settings.cpp b/src/experiments/settings/SMPSO_Settings.cpp index 6c1173e..24b03bb 100644 --- a/src/experiments/settings/SMPSO_Settings.cpp +++ b/src/experiments/settings/SMPSO_Settings.cpp @@ -72,7 +72,7 @@ Algorithm * SMPSO_Settings::configure() algorithm->setInputParameter("maxIterations", &maxIterations_); algorithm->setInputParameter("archiveSize", &archiveSize_); - std::map parameters; + MapOfStringFunct parameters; double mutationProbability = mutationProbability_; double mutationDistributionIndex = mutationDistributionIndex_; diff --git a/src/experiments/settings/gGA_Settings.cpp b/src/experiments/settings/gGA_Settings.cpp index dbbcd44..30ccbde 100644 --- a/src/experiments/settings/gGA_Settings.cpp +++ b/src/experiments/settings/gGA_Settings.cpp @@ -68,7 +68,7 @@ Algorithm * gGA_Settings::configure() algorithm->setInputParameter("maxEvaluations",&maxEvaluations_); // Mutation and Crossover for Real codification - std::map parameters; + MapOfStringFunct parameters; double crossoverProbability = crossoverProbability_; double crossoverDistributionIndex = crossoverDistributionIndex_ ; diff --git a/src/experiments/settings/ssGA_Settings.cpp b/src/experiments/settings/ssGA_Settings.cpp index 89f17f7..6fafd93 100644 --- a/src/experiments/settings/ssGA_Settings.cpp +++ b/src/experiments/settings/ssGA_Settings.cpp @@ -68,7 +68,7 @@ Algorithm * ssGA_Settings::configure() algorithm->setInputParameter("maxEvaluations",&maxEvaluations_); // Mutation and Crossover for Real codification - std::map parameters; + MapOfStringFunct parameters; double crossoverProbability = crossoverProbability_; double crossoverDistributionIndex = crossoverDistributionIndex_ ; diff --git a/src/experiments/util/RBoxplot.cpp b/src/experiments/util/RBoxplot.cpp index 044b24f..ea52260 100644 --- a/src/experiments/util/RBoxplot.cpp +++ b/src/experiments/util/RBoxplot.cpp @@ -22,7 +22,7 @@ #include -void RBoxplot::generateScripts(int rows, int cols, std::vector problems, std::string prefix, +void RBoxplot::generateScripts(int rows, int cols, VectorOfString problems, std::string prefix, bool notch, ExperimentReport * experiment) { diff --git a/src/experiments/util/RBoxplot.h b/src/experiments/util/RBoxplot.h index 3fca0ee..0307ee6 100644 --- a/src/experiments/util/RBoxplot.h +++ b/src/experiments/util/RBoxplot.h @@ -22,10 +22,12 @@ #ifndef __RBOXPLOT__ #define __RBOXPLOT__ -#include +#include "JMetalHeader.h" #include #include +using namespace JMetal; + class ExperimentReport; /** @@ -35,7 +37,7 @@ class ExperimentReport; class RBoxplot { public: - static void generateScripts(int rows, int cols, std::vector problems, + static void generateScripts(int rows, int cols, VectorOfString problems, std::string prefix, bool notch, ExperimentReport * experiment); }; diff --git a/src/experiments/util/RWilcoxon.cpp b/src/experiments/util/RWilcoxon.cpp index 5a07661..4361dc3 100644 --- a/src/experiments/util/RWilcoxon.cpp +++ b/src/experiments/util/RWilcoxon.cpp @@ -23,7 +23,7 @@ #include -void RWilcoxon::generateScripts(std::vector problems, std::string prefix, ExperimentReport * experiment) +void RWilcoxon::generateScripts(VectorOfString problems, std::string prefix, ExperimentReport * experiment) { // STEP 1. Creating R output directory diff --git a/src/experiments/util/RWilcoxon.h b/src/experiments/util/RWilcoxon.h index 9996d18..d15f36d 100644 --- a/src/experiments/util/RWilcoxon.h +++ b/src/experiments/util/RWilcoxon.h @@ -22,9 +22,11 @@ #ifndef __RWILCOXON__ #define __RWILCOXON__ -#include +#include "JMetalHeader.h" #include +using namespace JMetal; + class ExperimentReport; /** @@ -35,7 +37,7 @@ class ExperimentReport; class RWilcoxon { public: - static void generateScripts(std::vector problems, std::string prefix, + static void generateScripts(VectorOfString problems, std::string prefix, ExperimentReport * experiment); }; // RWilcoxon diff --git a/src/experiments/util/RunExperiment.cpp b/src/experiments/util/RunExperiment.cpp index 5fc476d..ae14ae3 100644 --- a/src/experiments/util/RunExperiment.cpp +++ b/src/experiments/util/RunExperiment.cpp @@ -31,7 +31,7 @@ /** * Constructor */ -RunExperiment::RunExperiment(ExperimentExecution * experiment,std::map map, +RunExperiment::RunExperiment(ExperimentExecution * experiment,MapOfStringFunct map, int id, int numberOfThreads, int numberOfProblems, int threadIndex, mutex * mtx) { @@ -60,8 +60,8 @@ void RunExperiment::run() std::cout << experimentName << std::endl; experimentBaseDirectory_ = *(string*) map_["experimentDirectory"]; std::cout << experimentBaseDirectory_ << std::endl; - algorithmNameList_ = *(std::vector*) map_["algorithmNameList"]; - problemList_ = *(std::vector*) map_["problemList"]; + algorithmNameList_ = *(VectorOfString*) map_["algorithmNameList"]; + problemList_ = *(VectorOfString*) map_["problemList"]; independentRuns_ = *(int*) map_["independentRuns"]; std::cout << independentRuns_ << std::endl; outputParetoFrontFile_ = *(string*) map_["outputParetoFrontFile"]; diff --git a/src/experiments/util/RunExperiment.h b/src/experiments/util/RunExperiment.h index c371eab..343d486 100644 --- a/src/experiments/util/RunExperiment.h +++ b/src/experiments/util/RunExperiment.h @@ -47,11 +47,11 @@ class RunExperiment ExperimentExecution * experiment_; int id_; - std::map map_; + MapOfStringFunct map_; int numberOfThreads_; int numberOfProblems_; - RunExperiment(ExperimentExecution * experiment,std::map map, int id, + RunExperiment(ExperimentExecution * experiment,MapOfStringFunct map, int id, int numberOfThreads, int numberOfProblems, int threadIndex, mutex * mtx); void run(); @@ -63,9 +63,9 @@ class RunExperiment mutex * mutex_; std::string experimentName_; - std::vector algorithmNameList_; // List of the names of the algorithms to + VectorOfString algorithmNameList_; // List of the names of the algorithms to // be executed - std::vector problemList_; // List of problems to be solved + VectorOfString problemList_; // List of problems to be solved std::string experimentBaseDirectory_; // Directory to store the results std::string latexDirectory_; // Directory to store the latex files std::string rDirectory_; // Directory to store the generated R scripts diff --git a/src/experiments/util/Statistics.cpp b/src/experiments/util/Statistics.cpp index b3290d1..abc1369 100644 --- a/src/experiments/util/Statistics.cpp +++ b/src/experiments/util/Statistics.cpp @@ -31,7 +31,7 @@ * @param last index of last position to consider in the vector * @return The median */ -double Statistics::calculateMedian(std::vector vector_, int first, int last) +double Statistics::calculateMedian(VectorOfDouble vector_, int first, int last) { double median = 0.0; @@ -56,7 +56,7 @@ double Statistics::calculateMedian(std::vector vector_, int first, int l * @param vector * @return The IQR */ -double Statistics::calculateIQR(std::vector vector_) +double Statistics::calculateIQR(VectorOfDouble vector_) { double q3 = 0.0; double q1 = 0.0; diff --git a/src/experiments/util/Statistics.h b/src/experiments/util/Statistics.h index 159cfc8..1c90630 100644 --- a/src/experiments/util/Statistics.h +++ b/src/experiments/util/Statistics.h @@ -22,9 +22,9 @@ #ifndef __STATISTICS__ #define __STATISTICS__ -#include +#include "JMetalHeader.h" -using namespace std; +using namespace JMetal; /** * This class provides methods for computing some statistics @@ -34,8 +34,8 @@ class Statistics { public: - static double calculateMedian(vector vector_, int first, int last); - static double calculateIQR(vector vector_); + static double calculateMedian(VectorOfDouble vector_, int first, int last); + static double calculateIQR(VectorOfDouble vector_); }; diff --git a/src/main/OMOPSO_main.cpp b/src/main/OMOPSO_main.cpp index 646a753..579ef79 100644 --- a/src/main/OMOPSO_main.cpp +++ b/src/main/OMOPSO_main.cpp @@ -49,7 +49,7 @@ int main(int argc, char ** argv) QualityIndicator *indicators ; // Object to get quality indicators - std::map parameters; // Operator parameters + MapOfStringFunct parameters; // Operator parameters indicators = nullptr; diff --git a/src/metaheuristics/moead/MOEAD.cpp b/src/metaheuristics/moead/MOEAD.cpp index d8c7e09..9a3ef3c 100644 --- a/src/metaheuristics/moead/MOEAD.cpp +++ b/src/metaheuristics/moead/MOEAD.cpp @@ -102,7 +102,7 @@ SolutionSet * MOEAD::execute() { type = 2; // whole population } - std::vector p; + VectorOfInteger p; matingSelection(p, n, 2, type); // STEP 2.2. Reproduction @@ -290,7 +290,7 @@ void MOEAD::initIdealPoint() /** * matingSelection */ -void MOEAD::matingSelection(std::vector &list, int cid, int size, int type) +void MOEAD::matingSelection(VectorOfInteger &list, int cid, int size, int type) { // list : the set of the indexes of selected mating parents diff --git a/src/metaheuristics/moead/MOEAD.h b/src/metaheuristics/moead/MOEAD.h index 2239edd..e09826d 100644 --- a/src/metaheuristics/moead/MOEAD.h +++ b/src/metaheuristics/moead/MOEAD.h @@ -85,7 +85,7 @@ class MOEAD : public Algorithm void initNeighborhood(); void initPopulation(); void initIdealPoint(); - void matingSelection(std::vector &list, int cid, int size, int type); + void matingSelection(VectorOfInteger &list, int cid, int size, int type); void updateReference(Solution * individual); void updateProblem(Solution * indiv, int id, int type); double fitnessFunction(Solution * individual, double * lambda); diff --git a/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.cpp b/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.cpp index f733a5d..a6c4986 100644 --- a/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.cpp +++ b/src/metaheuristics/singleObjective/geneticAlgorithm/ssGA.cpp @@ -57,7 +57,7 @@ SolutionSet * ssGA::execute() Comparator * comparator = new ObjectiveComparator(0); // Single objective comparator Operator * findWorstSolution; - std::map parameters; // Operator parameters + MapOfStringFunct parameters; // Operator parameters parameters["comparator"] = comparator; findWorstSolution = new WorstSolutionSelection(parameters) ; diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp b/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp index a0859ae..15940f2 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/PSO.cpp @@ -49,7 +49,7 @@ PSO::PSO(Problem *problem) : Algorithm(problem) ChVel2_ = 1.0; comparator_ = new ObjectiveComparator(0); // Single objective comparator - std::map parameters; // Operator parameters + MapOfStringFunct parameters; // Operator parameters parameters["comparator"] = comparator_; findBestSolution_ = new BestSolutionSelection(parameters); diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp index 03b0031..f0dc6ff 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2007.cpp @@ -40,7 +40,7 @@ StandardPSO2007::StandardPSO2007(Problem * problem) : Algorithm(problem) C_ = 1.0/2.0 + log(2) ; //1.193; comparator_ = new ObjectiveComparator(0) ; // Single objective comparator - std::map parameters ; // Operator parameters + MapOfStringFunct parameters ; // Operator parameters parameters["comparator"] = comparator_; findBestSolution_ = new BestSolutionSelection(parameters) ; diff --git a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp index a398f0f..65f0f49 100644 --- a/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp +++ b/src/metaheuristics/singleObjective/particleSwarmOptimization/StandardPSO2011.cpp @@ -41,7 +41,7 @@ StandardPSO2011::StandardPSO2011(Problem * problem) : Algorithm(problem) ChVel_ = -0.5 ; comparator_ = new ObjectiveComparator(0) ; // Single objective comparator - std::map parameters ; // Operator parameters + MapOfStringFunct parameters ; // Operator parameters parameters["comparator"] = comparator_; findBestSolution_ = new BestSolutionSelection(parameters) ; diff --git a/src/metaheuristics/smpso/SMPSO.h b/src/metaheuristics/smpso/SMPSO.h index 87357ed..c9734c5 100644 --- a/src/metaheuristics/smpso/SMPSO.h +++ b/src/metaheuristics/smpso/SMPSO.h @@ -135,7 +135,7 @@ class SMPSO : public Algorithm public: SMPSO(Problem * problem); - //TODO: SMPSO(Problem * problem, std::vector variables, std::string trueParetoFront); + //TODO: SMPSO(Problem * problem, VectorOfDouble variables, std::string trueParetoFront); //TODO: SMPSO(Problem * problem, std::string trueParetoFront); SolutionSet * execute(); //TODO: SolutionSet * getLeader(); diff --git a/src/metaheuristics/smsemoa/FastSMSEMOA.h b/src/metaheuristics/smsemoa/FastSMSEMOA.h index 1ef5b54..cd14931 100644 --- a/src/metaheuristics/smsemoa/FastSMSEMOA.h +++ b/src/metaheuristics/smsemoa/FastSMSEMOA.h @@ -23,6 +23,7 @@ #ifndef _FAST_SMSEMOA_H_ #define _FAST_SMSEMOA_H_ +#include "JMetalHeader.h" #include #include #include @@ -32,17 +33,14 @@ #include #include +using namespace JMetal; + class FastSMSEMOA : public Algorithm { - -private: - - MetricsUtil * utils_; - Hypervolume * hv_; - - std::vector hvContributions(std::vector< std::vector > front); - - +protected: + MetricsUtil * utils_ = nullptr; + Hypervolume * hv_ = nullptr; + VectorOfDouble hvContributions(MatrixOfDouble front); public: FastSMSEMOA(Problem * problem); ~FastSMSEMOA(); diff --git a/src/metaheuristics/smsemoa/SMSEMOA.cpp b/src/metaheuristics/smsemoa/SMSEMOA.cpp index 061fd1a..486c4af 100644 --- a/src/metaheuristics/smsemoa/SMSEMOA.cpp +++ b/src/metaheuristics/smsemoa/SMSEMOA.cpp @@ -149,18 +149,18 @@ SolutionSet * SMSEMOA::execute() if (lastFront->size() > 1) { - std::vector > frontValues = lastFront->writeObjectivesToMatrix(); + std::vector frontValues = lastFront->writeObjectivesToMatrix(); int numberOfObjectives = problem_->getNumberOfObjectives(); // STEP 1. Obtain the maximum and minimum values of the Pareto front - std::vector maximumValues = utils_->getMaximumValues(unionSolution->writeObjectivesToMatrix(), numberOfObjectives); - std::vector minimumValues = utils_->getMinimumValues(unionSolution->writeObjectivesToMatrix(), numberOfObjectives); + VectorOfDouble maximumValues = utils_->getMaximumValues(unionSolution->writeObjectivesToMatrix(), numberOfObjectives); + VectorOfDouble minimumValues = utils_->getMinimumValues(unionSolution->writeObjectivesToMatrix(), numberOfObjectives); // STEP 2. Get the normalized front - std::vector > normalizedFront = utils_->getNormalizedFront(frontValues, maximumValues, minimumValues); + std::vector normalizedFront = utils_->getNormalizedFront(frontValues, maximumValues, minimumValues); // compute offsets for reference point in normalized space - std::vector offsets; + VectorOfDouble offsets; for (int i = 0; i < maximumValues.size(); i++) { offsets.push_back(offset / (maximumValues[i] - minimumValues[i])); @@ -168,7 +168,7 @@ SolutionSet * SMSEMOA::execute() // STEP 3. Inverse the pareto front. This is needed because the original //metric by Zitzler is for maximization problems - std::vector > invertedFront = utils_->invertedFront(normalizedFront); + std::vector invertedFront = utils_->invertedFront(normalizedFront); // shift away from origin, so that boundary points also get a contribution > 0 for (int i = 0; i < invertedFront.size(); i++) { @@ -179,7 +179,7 @@ SolutionSet * SMSEMOA::execute() } // calculate contributions and sort - std::vector contributions = hvContributions(invertedFront); + VectorOfDouble contributions = hvContributions(invertedFront); for (int i = 0; i < contributions.size(); i++) { // contribution values are used analogously to crowding distance @@ -238,22 +238,22 @@ SolutionSet * SMSEMOA::execute() return result; } -std::vector SMSEMOA::hvContributions(std::vector< std::vector > front) +VectorOfDouble SMSEMOA::hvContributions(MatrixOfDouble front) { int numberOfObjectives = problem_->getNumberOfObjectives(); - std::vector contributions; + VectorOfDouble contributions; double hv; double** frontSubset; - std::vector< std::vector > frontCopy; + MatrixOfDouble frontCopy; double** totalFront = snew double*[front.size()]; for (int i = 0; i < front.size(); i++) { - frontCopy.push_back(std::vector()); + frontCopy.push_back(VectorOfDouble()); totalFront[i] = snew double[front[i].size()]; for (int j = 0; j < front[i].size(); j++) { @@ -267,7 +267,7 @@ std::vector SMSEMOA::hvContributions(std::vector< std::vector > for (int i = 0; i < front.size(); i++) { - std::vector evaluatedPoint; + VectorOfDouble evaluatedPoint; for (int j = 0; j < frontCopy[i].size(); j++) { evaluatedPoint.push_back(frontCopy[i][j]); diff --git a/src/operators/crossover/Crossover.cpp b/src/operators/crossover/Crossover.cpp index 4a147e9..029ec93 100644 --- a/src/operators/crossover/Crossover.cpp +++ b/src/operators/crossover/Crossover.cpp @@ -22,7 +22,7 @@ #include -Crossover::Crossover(std::map parameters) +Crossover::Crossover(MapOfStringFunct parameters) : Operator(parameters) {} Crossover::~Crossover() { /* do nothing */ } diff --git a/src/operators/crossover/Crossover.h b/src/operators/crossover/Crossover.h index f734330..c37b056 100644 --- a/src/operators/crossover/Crossover.h +++ b/src/operators/crossover/Crossover.h @@ -33,7 +33,7 @@ class Crossover : public Operator { public: - Crossover(std::map parameters); + Crossover(MapOfStringFunct parameters); virtual ~Crossover() = 0; }; diff --git a/src/operators/crossover/DifferentialEvolutionCrossover.cpp b/src/operators/crossover/DifferentialEvolutionCrossover.cpp index f642cd1..87d08a5 100644 --- a/src/operators/crossover/DifferentialEvolutionCrossover.cpp +++ b/src/operators/crossover/DifferentialEvolutionCrossover.cpp @@ -65,7 +65,7 @@ const std::string DifferentialEvolutionCrossover::DEFAULT_DE_VARIANT = "rand/1/b /** * Constructor */ -DifferentialEvolutionCrossover::DifferentialEvolutionCrossover(std::map parameters) +DifferentialEvolutionCrossover::DifferentialEvolutionCrossover(MapOfStringFunct parameters) : Crossover(parameters) { diff --git a/src/operators/crossover/DifferentialEvolutionCrossover.h b/src/operators/crossover/DifferentialEvolutionCrossover.h index 9965c08..ab30614 100644 --- a/src/operators/crossover/DifferentialEvolutionCrossover.h +++ b/src/operators/crossover/DifferentialEvolutionCrossover.h @@ -48,7 +48,7 @@ class DifferentialEvolutionCrossover : public Crossover { public: - DifferentialEvolutionCrossover(std::map parameters); + DifferentialEvolutionCrossover(MapOfStringFunct parameters); void *execute(void *); protected: diff --git a/src/operators/crossover/HUXCrossover.cpp b/src/operators/crossover/HUXCrossover.cpp index d3f2141..0f143b4 100644 --- a/src/operators/crossover/HUXCrossover.cpp +++ b/src/operators/crossover/HUXCrossover.cpp @@ -27,7 +27,7 @@ * Create a new SBX crossover operator whit a default * index given by DEFAULT_INDEX_CROSSOVER */ -HUXCrossover::HUXCrossover(std::map parameters) +HUXCrossover::HUXCrossover(MapOfStringFunct parameters) : Crossover(parameters) { crossoverProbability_ = 0.0 ; diff --git a/src/operators/crossover/HUXCrossover.h b/src/operators/crossover/HUXCrossover.h index 4a0fdbf..a740ca0 100644 --- a/src/operators/crossover/HUXCrossover.h +++ b/src/operators/crossover/HUXCrossover.h @@ -33,7 +33,7 @@ class HUXCrossover : public Crossover { public: - HUXCrossover(std::map parameters); + HUXCrossover(MapOfStringFunct parameters); void *execute(void *); private: diff --git a/src/operators/crossover/SBXCrossover.cpp b/src/operators/crossover/SBXCrossover.cpp index 6e7d462..21d4031 100644 --- a/src/operators/crossover/SBXCrossover.cpp +++ b/src/operators/crossover/SBXCrossover.cpp @@ -38,7 +38,7 @@ const double SBXCrossover::ETA_C_DEFAULT_ = 20.0; * Create a new SBX crossover operator whit a default * index given by DEFAULT_INDEX_CROSSOVER */ -SBXCrossover::SBXCrossover(std::map parameters) +SBXCrossover::SBXCrossover(MapOfStringFunct parameters) : Crossover(parameters) { //TODO: crossoverProbability_ = nullptr; diff --git a/src/operators/crossover/SBXCrossover.h b/src/operators/crossover/SBXCrossover.h index 63718b3..9d4f3ec 100644 --- a/src/operators/crossover/SBXCrossover.h +++ b/src/operators/crossover/SBXCrossover.h @@ -36,7 +36,7 @@ class SBXCrossover : public Crossover { public: - SBXCrossover(std::map parameters); + SBXCrossover(MapOfStringFunct parameters); ~SBXCrossover(); void *execute(void *); diff --git a/src/operators/crossover/SinglePointCrossover.cpp b/src/operators/crossover/SinglePointCrossover.cpp index c0bb4c6..0dcd682 100644 --- a/src/operators/crossover/SinglePointCrossover.cpp +++ b/src/operators/crossover/SinglePointCrossover.cpp @@ -33,7 +33,7 @@ * Create a new SBX crossover operator whit a default * index given by DEFAULT_INDEX_CROSSOVER */ -SinglePointCrossover::SinglePointCrossover(std::map parameters) +SinglePointCrossover::SinglePointCrossover(MapOfStringFunct parameters) : Crossover(parameters) { crossoverProbability_ = 0.0 ; diff --git a/src/operators/mutation/BitFlipMutation.cpp b/src/operators/mutation/BitFlipMutation.cpp index 81b21a3..3e422ba 100644 --- a/src/operators/mutation/BitFlipMutation.cpp +++ b/src/operators/mutation/BitFlipMutation.cpp @@ -26,7 +26,7 @@ * Constructor * Creates a new instance of the polynomial mutation operator */ -BitFlipMutation::BitFlipMutation(std::map parameters) +BitFlipMutation::BitFlipMutation(MapOfStringFunct parameters) : Mutation(parameters) { mutationProbability_ = 0.0 ; diff --git a/src/operators/mutation/BitFlipMutation.h b/src/operators/mutation/BitFlipMutation.h index 6a99b5d..f32d234 100644 --- a/src/operators/mutation/BitFlipMutation.h +++ b/src/operators/mutation/BitFlipMutation.h @@ -36,7 +36,7 @@ class BitFlipMutation : public Mutation { public: - BitFlipMutation(std::map parameters); + BitFlipMutation(MapOfStringFunct parameters); ~BitFlipMutation(); void * execute(void *); diff --git a/src/operators/mutation/Mutation.cpp b/src/operators/mutation/Mutation.cpp index 8a90614..a44ebb7 100644 --- a/src/operators/mutation/Mutation.cpp +++ b/src/operators/mutation/Mutation.cpp @@ -22,7 +22,7 @@ #include -Mutation::Mutation(std::map parameters) +Mutation::Mutation(MapOfStringFunct parameters) : Operator (parameters) {} Mutation::~Mutation() { /* do nothing */ } diff --git a/src/operators/mutation/Mutation.h b/src/operators/mutation/Mutation.h index 40622a7..ca0a92c 100644 --- a/src/operators/mutation/Mutation.h +++ b/src/operators/mutation/Mutation.h @@ -33,7 +33,7 @@ class Mutation : public Operator { public: - Mutation(std::map parameters); + Mutation(MapOfStringFunct parameters); virtual ~Mutation() = 0; }; diff --git a/src/operators/mutation/NonUniformMutation.cpp b/src/operators/mutation/NonUniformMutation.cpp index 065f658..ac70eb8 100644 --- a/src/operators/mutation/NonUniformMutation.cpp +++ b/src/operators/mutation/NonUniformMutation.cpp @@ -34,7 +34,7 @@ const std::string NonUniformMutation::VALID_TYPES[] = {"Real", "ArrayReal"}; * Constructor * Creates a new instance of the non uniform mutation */ -NonUniformMutation::NonUniformMutation(std::map parameters) +NonUniformMutation::NonUniformMutation(MapOfStringFunct parameters) : Mutation(parameters) { if (parameters["probability"] != nullptr) diff --git a/src/operators/mutation/NonUniformMutation.h b/src/operators/mutation/NonUniformMutation.h index c8e681e..e2257b3 100644 --- a/src/operators/mutation/NonUniformMutation.h +++ b/src/operators/mutation/NonUniformMutation.h @@ -78,7 +78,7 @@ class NonUniformMutation : public Mutation * Constructor. * Creates a new instance of the non uniform mutation */ - NonUniformMutation(std::map parameters); + NonUniformMutation(MapOfStringFunct parameters); /** * Executes the operation diff --git a/src/operators/mutation/PolynomialMutation.cpp b/src/operators/mutation/PolynomialMutation.cpp index b2172bc..d34775a 100644 --- a/src/operators/mutation/PolynomialMutation.cpp +++ b/src/operators/mutation/PolynomialMutation.cpp @@ -32,7 +32,7 @@ const double PolynomialMutation::eta_m_ = ETA_M_DEFAULT_; * Constructor * Creates a new instance of the polynomial mutation operator */ -PolynomialMutation::PolynomialMutation(std::map parameters) +PolynomialMutation::PolynomialMutation(MapOfStringFunct parameters) : Mutation(parameters) { // TODO: mutationProbability_ = nullptr; diff --git a/src/operators/mutation/PolynomialMutation.h b/src/operators/mutation/PolynomialMutation.h index f2d457d..3b0792d 100644 --- a/src/operators/mutation/PolynomialMutation.h +++ b/src/operators/mutation/PolynomialMutation.h @@ -42,7 +42,7 @@ class PolynomialMutation : public Mutation static const double ETA_M_DEFAULT_; static const double eta_m_; - PolynomialMutation(std::map parameters); + PolynomialMutation(MapOfStringFunct parameters); ~PolynomialMutation(); void * execute(void *); diff --git a/src/operators/mutation/UniformMutation.cpp b/src/operators/mutation/UniformMutation.cpp index 4f6ac34..e497827 100644 --- a/src/operators/mutation/UniformMutation.cpp +++ b/src/operators/mutation/UniformMutation.cpp @@ -33,7 +33,7 @@ const std::string UniformMutation::VALID_TYPES[] = {"Real", "ArrayReal"}; * Constructor * Creates a new uniform mutation operator instance */ -UniformMutation::UniformMutation(std::map parameters) +UniformMutation::UniformMutation(MapOfStringFunct parameters) : Mutation(parameters) { if (parameters["probability"] != nullptr) diff --git a/src/operators/selection/BestSolutionSelection.cpp b/src/operators/selection/BestSolutionSelection.cpp index f11a9d2..593c069 100644 --- a/src/operators/selection/BestSolutionSelection.cpp +++ b/src/operators/selection/BestSolutionSelection.cpp @@ -31,7 +31,7 @@ /** * Constructor */ -BestSolutionSelection::BestSolutionSelection(std::map parameters) +BestSolutionSelection::BestSolutionSelection(MapOfStringFunct parameters) : Selection(parameters) { comparator_ = nullptr; diff --git a/src/operators/selection/BestSolutionSelection.h b/src/operators/selection/BestSolutionSelection.h index b777ca4..a8275a0 100644 --- a/src/operators/selection/BestSolutionSelection.h +++ b/src/operators/selection/BestSolutionSelection.h @@ -36,7 +36,7 @@ class BestSolutionSelection : public Selection Comparator * comparator_; public: - BestSolutionSelection(std::map parameters); + BestSolutionSelection(MapOfStringFunct parameters); void *execute(void *); }; diff --git a/src/operators/selection/BinaryTournament.cpp b/src/operators/selection/BinaryTournament.cpp index 20560bd..1342ab2 100644 --- a/src/operators/selection/BinaryTournament.cpp +++ b/src/operators/selection/BinaryTournament.cpp @@ -32,7 +32,7 @@ * Constructor * Creates a new Binary tournament operator using a BinaryTournamentComparator */ -BinaryTournament::BinaryTournament(std::map parameters) +BinaryTournament::BinaryTournament(MapOfStringFunct parameters) : Selection(parameters) { if (parameters["comparator"] != nullptr) diff --git a/src/operators/selection/BinaryTournament.h b/src/operators/selection/BinaryTournament.h index 52e6abe..74a0a6e 100644 --- a/src/operators/selection/BinaryTournament.h +++ b/src/operators/selection/BinaryTournament.h @@ -37,7 +37,7 @@ class BinaryTournament : public Selection Comparator * comparator_; public: - BinaryTournament(std::map parameters); + BinaryTournament(MapOfStringFunct parameters); ~BinaryTournament(); void *execute(void *); diff --git a/src/operators/selection/BinaryTournament2.cpp b/src/operators/selection/BinaryTournament2.cpp index bb5c51d..cf7c27b 100644 --- a/src/operators/selection/BinaryTournament2.cpp +++ b/src/operators/selection/BinaryTournament2.cpp @@ -35,7 +35,7 @@ * Creates a new instance of the Binary tournament operator (Deb's * NSGA-II implementation version) */ -BinaryTournament2::BinaryTournament2(std::map parameters) +BinaryTournament2::BinaryTournament2(MapOfStringFunct parameters) : Selection(parameters) { index_ = 0; diff --git a/src/operators/selection/BinaryTournament2.h b/src/operators/selection/BinaryTournament2.h index 3badd21..29a42b0 100644 --- a/src/operators/selection/BinaryTournament2.h +++ b/src/operators/selection/BinaryTournament2.h @@ -42,7 +42,7 @@ class BinaryTournament2 : public Selection int index_; public: - BinaryTournament2(std::map parameters); + BinaryTournament2(MapOfStringFunct parameters); ~BinaryTournament2(); void *execute(void *); diff --git a/src/operators/selection/DifferentialEvolutionSelection.cpp b/src/operators/selection/DifferentialEvolutionSelection.cpp index d98d32a..31227ce 100644 --- a/src/operators/selection/DifferentialEvolutionSelection.cpp +++ b/src/operators/selection/DifferentialEvolutionSelection.cpp @@ -32,7 +32,7 @@ /** * Constructor */ -DifferentialEvolutionSelection::DifferentialEvolutionSelection(std::map parameters) +DifferentialEvolutionSelection::DifferentialEvolutionSelection(MapOfStringFunct parameters) : Selection(parameters) {} diff --git a/src/operators/selection/DifferentialEvolutionSelection.h b/src/operators/selection/DifferentialEvolutionSelection.h index 01f95c0..92db92c 100644 --- a/src/operators/selection/DifferentialEvolutionSelection.h +++ b/src/operators/selection/DifferentialEvolutionSelection.h @@ -34,7 +34,7 @@ class DifferentialEvolutionSelection : public Selection { public: - DifferentialEvolutionSelection(std::map parameters); + DifferentialEvolutionSelection(MapOfStringFunct parameters); void *execute(void *); }; diff --git a/src/operators/selection/RandomSelection.cpp b/src/operators/selection/RandomSelection.cpp index 2e36834..32fa95c 100755 --- a/src/operators/selection/RandomSelection.cpp +++ b/src/operators/selection/RandomSelection.cpp @@ -32,7 +32,7 @@ * Constructor * Creates a new RandomSelection operator using a BinaryTournamentComparator */ -RandomSelection::RandomSelection(std::map parameters): Selection(parameters) +RandomSelection::RandomSelection(MapOfStringFunct parameters): Selection(parameters) { } // RandomSelection diff --git a/src/operators/selection/RandomSelection.h b/src/operators/selection/RandomSelection.h index 9bc0eb8..e7e2fb1 100755 --- a/src/operators/selection/RandomSelection.h +++ b/src/operators/selection/RandomSelection.h @@ -37,7 +37,7 @@ class RandomSelection : public Selection Comparator * comparator_; public: - RandomSelection(std::map parameters); + RandomSelection(MapOfStringFunct parameters); ~RandomSelection(); void *execute(void *); diff --git a/src/operators/selection/Selection.cpp b/src/operators/selection/Selection.cpp index cd0bdbe..5a41468 100644 --- a/src/operators/selection/Selection.cpp +++ b/src/operators/selection/Selection.cpp @@ -22,7 +22,7 @@ #include -Selection::Selection(std::map parameters) +Selection::Selection(MapOfStringFunct parameters) : Operator(parameters) {} Selection::~Selection() { /* do nothing */ } diff --git a/src/operators/selection/Selection.h b/src/operators/selection/Selection.h index 79567da..6cf6ee1 100644 --- a/src/operators/selection/Selection.h +++ b/src/operators/selection/Selection.h @@ -33,7 +33,7 @@ class Selection : public Operator { public: - Selection (std::map parameters); + Selection (MapOfStringFunct parameters); virtual ~Selection() = 0; }; diff --git a/src/operators/selection/WorstSolutionSelection.cpp b/src/operators/selection/WorstSolutionSelection.cpp index 95a68c1..4032c33 100644 --- a/src/operators/selection/WorstSolutionSelection.cpp +++ b/src/operators/selection/WorstSolutionSelection.cpp @@ -31,7 +31,7 @@ /** * Constructor */ -WorstSolutionSelection::WorstSolutionSelection(std::map parameters) +WorstSolutionSelection::WorstSolutionSelection(MapOfStringFunct parameters) : Selection(parameters) { comparator_ = nullptr; diff --git a/src/problems/LZ09/LZ09.cpp b/src/problems/LZ09/LZ09.cpp index cbe0559..689ba32 100644 --- a/src/problems/LZ09/LZ09.cpp +++ b/src/problems/LZ09/LZ09.cpp @@ -35,67 +35,67 @@ LZ09::LZ09(int nvar, int nobj, int ptype, int dtype, int ltype) /** * Alpha function */ -void LZ09::alphaFunction(double *alpha, std::vector * x, int dim, int type) +void LZ09::alphaFunction(double *alpha, VectorOfDouble * x, int dim, int type) { if (dim == 2) { if (type == 21) { - alpha[0] = x->at(0); - alpha[1] = 1 - sqrt(x->at(0)); + alpha[0] = (*x)[0]; + alpha[1] = 1 - sqrt((*x)[0]); } if (type == 22) { - alpha[0] = x->at(0); - alpha[1] = 1 - x->at(0) * x->at(0); + alpha[0] = (*x)[0]; + alpha[1] = 1 - (*x)[0] * (*x)[0]; } if (type == 23) { - alpha[0] = x->at(0); + alpha[0] = (*x)[0]; alpha[1] = 1 - sqrt(alpha[0]) - alpha[0] * sin(10 * alpha[0] * alpha[0] * 3.141596); } if (type == 24) { - alpha[0] = x->at(0); - alpha[1] = 1 - x->at(0) - 0.05 * sin(4 * 3.141596 * x->at(0)); + alpha[0] = (*x)[0]; + alpha[1] = 1 - (*x)[0] - 0.05 * sin(4 * 3.141596 * (*x)[0]); } } else { if (type == 31) { - alpha[0] = cos(x->at(0) * 3.141596 / 2) * cos(x->at(1) * 3.141596 / 2); - alpha[1] = cos(x->at(0) * 3.141596 / 2) * sin(x->at(1) * 3.141596 / 2); - alpha[2] = sin(x->at(0) * 3.141596 / 2); + alpha[0] = cos((*x)[0] * 3.141596 / 2) * cos(x->at(1) * 3.141596 / 2); + alpha[1] = cos((*x)[0] * 3.141596 / 2) * sin(x->at(1) * 3.141596 / 2); + alpha[2] = sin((*x)[0] * 3.141596 / 2); } if (type == 32) { - alpha[0] = 1 - cos(x->at(0) * 3.141596 / 2) + alpha[0] = 1 - cos((*x)[0] * 3.141596 / 2) * cos(x->at(1) * 3.141596 / 2); - alpha[1] = 1 - cos(x->at(0) * 3.141596 / 2) + alpha[1] = 1 - cos((*x)[0] * 3.141596 / 2) * sin(x->at(1) * 3.141596 / 2); - alpha[2] = 1 - sin(x->at(0) * 3.141596 / 2); + alpha[2] = 1 - sin((*x)[0] * 3.141596 / 2); } if (type == 33) { - alpha[0] = x->at(0); + alpha[0] = (*x)[0]; alpha[1] = x->at(1); alpha[2] = 3 - - (sin(3 * 3.141596 * x->at(0)) + sin(3 * 3.141596 * x->at(1))) - 2 - * (x->at(0) + x->at(1)); + - (sin(3 * 3.141596 * (*x)[0]) + sin(3 * 3.141596 * x->at(1))) - 2 + * ((*x)[0] + x->at(1)); } if (type == 34) { - alpha[0] = x->at(0) * x->at(1); - alpha[1] = x->at(0) * (1 - x->at(1)); - alpha[2] = (1 - x->at(0)); + alpha[0] = (*x)[0] * x->at(1); + alpha[1] = (*x)[0] * (1 - x->at(1)); + alpha[2] = (1 - (*x)[0]); } } } @@ -105,7 +105,7 @@ void LZ09::alphaFunction(double *alpha, std::vector * x, int dim, int ty */ -double LZ09::betaFunction(std::vector * x, int type) +double LZ09::betaFunction(VectorOfDouble * x, int type) { double beta; @@ -263,7 +263,7 @@ double LZ09::psfunc3(double x, double t1, double t2, int dim, int type) return beta; } -void LZ09::objective(std::vector *x_var, std::vector *y_obj) +void LZ09::objective(VectorOfDouble *x_var, std::vector *y_obj) { // 2-objective case if(nobj_==2) diff --git a/src/problems/LZ09/LZ09.h b/src/problems/LZ09/LZ09.h index 0d4678c..ca23ba6 100644 --- a/src/problems/LZ09/LZ09.h +++ b/src/problems/LZ09/LZ09.h @@ -21,11 +21,11 @@ #ifndef __LZ09_H__ #define __LZ09_H__ +#include "JMetalHeader.h" #include #include -#include - +using namespace JMetal; class LZ09 { @@ -38,11 +38,11 @@ class LZ09 public: LZ09 (int nvar, int nobj, int ptype, int dtype, int ltype) ; - void alphaFunction(double *alpha, std::vector *x, int dim, int type) ; - double betaFunction(std::vector * x, int type) ; + void alphaFunction(double *alpha, VectorOfDouble *x, int dim, int type) ; + double betaFunction(VectorOfDouble * x, int type) ; double psfunc2(double x, double t1, int dim, int type, int css) ; double psfunc3(double x, double t1, double t2, int dim, int type) ; - void objective(std::vector * x_var, std::vector * y_obj) ; + void objective(VectorOfDouble * x_var, std::vector * y_obj) ; }; diff --git a/src/problems/LZ09/LZ09_F1.cpp b/src/problems/LZ09/LZ09_F1.cpp index dea119e..6e6f94c 100644 --- a/src/problems/LZ09/LZ09_F1.cpp +++ b/src/problems/LZ09/LZ09_F1.cpp @@ -91,8 +91,8 @@ void LZ09_F1::evaluate(Solution * solution) { XReal * vars = snew XReal(solution); - std::vector * x = snew std::vector(numberOfVariables_) ; - std::vector * y = snew std::vector(numberOfObjectives_); + VectorOfDouble * x = snew VectorOfDouble(numberOfVariables_) ; + VectorOfDouble * y = snew VectorOfDouble(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F2.cpp b/src/problems/LZ09/LZ09_F2.cpp index 14d2ad8..9c6e7ea 100644 --- a/src/problems/LZ09/LZ09_F2.cpp +++ b/src/problems/LZ09/LZ09_F2.cpp @@ -93,8 +93,8 @@ void LZ09_F2::evaluate(Solution * solution) { XReal * vars = snew XReal(solution); - std::vector * x = snew std::vector(numberOfVariables_) ; - std::vector * y = snew std::vector(numberOfObjectives_); + VectorOfDouble * x = snew VectorOfDouble(numberOfVariables_) ; + VectorOfDouble * y = snew VectorOfDouble(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F3.cpp b/src/problems/LZ09/LZ09_F3.cpp index af5b99a..e194dcd 100644 --- a/src/problems/LZ09/LZ09_F3.cpp +++ b/src/problems/LZ09/LZ09_F3.cpp @@ -93,8 +93,8 @@ void LZ09_F3::evaluate(Solution * solution) { XReal * vars = snew XReal(solution); - std::vector * x = snew std::vector(numberOfVariables_) ; - std::vector * y = snew std::vector(numberOfObjectives_); + VectorOfDouble * x = snew VectorOfDouble(numberOfVariables_) ; + VectorOfDouble * y = snew VectorOfDouble(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F4.cpp b/src/problems/LZ09/LZ09_F4.cpp index 006ba38..ae71f97 100644 --- a/src/problems/LZ09/LZ09_F4.cpp +++ b/src/problems/LZ09/LZ09_F4.cpp @@ -93,8 +93,8 @@ void LZ09_F4::evaluate(Solution * solution) { XReal * vars = snew XReal(solution); - std::vector * x = snew std::vector(numberOfVariables_) ; - std::vector * y = snew std::vector(numberOfObjectives_); + VectorOfDouble * x = snew VectorOfDouble(numberOfVariables_) ; + VectorOfDouble * y = snew VectorOfDouble(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F5.cpp b/src/problems/LZ09/LZ09_F5.cpp index 3389106..59ae8f3 100644 --- a/src/problems/LZ09/LZ09_F5.cpp +++ b/src/problems/LZ09/LZ09_F5.cpp @@ -93,8 +93,8 @@ void LZ09_F5::evaluate(Solution * solution) { XReal * vars = snew XReal(solution); - std::vector * x = snew std::vector(numberOfVariables_) ; - std::vector * y = snew std::vector(numberOfObjectives_); + VectorOfDouble * x = snew VectorOfDouble(numberOfVariables_) ; + VectorOfDouble * y = snew VectorOfDouble(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F6.cpp b/src/problems/LZ09/LZ09_F6.cpp index 0989e7a..bb75ef1 100644 --- a/src/problems/LZ09/LZ09_F6.cpp +++ b/src/problems/LZ09/LZ09_F6.cpp @@ -93,8 +93,8 @@ void LZ09_F6::evaluate(Solution * solution) { XReal * vars = snew XReal(solution); - std::vector * x = snew std::vector(numberOfVariables_) ; - std::vector * y = snew std::vector(numberOfObjectives_); + VectorOfDouble * x = snew VectorOfDouble(numberOfVariables_) ; + VectorOfDouble * y = snew VectorOfDouble(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F7.cpp b/src/problems/LZ09/LZ09_F7.cpp index 41a7409..c32fb2e 100644 --- a/src/problems/LZ09/LZ09_F7.cpp +++ b/src/problems/LZ09/LZ09_F7.cpp @@ -93,8 +93,8 @@ void LZ09_F7::evaluate(Solution * solution) { XReal * vars = snew XReal(solution); - std::vector * x = snew std::vector(numberOfVariables_) ; - std::vector * y = snew std::vector(numberOfObjectives_); + VectorOfDouble * x = snew VectorOfDouble(numberOfVariables_) ; + VectorOfDouble * y = snew VectorOfDouble(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F8.cpp b/src/problems/LZ09/LZ09_F8.cpp index c953ae3..f1e5372 100644 --- a/src/problems/LZ09/LZ09_F8.cpp +++ b/src/problems/LZ09/LZ09_F8.cpp @@ -93,8 +93,8 @@ void LZ09_F8::evaluate(Solution * solution) { XReal * vars = snew XReal(solution); - std::vector * x = snew std::vector(numberOfVariables_) ; - std::vector * y = snew std::vector(numberOfObjectives_); + VectorOfDouble * x = snew VectorOfDouble(numberOfVariables_) ; + VectorOfDouble * y = snew VectorOfDouble(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/problems/LZ09/LZ09_F9.cpp b/src/problems/LZ09/LZ09_F9.cpp index 0abc38e..f3c67cf 100644 --- a/src/problems/LZ09/LZ09_F9.cpp +++ b/src/problems/LZ09/LZ09_F9.cpp @@ -93,8 +93,8 @@ void LZ09_F9::evaluate(Solution * solution) { XReal * vars = snew XReal(solution); - std::vector * x = snew std::vector(numberOfVariables_) ; - std::vector * y = snew std::vector(numberOfObjectives_); + VectorOfDouble * x = snew VectorOfDouble(numberOfVariables_) ; + VectorOfDouble * y = snew VectorOfDouble(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { diff --git a/src/qualityIndicator/Epsilon.cpp b/src/qualityIndicator/Epsilon.cpp index 5e70952..b24411b 100644 --- a/src/qualityIndicator/Epsilon.cpp +++ b/src/qualityIndicator/Epsilon.cpp @@ -47,7 +47,7 @@ Epsilon::~Epsilon() * @param a. Solution front * @return the value of the epsilon indicator */ -double Epsilon::epsilon(std::vector > b, std::vector > a, +double Epsilon::epsilon(MatrixOfDouble b, MatrixOfDouble a, int dim) { diff --git a/src/qualityIndicator/Epsilon.h b/src/qualityIndicator/Epsilon.h index 1d89f39..6e0bef9 100644 --- a/src/qualityIndicator/Epsilon.h +++ b/src/qualityIndicator/Epsilon.h @@ -24,6 +24,7 @@ #include #include + /** * This class implements the unary epsilon additive indicator as proposed in * E. Zitzler, E. Thiele, L. Laummanns, M., Fonseca, C., and Grunert da Fonseca. @@ -34,6 +35,8 @@ * $java jmetal.qualityIndicator.Epsilon */ +using namespace JMetal; + class Epsilon { @@ -54,7 +57,7 @@ class Epsilon Epsilon(); ~Epsilon(); - double epsilon(std::vector > b, std::vector< std::vector > a, int dim); + double epsilon(MatrixOfDouble b, MatrixOfDouble a, int dim); }; // Epsilon diff --git a/src/qualityIndicator/Fitness.cpp b/src/qualityIndicator/Fitness.cpp index a914d88..6655879 100644 --- a/src/qualityIndicator/Fitness.cpp +++ b/src/qualityIndicator/Fitness.cpp @@ -47,7 +47,7 @@ Fitness::~Fitness() * @param a. Solution front * @return the value of the epsilon indicator */ -void Fitness::fitness(std::vector > a, std::string file) +void Fitness::fitness(std::vector a, std::string file) { std::fstream out(file.c_str(), std::ios::out | std::ios::app); for (int i=0; i > a, std::string file); + void fitness(std::vector a, std::string file); }; // Fitness diff --git a/src/qualityIndicator/GenerationalDistance.cpp b/src/qualityIndicator/GenerationalDistance.cpp index 3b216e0..9c33b4d 100644 --- a/src/qualityIndicator/GenerationalDistance.cpp +++ b/src/qualityIndicator/GenerationalDistance.cpp @@ -51,29 +51,29 @@ GenerationalDistance::~GenerationalDistance() * @param front The front * @param trueParetoFront The true pareto front */ -double GenerationalDistance::generationalDistance(std::vector< std::vector > front, - std::vector< std::vector > trueParetoFront, int numberOfObjectives) +double GenerationalDistance::generationalDistance(MatrixOfDouble front, + MatrixOfDouble trueParetoFront, int numberOfObjectives) { /** * Stores the maximum values of true pareto front. */ - std::vector maximumValue; + VectorOfDouble maximumValue; /** * Stores the minimum values of the true pareto front. */ - std::vector minimumValue; + VectorOfDouble minimumValue; /** * Stores the normalized front. */ - std::vector< std::vector > normalizedFront; + MatrixOfDouble normalizedFront; /** * Stores the normalized true Pareto front. */ - std::vector< std::vector > normalizedParetoFront ; + MatrixOfDouble normalizedParetoFront ; // STEP 1. Obtain the maximum and minimum values of the Pareto front maximumValue = utils_->getMaximumValues(trueParetoFront, numberOfObjectives); diff --git a/src/qualityIndicator/GenerationalDistance.h b/src/qualityIndicator/GenerationalDistance.h index 11f1979..41de6ab 100644 --- a/src/qualityIndicator/GenerationalDistance.h +++ b/src/qualityIndicator/GenerationalDistance.h @@ -48,8 +48,8 @@ class GenerationalDistance GenerationalDistance(); ~GenerationalDistance(); - double generationalDistance(std::vector< std::vector > front, - std::vector< std::vector > trueParetoFront, int numberOfObjectives); + double generationalDistance(MatrixOfDouble front, + MatrixOfDouble trueParetoFront, int numberOfObjectives); }; diff --git a/src/qualityIndicator/Hypervolume.cpp b/src/qualityIndicator/Hypervolume.cpp index 2adb59a..a0b186a 100644 --- a/src/qualityIndicator/Hypervolume.cpp +++ b/src/qualityIndicator/Hypervolume.cpp @@ -276,29 +276,29 @@ double** Hypervolume::mergeFronts(double** front1, int sizeFront1, * @param paretoTrueFront The true pareto front * @param numberOfObjectives Number of objectives of the pareto front */ -double Hypervolume::hypervolume(std::vector< std::vector > paretoFront, - std::vector< std::vector > paretoTrueFront, int numberOfObjectives) +double Hypervolume::hypervolume(MatrixOfDouble paretoFront, + MatrixOfDouble paretoTrueFront, int numberOfObjectives) { /** * Stores the maximum values of true pareto front. */ - std::vector maximumValues; + VectorOfDouble maximumValues; /** * Stores the minimum values of the true pareto front. */ - std::vector minimumValues; + VectorOfDouble minimumValues; /** * Stores the normalized front. */ - std::vector< std::vector > normalizedFront; + MatrixOfDouble normalizedFront; /** * Stores the inverted front. Needed for minimization problems */ - std::vector< std::vector > invertedFront; + MatrixOfDouble invertedFront; // STEP 1. Obtain the maximum and minimum values of the Pareto front maximumValues = utils_->getMaximumValues(paretoTrueFront, numberOfObjectives); diff --git a/src/qualityIndicator/Hypervolume.h b/src/qualityIndicator/Hypervolume.h index 21ec725..3880b8e 100644 --- a/src/qualityIndicator/Hypervolume.h +++ b/src/qualityIndicator/Hypervolume.h @@ -60,8 +60,8 @@ class Hypervolume ~Hypervolume(); double calculateHypervolume(double** front, int noPoints, int noObjectives); - double hypervolume(std::vector< std::vector > paretoFront, - std::vector< std::vector > paretoTrueFront, int numberOfObjectives); + double hypervolume(MatrixOfDouble paretoFront, + MatrixOfDouble paretoTrueFront, int numberOfObjectives); }; diff --git a/src/qualityIndicator/InvertedGenerationalDistance.cpp b/src/qualityIndicator/InvertedGenerationalDistance.cpp index 3a09fa2..f6db325 100644 --- a/src/qualityIndicator/InvertedGenerationalDistance.cpp +++ b/src/qualityIndicator/InvertedGenerationalDistance.cpp @@ -52,29 +52,29 @@ InvertedGenerationalDistance::~InvertedGenerationalDistance() * @param trueParetoFront The true pareto front */ double InvertedGenerationalDistance::invertedGenerationalDistance( - std::vector< std::vector > front, std::vector< std::vector > trueParetoFront, + MatrixOfDouble front, MatrixOfDouble trueParetoFront, int numberOfObjectives) { /** * Stores the maximum values of true pareto front. */ - std::vector maximumValue; + VectorOfDouble maximumValue; /** * Stores the minimum values of the true pareto front. */ - std::vector minimumValue; + VectorOfDouble minimumValue; /** * Stores the normalized front. */ - std::vector< std::vector > normalizedFront; + MatrixOfDouble normalizedFront; /** * Stores the normalized true Pareto front. */ - std::vector< std::vector > normalizedParetoFront ; + MatrixOfDouble normalizedParetoFront ; // STEP 1. Obtain the maximum and minimum values of the Pareto front maximumValue = utils_->getMaximumValues(trueParetoFront, numberOfObjectives); diff --git a/src/qualityIndicator/InvertedGenerationalDistance.h b/src/qualityIndicator/InvertedGenerationalDistance.h index 3d372bd..7c0f4b7 100644 --- a/src/qualityIndicator/InvertedGenerationalDistance.h +++ b/src/qualityIndicator/InvertedGenerationalDistance.h @@ -48,8 +48,8 @@ class InvertedGenerationalDistance InvertedGenerationalDistance(); ~InvertedGenerationalDistance(); - double invertedGenerationalDistance(std::vector< std::vector > front, - std::vector< std::vector > trueParetoFront, int numberOfObjectives); + double invertedGenerationalDistance(MatrixOfDouble front, + MatrixOfDouble trueParetoFront, int numberOfObjectives); }; diff --git a/src/qualityIndicator/Spread.cpp b/src/qualityIndicator/Spread.cpp index 70c4ca3..a2dab1b 100644 --- a/src/qualityIndicator/Spread.cpp +++ b/src/qualityIndicator/Spread.cpp @@ -41,7 +41,7 @@ Spread::~Spread() } // ~Spread -bool Spread::compareFront(std::vector pointOne, std::vector pointTwo) +bool Spread::compareFront(VectorOfDouble pointOne, VectorOfDouble pointTwo) { int value; @@ -68,29 +68,29 @@ bool Spread::compareFront(std::vector pointOne, std::vector poin * @param trueParetoFront The true pareto front. * @param numberOfObjectives The number of objectives. */ -double Spread::spread(std::vector > front, - std::vector > trueParetoFront, int numberOfObjectives) +double Spread::spread(std::vector front, + std::vector trueParetoFront, int numberOfObjectives) { /** * Stores the maximum values of true pareto front. */ - std::vector maximumValue ; + VectorOfDouble maximumValue ; /** * Stores the minimum values of the true pareto front. */ - std::vector minimumValue ; + VectorOfDouble minimumValue ; /** * Stores the normalized front. */ - std::vector > normalizedFront ; + std::vector normalizedFront ; /** * Stores the normalized true Pareto front. */ - std::vector > normalizedParetoFront ; + std::vector normalizedParetoFront ; // STEP 1. Obtain the maximum and minimum values of the Pareto front maximumValue = utils_->getMaximumValues(trueParetoFront, numberOfObjectives); diff --git a/src/qualityIndicator/main/Epsilon_main.cpp b/src/qualityIndicator/main/Epsilon_main.cpp index b395ab2..6a0dc50 100644 --- a/src/qualityIndicator/main/Epsilon_main.cpp +++ b/src/qualityIndicator/main/Epsilon_main.cpp @@ -43,9 +43,9 @@ int main(int argc, char ** argv) //Create a new instance of the metric Epsilon * qualityIndicator = snew Epsilon(); //Read the front from the files - std::vector< std::vector > solutionFront = + MatrixOfDouble solutionFront = qualityIndicator->utils_->readFront(argv[1]); - std::vector< std::vector > trueFront = + MatrixOfDouble trueFront = qualityIndicator->utils_->readFront(argv[2]); //Obtain delta value diff --git a/src/qualityIndicator/main/GenerationalDistance_main.cpp b/src/qualityIndicator/main/GenerationalDistance_main.cpp index 4599b67..064f273 100644 --- a/src/qualityIndicator/main/GenerationalDistance_main.cpp +++ b/src/qualityIndicator/main/GenerationalDistance_main.cpp @@ -43,9 +43,9 @@ int main(int argc, char ** argv) //Create a new instance of the metric GenerationalDistance * qualityIndicator = snew GenerationalDistance(); //Read the front from the files - std::vector< std::vector > solutionFront = + MatrixOfDouble solutionFront = qualityIndicator->utils_->readFront(argv[1]); - std::vector< std::vector > trueFront = + MatrixOfDouble trueFront = qualityIndicator->utils_->readFront(argv[2]); //Obtain delta value diff --git a/src/qualityIndicator/main/Hypervolume_main.cpp b/src/qualityIndicator/main/Hypervolume_main.cpp index 180d55f..33240c8 100644 --- a/src/qualityIndicator/main/Hypervolume_main.cpp +++ b/src/qualityIndicator/main/Hypervolume_main.cpp @@ -43,9 +43,9 @@ int main(int argc, char ** argv) //Create a new instance of the metric Hypervolume * qualityIndicator = snew Hypervolume(); //Read the front from the files - std::vector< std::vector > solutionFront = + MatrixOfDouble solutionFront = qualityIndicator->utils_->readFront(argv[1]); - std::vector< std::vector > trueFront = + MatrixOfDouble trueFront = qualityIndicator->utils_->readFront(argv[2]); //Obtain delta value diff --git a/src/qualityIndicator/main/InvertedGenerationalDistance_main.cpp b/src/qualityIndicator/main/InvertedGenerationalDistance_main.cpp index 7f861d3..c6c4f87 100644 --- a/src/qualityIndicator/main/InvertedGenerationalDistance_main.cpp +++ b/src/qualityIndicator/main/InvertedGenerationalDistance_main.cpp @@ -44,9 +44,9 @@ int main(int argc, char ** argv) InvertedGenerationalDistance * qualityIndicator = snew InvertedGenerationalDistance(); //Read the front from the files - std::vector< std::vector > solutionFront = + MatrixOfDouble solutionFront = qualityIndicator->utils_->readFront(argv[1]); - std::vector< std::vector > trueFront = + MatrixOfDouble trueFront = qualityIndicator->utils_->readFront(argv[2]); //Obtain delta value diff --git a/src/qualityIndicator/util/LexicoGraphicalComparator.cpp b/src/qualityIndicator/util/LexicoGraphicalComparator.cpp index 9ca0cfc..937c20e 100644 --- a/src/qualityIndicator/util/LexicoGraphicalComparator.cpp +++ b/src/qualityIndicator/util/LexicoGraphicalComparator.cpp @@ -20,7 +20,9 @@ #include +#include "JMetalHeader.h" +using namespace JMetal; /** * The compare method compare the objects o1 and o2. @@ -30,9 +32,9 @@ */ int LexicoGraphicalComparator::compare(void * o1, void * o2) { - //Cast to std::vector o1 and o2. - std::vector pointOne = * (std::vector *) o1; - std::vector pointTwo = * (std::vector *) o2; + //Cast to VectorOfDouble o1 and o2. + VectorOfDouble pointOne = * (VectorOfDouble *) o1; + VectorOfDouble pointTwo = * (VectorOfDouble *) o2; //To determine the first i, that pointOne[i] != pointTwo[i]; int index = 0; diff --git a/src/qualityIndicator/util/LexicoGraphicalComparator.h b/src/qualityIndicator/util/LexicoGraphicalComparator.h index 223cfef..4fea8a6 100644 --- a/src/qualityIndicator/util/LexicoGraphicalComparator.h +++ b/src/qualityIndicator/util/LexicoGraphicalComparator.h @@ -22,7 +22,6 @@ #define __LEXICOGRAPHICALCOMPARATOR__ #include -#include class LexicoGraphicalComparator : public Comparator { diff --git a/src/qualityIndicator/util/MetricsUtil.cpp b/src/qualityIndicator/util/MetricsUtil.cpp index c6e5a6a..242049e 100644 --- a/src/qualityIndicator/util/MetricsUtil.cpp +++ b/src/qualityIndicator/util/MetricsUtil.cpp @@ -30,10 +30,10 @@ * @param path The path to the file that contains the pareto front * @return double [][] whit the pareto front **/ -std::vector< std::vector > MetricsUtil::readFront(std::string path) +MatrixOfDouble MetricsUtil::readFront(std::string path) { - std::vector< std::vector > front; + MatrixOfDouble front; std::ifstream in(path.c_str()); if( !in ) @@ -46,7 +46,7 @@ std::vector< std::vector > MetricsUtil::readFront(std::string path) while( getline(in, line ) ) { - std::vector list; + VectorOfDouble list; istringstream iss(line); @@ -75,14 +75,14 @@ std::vector< std::vector > MetricsUtil::readFront(std::string path) * front * @param front The pareto front * @param noObjectives Number of objectives in the pareto front - * @return std::vector A vector of noOjectives values with the maximum values + * @return VectorOfDouble A vector of noOjectives values with the maximum values * for each objective **/ -std::vector MetricsUtil::getMaximumValues(std::vector< std::vector > front, +VectorOfDouble MetricsUtil::getMaximumValues(MatrixOfDouble front, int noObjectives) { - std::vector maximumValue; + VectorOfDouble maximumValue; for (int i = 0; i < noObjectives; i++) { @@ -109,14 +109,14 @@ std::vector MetricsUtil::getMaximumValues(std::vector< std::vector A vector of noOjectives values with the minimum values + * @return VectorOfDouble A vector of noOjectives values with the minimum values * for each objective **/ -std::vector MetricsUtil::getMinimumValues(std::vector< std::vector > front, +VectorOfDouble MetricsUtil::getMinimumValues(MatrixOfDouble front, int noObjectives) { - std::vector minimumValue; + VectorOfDouble minimumValue; for (int i = 0; i < noObjectives; i++) { @@ -146,7 +146,7 @@ std::vector MetricsUtil::getMinimumValues(std::vector< std::vector a, std::vector b) +double MetricsUtil::distance(VectorOfDouble a, VectorOfDouble b) { double distance = 0.0; @@ -162,14 +162,14 @@ double MetricsUtil::distance(std::vector a, std::vector b) /** * Gets the distance between a point and the nearest one in - * a given front (the front is given as std::vector< std::vector >) + * a given front (the front is given as MatrixOfDouble) * @param point The point * @param front The front that contains the other points to calculate the * distances * @return The minimum distance between the point and the front **/ -double MetricsUtil::distanceToClosedPoint(std::vector point, - std::vector< std::vector > front) +double MetricsUtil::distanceToClosedPoint(VectorOfDouble point, + MatrixOfDouble front) { double minDistance = distance(point,front[0]); @@ -197,8 +197,8 @@ double MetricsUtil::distanceToClosedPoint(std::vector point, * @return The minimun distances greater than zero between the point and * the front */ -double MetricsUtil::distanceToNearestPoint(std::vector point, - std::vector< std::vector > front) +double MetricsUtil::distanceToNearestPoint(VectorOfDouble point, + MatrixOfDouble front) { double minDistance = std::numeric_limits::max(); @@ -226,15 +226,15 @@ double MetricsUtil::distanceToNearestPoint(std::vector point, * @param minimumValue The minimum values allowed * @return the normalized pareto front **/ -std::vector< std::vector > MetricsUtil::getNormalizedFront(std::vector< std::vector > front, - std::vector maximumValue, std::vector minimumValue) +MatrixOfDouble MetricsUtil::getNormalizedFront(MatrixOfDouble front, + VectorOfDouble maximumValue, VectorOfDouble minimumValue) { - std::vector< std::vector > normalizedFront; + MatrixOfDouble normalizedFront; for (int i = 0; i < front.size(); i++) { - std::vector list; + VectorOfDouble list; for (int j = 0; j < front[i].size(); j++) { //normalizedFront[i][j] = (front[i][j] - minimumValue[j]) / @@ -255,14 +255,14 @@ std::vector< std::vector > MetricsUtil::getNormalizedFront(std::vector< * @param front The pareto front to inverse * @return The inverted pareto front **/ -std::vector< std::vector > MetricsUtil::invertedFront(std::vector< std::vector > front) +MatrixOfDouble MetricsUtil::invertedFront(MatrixOfDouble front) { - std::vector< std::vector > invertedFront; + MatrixOfDouble invertedFront; for (int i = 0; i < front.size(); i++) { - std::vector list; + VectorOfDouble list; for (int j = 0; j < front[i].size(); j++) { if (front[i][j] <= 1.0 && front[i][j]>= 0.0) @@ -308,7 +308,7 @@ SolutionSet * MetricsUtil::readNonDominatedSolutionSet(std::string path) while( getline(in, line ) ) { - std::vector list; + VectorOfDouble list; istringstream iss(line); while (iss) { @@ -358,7 +358,7 @@ void MetricsUtil::readNonDominatedSolutionSet(std::string path, NonDominatedSolu while( getline(in, line ) ) { - std::vector list; + VectorOfDouble list; istringstream iss(line); while (iss) { diff --git a/src/qualityIndicator/util/MetricsUtil.h b/src/qualityIndicator/util/MetricsUtil.h index a8b87b5..60d0481 100644 --- a/src/qualityIndicator/util/MetricsUtil.h +++ b/src/qualityIndicator/util/MetricsUtil.h @@ -21,18 +21,17 @@ #ifndef __METRICSUTIL__ #define __METRICSUTIL__ +#include "JMetalHeader.h" #include -#include #include #include #include #include -#include #include #include #include -using namespace std; +using namespace JMetal; /** * @class MetricsUtil @@ -43,17 +42,17 @@ class MetricsUtil { public: - vector< vector > readFront(string path); - vector getMaximumValues(vector< vector > front, int noObjectives); - vector getMinimumValues(vector< vector > front, int noObjectives); - double distance(vector a, vector b); - double distanceToClosedPoint(vector point, vector< vector > front); - double distanceToNearestPoint(vector point, vector< vector > front); - vector< vector > getNormalizedFront(vector< vector > front, - vector maximumValue, vector minimumValue); - vector< vector > invertedFront(vector< vector > front); - SolutionSet * readNonDominatedSolutionSet(string path); - void readNonDominatedSolutionSet(string path, NonDominatedSolutionList * solutionSet); + MatrixOfDouble readFront(std::string path); + VectorOfDouble getMaximumValues(MatrixOfDouble front, int noObjectives); + VectorOfDouble getMinimumValues(MatrixOfDouble front, int noObjectives); + double distance(VectorOfDouble a, VectorOfDouble b); + double distanceToClosedPoint(VectorOfDouble point, MatrixOfDouble front); + double distanceToNearestPoint(VectorOfDouble point, MatrixOfDouble front); + MatrixOfDouble getNormalizedFront(MatrixOfDouble front, + VectorOfDouble maximumValue, VectorOfDouble minimumValue); + MatrixOfDouble invertedFront(MatrixOfDouble front); + SolutionSet * readNonDominatedSolutionSet(std::string path); + void readNonDominatedSolutionSet(std::string path, NonDominatedSolutionList * solutionSet); }; #endif /* __METRICSUTIL__ */ diff --git a/src/util/AdaptiveRandomNeighborhood.cpp b/src/util/AdaptiveRandomNeighborhood.cpp index 5b2d052..66e7f22 100644 --- a/src/util/AdaptiveRandomNeighborhood.cpp +++ b/src/util/AdaptiveRandomNeighborhood.cpp @@ -42,7 +42,7 @@ AdaptiveRandomNeighborhood::AdaptiveRandomNeighborhood(SolutionSet * solutionSet for (int i = 0; i < solutionSet_->size(); i++) { //list_[i] = snew int [] - std::vector list_i; + VectorOfInteger list_i; list_i.push_back(i); list_.push_back(list_i); } @@ -89,7 +89,7 @@ AdaptiveRandomNeighborhood::AdaptiveRandomNeighborhood(SolutionSet * solutionSet } -std::vector AdaptiveRandomNeighborhood::getNeighbors(int i) +VectorOfInteger AdaptiveRandomNeighborhood::getNeighbors(int i) { if (i > list_.size()) { @@ -128,7 +128,7 @@ SolutionSet * AdaptiveRandomNeighborhood::getBestFitnessSolutionInNeighborhood(C } -std::vector> AdaptiveRandomNeighborhood::getNeighborhood() +MatrixOfInteger AdaptiveRandomNeighborhood::getNeighborhood() { return list_; } @@ -141,7 +141,7 @@ void AdaptiveRandomNeighborhood::recompute() for (int i = 0; i < solutionSet_->size(); i++) { //list_[i] = snew int [] - std::vector list_i; + VectorOfInteger list_i; list_i.push_back(i); list_.push_back(list_i); } diff --git a/src/util/AdaptiveRandomNeighborhood.h b/src/util/AdaptiveRandomNeighborhood.h index e93bcae..c3ae50d 100644 --- a/src/util/AdaptiveRandomNeighborhood.h +++ b/src/util/AdaptiveRandomNeighborhood.h @@ -25,35 +25,24 @@ #include #include #include - -#include #include -//#include - - /** * Class representing an adaptive random neighborhood */ class AdaptiveRandomNeighborhood { - -private: - - SolutionSet * solutionSet_; - std::vector> list_; +protected: + SolutionSet * solutionSet_ = nullptr; + MatrixOfInteger list_; int numberOfRandomNeighbours_; - public: - AdaptiveRandomNeighborhood(SolutionSet * solutionSet, int numberOfRandomNeighbours); - std::vector getNeighbors(int i); + VectorOfInteger getNeighbors(int i); int getNumberOfRandomNeighbours(); SolutionSet * getBestFitnessSolutionInNeighborhood(Comparator * comparator); - std::vector> getNeighborhood(); + MatrixOfInteger getNeighborhood(); void recompute(); - //std::string toString(); - }; // AdaptiveRandomNeighborhood #endif /* __ADAPTIVE_RANDOM_NEIGHBORHOOD__ */ diff --git a/src/util/Ranking.cpp b/src/util/Ranking.cpp index fb7c58f..c0b245c 100644 --- a/src/util/Ranking.cpp +++ b/src/util/Ranking.cpp @@ -56,10 +56,10 @@ Ranking::Ranking (SolutionSet * solutionSet) } // iDominate[k] contains the list of solutions dominated by k - std::vector * iDominate = new std::vector[solutionSet_->size()]; + VectorOfInteger * iDominate = new VectorOfInteger[solutionSet_->size()]; // front[i] contains the list of individuals belonging to the front i - std::vector * front = new std::vector[solutionSet_->size()+1]; + VectorOfInteger * front = new VectorOfInteger[solutionSet_->size()+1]; // flagDominate is an auxiliar variable int flagDominate; @@ -109,7 +109,7 @@ Ranking::Ranking (SolutionSet * solutionSet) // Obtain the rest of fronts int i = 0; - std::vector::iterator it1, it2; + VectorOfInteger::iterator it1, it2; while (front[i].size()!=0) { i++; From 162447d60665f7e4296c8c75726b2418ae2fb4d7 Mon Sep 17 00:00:00 2001 From: Sergio Vieira Date: Fri, 28 Jul 2017 16:27:22 -0300 Subject: [PATCH 12/29] refactored omopso main file --- src/main/OMOPSO_main.cpp | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/src/main/OMOPSO_main.cpp b/src/main/OMOPSO_main.cpp index 579ef79..e361f5b 100644 --- a/src/main/OMOPSO_main.cpp +++ b/src/main/OMOPSO_main.cpp @@ -39,19 +39,13 @@ */ int main(int argc, char ** argv) { - clock_t t_ini, t_fin; - - Problem *problem; // The problem to solve - Algorithm *algorithm; // The algorithm to use - Mutation *uniformMutation; - Mutation *nonUniformMutation; - - QualityIndicator *indicators ; // Object to get quality indicators - - MapOfStringFunct parameters; // Operator parameters - - indicators = nullptr; + Problem *problem = nullptr; // The problem to solve + Algorithm *algorithm = nullptr; // The algorithm to use + Mutation *uniformMutation = nullptr; + Mutation *nonUniformMutation = nullptr; + QualityIndicator *indicators = nullptr; // Object to get quality indicators + MapOfStringFunct parameters; // Operator parameters if (argc>=2) { @@ -64,9 +58,7 @@ int main(int argc, char ** argv) std::cout << "Default problem will be used: Kursawe" << std::endl; problem = ProblemFactory::getProblem(const_cast("Kursawe")); } - algorithm = snew OMOPSO(problem); - int maxIterations = 250; double perturbationIndex = 0.5; double mutationProbability = 1.0/problem->getNumberOfVariables(); @@ -77,22 +69,18 @@ int main(int argc, char ** argv) algorithm->setInputParameter("swarmSize",&swarmSize); algorithm->setInputParameter("archiveSize",&archiveSize); algorithm->setInputParameter("maxIterations",&maxIterations); - parameters["probability"] = &mutationProbability; parameters["perturbation"] = &perturbationIndex; uniformMutation = snew UniformMutation(parameters); - parameters.clear(); parameters["probability"] = &mutationProbability; parameters["perturbation"] = &perturbationIndex; parameters["maxIterations"] = &maxIterations; nonUniformMutation = snew NonUniformMutation(parameters); - // Add the operators to the algorithm algorithm->addOperator("uniformMutation",uniformMutation); algorithm->addOperator("nonUniformMutation",nonUniformMutation); - // Execute the Algorithm t_ini = clock(); SolutionSet * population = algorithm->execute(); @@ -106,7 +94,6 @@ int main(int argc, char ** argv) population->printVariablesToFile("VAR"); std::cout << "Objectives values have been written to file FUN" << std::endl; population->printObjectivesToFile("FUN"); - if (indicators != nullptr) { std::cout << "Quality indicators" << std::endl ; @@ -121,5 +108,4 @@ int main(int argc, char ** argv) delete nonUniformMutation; delete population; delete algorithm; - } // main From dbd90ea568ffd9216aecd439c3f34c7d3f530b9b Mon Sep 17 00:00:00 2001 From: "joao.goncalves joao.goncalves" Date: Fri, 4 Aug 2017 11:59:52 -0300 Subject: [PATCH 13/29] Included the sigaproblem. --- src/problems/SIGA/SIGARuleMetal.cpp | 57 +++++++++++++++++++++++++++++ src/problems/SIGA/SIGARuleMetal.h | 24 ++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 src/problems/SIGA/SIGARuleMetal.cpp create mode 100644 src/problems/SIGA/SIGARuleMetal.h diff --git a/src/problems/SIGA/SIGARuleMetal.cpp b/src/problems/SIGA/SIGARuleMetal.cpp new file mode 100644 index 0000000..d129704 --- /dev/null +++ b/src/problems/SIGA/SIGARuleMetal.cpp @@ -0,0 +1,57 @@ +#include "SIGARuleMetal.h" + +SIGARuleMetal::SIGARuleMetal(std::function callback, string solutionType, int numberOfVariables, int numberOfObjectives) +{ + numberOfVariables_ = numberOfVariables; + numberOfObjectives_ = numberOfObjectives; + numberOfConstraints_ = 0; + callback_ = callback; + problemName_ = "SIGARule"; + + lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (lowerLimit_ == nullptr) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (upperLimit_ == nullptr) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + for (int i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = 0.0; + upperLimit_[i] = 1.0; + } + + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = snew BinaryRealSolutionType(this); + else if (solutionType.compare("Real") == 0) + { + solutionType_ = snew RealSolutionType(this); + //cout << "Tipo seleccionado Real" << endl; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = snew ArrayRealSolutionType(this); + else + { + cout << "Error: solution type " << solutionType << " invalid" << endl; + exit(-1); + } +} + +void SIGARuleMetal::evaluate(Solution * solution) +{ + callback_(solution); +} + +SIGARuleMetal::~SIGARuleMetal() +{ + delete[] lowerLimit_; + delete[] upperLimit_; + delete solutionType_; +} diff --git a/src/problems/SIGA/SIGARuleMetal.h b/src/problems/SIGA/SIGARuleMetal.h new file mode 100644 index 0000000..c20ca2c --- /dev/null +++ b/src/problems/SIGA/SIGARuleMetal.h @@ -0,0 +1,24 @@ +#ifndef __SIGA_RULE_METAL_H__ +#define __SIGA_RULE_METAL_H__ + +#include +#include +#include +#include +#include +#include +#include +#include + +class SIGARuleMetal : public Problem +{ +public: + SIGARuleMetal(std::function callback, string solutionType, int numberOfVariables, int numberOfObjectives); + void evaluate(Solution *solution); + + virtual ~SIGARuleMetal(); +private: + std::function callback_; +}; + +#endif /* __DTLZ1_H__ */ From 0ac153dc43fb63f3548bda9dd933880747fb3445 Mon Sep 17 00:00:00 2001 From: "joao.goncalves joao.goncalves" Date: Fri, 4 Aug 2017 13:33:27 -0300 Subject: [PATCH 14/29] Inserted the cmakeList. --- src/problems/CMakeLists.txt | 3 ++- src/problems/SIGA/CMakeLists.txt | 0 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 src/problems/SIGA/CMakeLists.txt diff --git a/src/problems/CMakeLists.txt b/src/problems/CMakeLists.txt index 9543ef7..97b2150 100644 --- a/src/problems/CMakeLists.txt +++ b/src/problems/CMakeLists.txt @@ -4,4 +4,5 @@ LIST_APPEND("${SOURCES}") add_subdirectory(DTLZ) add_subdirectory(LZ09) add_subdirectory(singleObjective) -add_subdirectory(ZDT) \ No newline at end of file +add_subdirectory(ZDT) +add_subdirectory(SIGA) \ No newline at end of file diff --git a/src/problems/SIGA/CMakeLists.txt b/src/problems/SIGA/CMakeLists.txt new file mode 100644 index 0000000..e69de29 From c18d5374d9490e467f4a3a572d4bae55ff0c73f5 Mon Sep 17 00:00:00 2001 From: Sergio Vieira Date: Fri, 4 Aug 2017 15:17:58 -0300 Subject: [PATCH 15/29] - Adds Range Mutation and some improvements --- src/core/JMetalHeader.h | 2 + src/encodings/variable/ArrayReal.cpp | 10 ++-- src/encodings/variable/ArrayReal.h | 9 ++-- src/operators/mutation/RangeMutation.cpp | 48 ++++++++++++++++++ src/operators/mutation/RangeMutation.h | 63 ++++++++++++++++++++++++ src/util/wrapper/XReal.cpp | 6 ++- 6 files changed, 127 insertions(+), 11 deletions(-) create mode 100644 src/operators/mutation/RangeMutation.cpp create mode 100644 src/operators/mutation/RangeMutation.h diff --git a/src/core/JMetalHeader.h b/src/core/JMetalHeader.h index 92e6d72..20964a0 100644 --- a/src/core/JMetalHeader.h +++ b/src/core/JMetalHeader.h @@ -30,6 +30,8 @@ namespace JMetal using VectorOfBoolean = std::vector; using MatrixOfBoolean = std::vector; using VectorOfString = std::vector; + using VectorOfShort = std::vector; + using MatrixOfShort = std::vector; } #endif \ No newline at end of file diff --git a/src/encodings/variable/ArrayReal.cpp b/src/encodings/variable/ArrayReal.cpp index 10c1699..84b4464 100644 --- a/src/encodings/variable/ArrayReal.cpp +++ b/src/encodings/variable/ArrayReal.cpp @@ -30,7 +30,7 @@ ArrayReal::ArrayReal() { problem_ = nullptr; size_ = 0; - array_ = nullptr; + //array_ = nullptr; } // Constructor @@ -42,7 +42,8 @@ ArrayReal::ArrayReal(int size, Problem * problem) { problem_ = problem; size_ = size; - array_ = snew double[size_]; + //array_ = snew double[size_]; + array_.assign(size_, 0.0); for (int i = 0; i < size_ ; i++) { @@ -61,7 +62,8 @@ ArrayReal::ArrayReal(ArrayReal * arrayReal) { problem_ = arrayReal->problem_ ; size_ = arrayReal->size_; - array_ = snew double[size_]; + //array_ = snew double[size_]; + array_.assign(size_, 0.0); for (int i = 0; i < size_; i++) { @@ -75,7 +77,7 @@ ArrayReal::ArrayReal(ArrayReal * arrayReal) */ ArrayReal::~ArrayReal() { - delete [] array_; + //delete [] array_; } // ~ArrayReal diff --git a/src/encodings/variable/ArrayReal.h b/src/encodings/variable/ArrayReal.h index 940078d..d3f829f 100644 --- a/src/encodings/variable/ArrayReal.h +++ b/src/encodings/variable/ArrayReal.h @@ -33,11 +33,10 @@ */ class ArrayReal : public Variable { - -public: - - double * array_; - Problem * problem_; +protected: + JMetal::VectorOfDouble array_; +public: + Problem * problem_ = nullptr; int size_; ArrayReal(); diff --git a/src/operators/mutation/RangeMutation.cpp b/src/operators/mutation/RangeMutation.cpp new file mode 100644 index 0000000..79a07bd --- /dev/null +++ b/src/operators/mutation/RangeMutation.cpp @@ -0,0 +1,48 @@ +#include "RangeMutation.h" + +RangeMutation::RangeMutation(MapOfStringFunct parameters): Mutation(parameters) +{ + if (parameters["probability"] != nullptr) + { + mutationProbability_ = *(double *)parameters["probability"]; + } + if (parameters["perturbation"] != nullptr) + { + perturbation_ = *(double *)parameters["perturbation"]; + } + if (parameters["zone_index"] != nullptr) + { + zoneIndex_ = *(MatrixOfShort *)parameters["zone_index"]; + } +} + +void RangeMutation::doMutation(double probability, Solution * solution) +{ + XReal * x = new XReal(solution); + for (int var = 0; var < solution->getNumberOfVariables(); ++var) + { + if (PseudoRandom::randDouble() < probability) + { + double rand = PseudoRandom::randDouble(); + double tmp = (rand - 0.5) * perturbation_; + + tmp += x->getValue(var); + if (tmp < x->getLowerBound(var)) + { + tmp = x->getLowerBound(var); + } + else if (tmp > x->getUpperBound(var)) + { + tmp = x->getUpperBound(var); + } + x->setValue(var, tmp); + } // if + } // for + + delete x; +} + +void * RangeMutation::execute(void *) +{ + return nullptr; +} diff --git a/src/operators/mutation/RangeMutation.h b/src/operators/mutation/RangeMutation.h new file mode 100644 index 0000000..b2d4ce1 --- /dev/null +++ b/src/operators/mutation/RangeMutation.h @@ -0,0 +1,63 @@ +// UniformMutation.h +// +// Author: +// Sérgio Vieira +// +// Copyright (c) 2014 Antonio J. Nebro +// +// This program 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 3 of the License, or +// (at your option) any later version. +// +// This program 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 program. If not, see . + +#ifndef __RANGE_MUTATION__ +#define __RANGE_MUTATION__ + +#include +#include +#include +#include + +/** +* This class implements a uniform mutation operator. +*/ +class RangeMutation : public Mutation +{ +protected: + /** + * Stores the value used in a range mutation operator. + */ + double perturbation_ = 0.0; + double mutationProbability_ = 0.0; + MatrixOfShort zoneIndex_; + /** + * Performs the operation. + * @param probability Mutation probability + * @param solution The solution to mutate + * @throws JMException + */ + void doMutation(double probability, Solution *solution); +public: + /** + * Constructor. + * Creates a new range mutation operator instance. + */ + RangeMutation(MapOfStringFunct parameters); + + /** + * Executes the operation + * @param object An object containing the solution to mutate + */ + void *execute(void *); + +}; // Range Mutation + +#endif diff --git a/src/util/wrapper/XReal.cpp b/src/util/wrapper/XReal.cpp index 49776cf..8e86a1f 100644 --- a/src/util/wrapper/XReal.cpp +++ b/src/util/wrapper/XReal.cpp @@ -58,7 +58,8 @@ double XReal::getValue(int index) } else if (typeid(*type_) == typeid(ArrayRealSolutionType)) { - return ((ArrayReal*)(solution_->getDecisionVariables()[0]))->array_[index]; + //return ((ArrayReal*)(solution_->getDecisionVariables()[0]))->array_[index]; + return ((ArrayReal*)(solution_->getDecisionVariables()[0]))->getValue(index); } else { @@ -85,7 +86,8 @@ void XReal::setValue(int index, double value) } else if (typeid(*type_) == typeid(ArrayRealSolutionType)) { - ((ArrayReal*)(solution_->getDecisionVariables()[0]))->array_[index]=value; + //((ArrayReal*)(solution_->getDecisionVariables()[0]))->array_[index]=value; + ((ArrayReal*)(solution_->getDecisionVariables()[0]))->setValue(index, value); } else { From 41c7a54d74dfba73e529ec534b5a4ecc0cfd7f98 Mon Sep 17 00:00:00 2001 From: Sergio Vieira Date: Fri, 4 Aug 2017 16:20:47 -0300 Subject: [PATCH 16/29] - Implemented Range Mutation --- src/main/OMOPSO_main.cpp | 9 +++- src/operators/mutation/RangeMutation.cpp | 60 +++++++++++++++++------- src/operators/mutation/RangeMutation.h | 4 ++ 3 files changed, 53 insertions(+), 20 deletions(-) diff --git a/src/main/OMOPSO_main.cpp b/src/main/OMOPSO_main.cpp index e361f5b..ab7a9d9 100644 --- a/src/main/OMOPSO_main.cpp +++ b/src/main/OMOPSO_main.cpp @@ -30,7 +30,7 @@ #include #include #include - +#include "RangeMutation.h" #include #include @@ -64,6 +64,9 @@ int main(int argc, char ** argv) double mutationProbability = 1.0/problem->getNumberOfVariables(); int swarmSize = 100; int archiveSize = 100; + JMetal::MatrixOfShort indexZones{{0, 1}}; + //JMetal::VectorOfShort indexes{0, 1}; + //indexZones.push_back(indexes); // Algorithm parameters algorithm->setInputParameter("swarmSize",&swarmSize); @@ -71,7 +74,9 @@ int main(int argc, char ** argv) algorithm->setInputParameter("maxIterations",&maxIterations); parameters["probability"] = &mutationProbability; parameters["perturbation"] = &perturbationIndex; - uniformMutation = snew UniformMutation(parameters); + parameters["zone_index"] = &indexZones; + //uniformMutation = snew UniformMutation(parameters); + uniformMutation = snew RangeMutation(parameters); parameters.clear(); parameters["probability"] = &mutationProbability; parameters["perturbation"] = &perturbationIndex; diff --git a/src/operators/mutation/RangeMutation.cpp b/src/operators/mutation/RangeMutation.cpp index 79a07bd..e78115d 100644 --- a/src/operators/mutation/RangeMutation.cpp +++ b/src/operators/mutation/RangeMutation.cpp @@ -19,30 +19,54 @@ RangeMutation::RangeMutation(MapOfStringFunct parameters): Mutation(parameters) void RangeMutation::doMutation(double probability, Solution * solution) { XReal * x = new XReal(solution); - for (int var = 0; var < solution->getNumberOfVariables(); ++var) + for (auto row : zoneIndex_) { - if (PseudoRandom::randDouble() < probability) + for (auto col: row) { - double rand = PseudoRandom::randDouble(); - double tmp = (rand - 0.5) * perturbation_; - - tmp += x->getValue(var); - if (tmp < x->getLowerBound(var)) - { - tmp = x->getLowerBound(var); - } - else if (tmp > x->getUpperBound(var)) + if (PseudoRandom::randDouble() < probability) { - tmp = x->getUpperBound(var); + double tmp = doPertubation(x, col); + x->setValue(col, tmp); } - x->setValue(var, tmp); - } // if - } // for - + } + } delete x; } -void * RangeMutation::execute(void *) +double RangeMutation::doPertubation(XReal* array, short col) +{ + double rand = PseudoRandom::randDouble(); + double tmp = (rand - 0.5) * perturbation_; + tmp += array->getValue(col); + double minMaxRange = ((array->getUpperBound(col) - array->getLowerBound(col)) / 2.0); + if (tmp < array->getLowerBound(col)) + { + //tmp = array->getLowerBound(col); + tmp = array->getLowerBound(col) + minMaxRange; + if (perturbation_ > 0.0 + && perturbation_ < 1.0) + { + double prand = PseudoRandom::randDouble() * perturbation_; + tmp = array->getLowerBound(col) + minMaxRange * prand; + } + } + else if (tmp > array->getUpperBound(col)) + { + //tmp = array->getUpperBound(col); + tmp = array->getUpperBound(col) - minMaxRange; + if (perturbation_ > 0.0 + && perturbation_ < 1.0) + { + double prand = PseudoRandom::randDouble() * perturbation_; + tmp = array->getUpperBound(col) - minMaxRange * prand; + } + } + return tmp; +} + +void * RangeMutation::execute(void * object) { - return nullptr; + Solution *solution = (Solution *)object; + doMutation(mutationProbability_, solution); + return solution; } diff --git a/src/operators/mutation/RangeMutation.h b/src/operators/mutation/RangeMutation.h index b2d4ce1..0c86aa1 100644 --- a/src/operators/mutation/RangeMutation.h +++ b/src/operators/mutation/RangeMutation.h @@ -45,6 +45,10 @@ class RangeMutation : public Mutation * @throws JMException */ void doMutation(double probability, Solution *solution); + /** + * Creates a valid random pertubation + **/ + double doPertubation(XReal* array, short col); public: /** * Constructor. From a56e02d983efdb686fc939bb2fbef4d84a441dd5 Mon Sep 17 00:00:00 2001 From: Sergio Vieira Date: Mon, 7 Aug 2017 09:11:36 -0300 Subject: [PATCH 17/29] - Improvements on nonUniformMutation class --- src/operators/mutation/NonUniformMutation.cpp | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/operators/mutation/NonUniformMutation.cpp b/src/operators/mutation/NonUniformMutation.cpp index ac70eb8..9e6a397 100644 --- a/src/operators/mutation/NonUniformMutation.cpp +++ b/src/operators/mutation/NonUniformMutation.cpp @@ -58,11 +58,10 @@ NonUniformMutation::NonUniformMutation(MapOfStringFunct parameters) */ void NonUniformMutation::doMutation(double probability, Solution *solution) { - - XReal * x = new XReal(solution); - + XReal * x = new XReal(solution); for (int var=0; var < solution->getNumberOfVariables(); var++) { + double minMaxRange = ((x->getUpperBound(var) - x->getLowerBound(var)) / 2.0); if (PseudoRandom::randDouble() < probability) { double rand = PseudoRandom::randDouble(); @@ -83,11 +82,25 @@ void NonUniformMutation::doMutation(double probability, Solution *solution) if (tmp < x->getLowerBound(var)) { - tmp = x->getLowerBound(var); + //tmp = x->getLowerBound(var); + tmp = x->getLowerBound(var) + minMaxRange; + if (perturbation_ > 0.0 + && perturbation_ < 1.0) + { + double prand = PseudoRandom::randDouble() * perturbation_; + tmp = x->getLowerBound(var) + minMaxRange * prand; + } + } else if (tmp > x->getUpperBound(var)) { - tmp = x->getUpperBound(var); + //tmp = x->getUpperBound(var); + if (perturbation_ > 0.0 + && perturbation_ < 1.0) + { + double prand = PseudoRandom::randDouble() * perturbation_; + tmp = x->getUpperBound(var) - minMaxRange * prand; + } } x->setValue(var, tmp) ; From 26504e7bdd5776bfeef1dd1e8677b06aa7e1e662 Mon Sep 17 00:00:00 2001 From: Sergio Vieira Date: Mon, 7 Aug 2017 09:18:41 -0300 Subject: [PATCH 18/29] - Improvements on UniformMutation class --- src/operators/mutation/UniformMutation.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/operators/mutation/UniformMutation.cpp b/src/operators/mutation/UniformMutation.cpp index e497827..e381704 100644 --- a/src/operators/mutation/UniformMutation.cpp +++ b/src/operators/mutation/UniformMutation.cpp @@ -58,6 +58,7 @@ void UniformMutation::doMutation(double probability, Solution *solution) for (int var=0; var < solution->getNumberOfVariables(); var++) { + double minMaxRange = ((x->getUpperBound(var) - x->getLowerBound(var)) / 2.0); if (PseudoRandom::randDouble() < probability) { double rand = PseudoRandom::randDouble(); @@ -67,11 +68,25 @@ void UniformMutation::doMutation(double probability, Solution *solution) if (tmp < x->getLowerBound(var)) { - tmp = x->getLowerBound(var); + //tmp = x->getLowerBound(var); + tmp = x->getLowerBound(var) + minMaxRange; + if (perturbation_ > 0.0 + && perturbation_ < 1.0) + { + double prand = PseudoRandom::randDouble() * perturbation_; + tmp = x->getLowerBound(var) + minMaxRange * prand; + } + } else if (tmp > x->getUpperBound(var)) { - tmp = x->getUpperBound(var); + //tmp = x->getUpperBound(var); + if (perturbation_ > 0.0 + && perturbation_ < 1.0) + { + double prand = PseudoRandom::randDouble() * perturbation_; + tmp = x->getUpperBound(var) - minMaxRange * prand; + } } x->setValue(var, tmp) ; From 59bb8e33d01694f0f98813fb8ff553fa0fffbe39 Mon Sep 17 00:00:00 2001 From: Sergio Vieira Date: Mon, 7 Aug 2017 14:57:19 -0300 Subject: [PATCH 19/29] - Improvements on OMOPS particle moving --- src/metaheuristics/omopso/OMOPSO.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/metaheuristics/omopso/OMOPSO.cpp b/src/metaheuristics/omopso/OMOPSO.cpp index d5536d2..024b0af 100644 --- a/src/metaheuristics/omopso/OMOPSO.cpp +++ b/src/metaheuristics/omopso/OMOPSO.cpp @@ -162,16 +162,19 @@ void OMOPSO::computeNewPositions() //particle.move(speed_[i]); for (int var = 0; var < particle->getNumberOfDecisionVariables(); var++) { + double diff = (speed[i][var] / 2.0) + PseudoRandom::randDouble(); particle->setValue(var, particle->getValue(var) + speed[i][var]); if (particle->getValue(var) < problem_->getLowerLimit(var)) - { - particle->setValue(var, problem_->getLowerLimit(var)); + { + //particle->setValue(var, problem_->getLowerLimit(var)); + particle->setValue(var, problem_->getLowerLimit(var) + diff); speed[i][var] = speed[i][var] * -1.0; } if (particle->getValue(var) > problem_->getUpperLimit(var)) { - particle->setValue(var, problem_->getUpperLimit(var)); + //particle->setValue(var, problem_->getUpperLimit(var)); + particle->setValue(var, problem_->getUpperLimit(var) - diff); speed[i][var] = speed[i][var] * -1.0; } } From 215d5caada07291a9f013aa8acd1bd2ad06bff0c Mon Sep 17 00:00:00 2001 From: "joao.goncalves joao.goncalves" Date: Mon, 7 Aug 2017 15:58:34 -0300 Subject: [PATCH 20/29] Added the test functions F1 and F3. --- src/problems/SIGA/BarrosF1_F3.cpp | 65 +++++++++++++++++++++++++++++++ src/problems/SIGA/BarrosF1_F3.h | 24 ++++++++++++ src/problems/SIGA/CMakeLists.txt | 3 ++ 3 files changed, 92 insertions(+) create mode 100644 src/problems/SIGA/BarrosF1_F3.cpp create mode 100644 src/problems/SIGA/BarrosF1_F3.h diff --git a/src/problems/SIGA/BarrosF1_F3.cpp b/src/problems/SIGA/BarrosF1_F3.cpp new file mode 100644 index 0000000..3a2a145 --- /dev/null +++ b/src/problems/SIGA/BarrosF1_F3.cpp @@ -0,0 +1,65 @@ +#include "BarrosF1_F3.h" + +BarrosF1F3::BarrosF1F3(string solutionType, int numberOfVariables, int numberOfObjectives) +{ + numberOfVariables_ = numberOfVariables; + numberOfObjectives_ = numberOfObjectives; + numberOfConstraints_ = 0; + problemName_ = "BarrosF1_F3"; + + lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (lowerLimit_ == nullptr) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (upperLimit_ == nullptr) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + for (int i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = 0.0; + upperLimit_[i] = 1.0; + } + + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = snew BinaryRealSolutionType(this); + else if (solutionType.compare("Real") == 0) + { + solutionType_ = snew RealSolutionType(this); + //cout << "Tipo seleccionado Real" << endl; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = snew ArrayRealSolutionType(this); + else + { + cout << "Error: solution type " << solutionType << " invalid" << endl; + exit(-1); + } +} + +void BarrosF1F3::evaluate(Solution * solution) +{ + XReal * vars = snew XReal(solution); + double x1 = vars->getValue(0); + double x2 = vars->getValue(1); + delete vars; + double f1 = x1; + double a = std::exp(-pow ( (x2 - 0.2) / 0.004, 2)); + double b = std::exp(-pow ( (x2 - 0.6) / 0.4, 2)); + double f3 = (2 - a - 0.8 * b) / x1; + solution->setObjective(0, f1); + solution->setObjective(0, f3); +} + +BarrosF1F3::~BarrosF1F3() +{ + delete[] lowerLimit_; + delete[] upperLimit_; + delete solutionType_; +} diff --git a/src/problems/SIGA/BarrosF1_F3.h b/src/problems/SIGA/BarrosF1_F3.h new file mode 100644 index 0000000..e049ef6 --- /dev/null +++ b/src/problems/SIGA/BarrosF1_F3.h @@ -0,0 +1,24 @@ +#ifndef __BARROS_F1_F3_H__ +#define __BARROS_F1_F3_H__ + +#include +#include +#include +#include +#include +#include +#include +#include + +class BarrosF1F3 : public Problem +{ +public: + BarrosF1F3(string solutionType, int numberOfVariables = 2, int numberOfObjectives = 2); + void evaluate(Solution *solution); + + virtual ~BarrosF1F3(); +private: + std::function callback_; +}; + +#endif /* __BARROS_F1_F3_H__ */ diff --git a/src/problems/SIGA/CMakeLists.txt b/src/problems/SIGA/CMakeLists.txt index e69de29..294ec59 100644 --- a/src/problems/SIGA/CMakeLists.txt +++ b/src/problems/SIGA/CMakeLists.txt @@ -0,0 +1,3 @@ +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file From 7660388bb2c00214244daae9dd308b2fbafbfe4a Mon Sep 17 00:00:00 2001 From: Sergio Vieira Date: Mon, 7 Aug 2017 15:58:34 -0300 Subject: [PATCH 21/29] - Adds Objective Function Barros F1 F2 --- src/main/OMOPSO_main.cpp | 4 +- src/problems/SIGA/BarrosF1F2.cpp | 123 +++++++++++++++++++++++++++++++ src/problems/SIGA/BarrosF1F2.h | 44 +++++++++++ src/problems/SIGA/CMakeLists.txt | 3 + 4 files changed, 173 insertions(+), 1 deletion(-) create mode 100644 src/problems/SIGA/BarrosF1F2.cpp create mode 100644 src/problems/SIGA/BarrosF1F2.h diff --git a/src/main/OMOPSO_main.cpp b/src/main/OMOPSO_main.cpp index ab7a9d9..39b2487 100644 --- a/src/main/OMOPSO_main.cpp +++ b/src/main/OMOPSO_main.cpp @@ -33,6 +33,7 @@ #include "RangeMutation.h" #include #include +#include "problems/SIGA/BarrosF1F2.h" /** * Method for configuring and running the OMOPSO algorithm @@ -56,7 +57,8 @@ int main(int argc, char ** argv) { std::cout << "No problem selected." << std::endl; std::cout << "Default problem will be used: Kursawe" << std::endl; - problem = ProblemFactory::getProblem(const_cast("Kursawe")); + //problem = ProblemFactory::getProblem(const_cast("Kursawe")); + problem = snew BarrosF1F2("Real"); } algorithm = snew OMOPSO(problem); int maxIterations = 250; diff --git a/src/problems/SIGA/BarrosF1F2.cpp b/src/problems/SIGA/BarrosF1F2.cpp new file mode 100644 index 0000000..3fbb330 --- /dev/null +++ b/src/problems/SIGA/BarrosF1F2.cpp @@ -0,0 +1,123 @@ +// BarrosF1F2.cpp +// +// Authors: +// Sérgio Vieira +// +// Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo +// +// This program 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 3 of the License, or +// (at your option) any later version. +// +// This program 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 program. If not, see . + +#include "problems/SIGA/BarrosF1F2.h" + +/** + * Class constructor + */ +BarrosF1F2::BarrosF1F2(std::string solutionType) +{ + numberOfVariables_ = 2; + numberOfObjectives_ = 2; + numberOfConstraints_ = 0; + problemName_ = "BarrosF1F2"; + + lowerLimit_ = snew double[numberOfVariables_]; + if (lowerLimit_ == nullptr) + { + std::cout << "BarrosF1F2::BarrosF1F2. Error reserving memory for storing the array of lower limits" << std::endl; + } // if + + upperLimit_ = snew double[numberOfVariables_]; + if (upperLimit_ == nullptr) + { + std::cout << "BarrosF1F2::BarrosF1F2. Error reserving memory for storing the array of upper limits" << std::endl; + exit(-1) ; + } // if + + for (int i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = -10.0; + upperLimit_[i] = 20.0; + } // for + + if (solutionType.compare("BinaryReal") == 0) + { + //std::cout << "Selected solution type: BinaryReal" << std::endl; + solutionType_ = snew BinaryRealSolutionType(this) ; + } + else if (solutionType.compare("Real") == 0) + { + solutionType_ = snew RealSolutionType(this) ; + //std::cout << "Selected solution type: Real" << std::endl; + } + else if (solutionType.compare("ArrayReal") == 0) + { + solutionType_ = snew ArrayRealSolutionType(this) ; + } + else + { + std::cout << "Error: solution type " << solutionType << " invalid" << std::endl; + exit(-1) ; + } +} // BarrosF1F2 + + +/** + * Destructor + */ +BarrosF1F2::~BarrosF1F2() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; +} // ~BarrosF1F2 + + +/** + * Evaluates a solution + */ +void BarrosF1F2::evaluate(Solution *solution) +{ + double *fx = nullptr; + double *x = nullptr; + Variable **variables = solution->getDecisionVariables(); + + fx = snew double[numberOfObjectives_]; + if (fx == nullptr) + { + std::cout << "BarrosF1F2::evaluate: Error reserving memory for the function values array" << std::endl; + exit(-1); + } // if + + x = snew double[numberOfVariables_]; + if (x == nullptr) + { + std::cout << "BarrosF1F2::evaluate: Error reserving memory for the variable values array" << std::endl; + exit(-1); + } // if + + for (int i = 0; i < numberOfVariables_; i++) + { + x[i] = variables[i]->getValue() ; + } + fx[0] = x[0]; + double value1 = pow(x[0] - 4.0, 2.0); + double value2 = pow(x[1] - 4.0, 2.0); + double valueSqrt = sqrt(value1 + value2); + fx[1] = -20.0 * (sin(0.1 + valueSqrt) / (0.1 + valueSqrt)); + solution->setObjective(0,fx[0]); + solution->setObjective(1,fx[1]); + + delete[]fx ; + delete[]x ; +} // evaluate + diff --git a/src/problems/SIGA/BarrosF1F2.h b/src/problems/SIGA/BarrosF1F2.h new file mode 100644 index 0000000..cca92b7 --- /dev/null +++ b/src/problems/SIGA/BarrosF1F2.h @@ -0,0 +1,44 @@ +// BarrosF1F2.h +// +// Authors: +// Sérgio Vieira +// +// +// Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo +// +// This program 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 3 of the License, or +// (at your option) any later version. +// +// This program 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 program. If not, see . + +#ifndef __BARROS_F1_F2__ +#define __BARROS_F1_F2__ + +#include +#include +#include +#include +#include +#include + +/** + * @class Barros F1 F2 + * @brief Class representing problem Barros + **/ +class BarrosF1F2 : public Problem +{ +public: + BarrosF1F2(std::string solutionType); + ~BarrosF1F2(); + void evaluate(Solution *solution); +}; + +#endif /** __BARROS_F1_F2__ **/ diff --git a/src/problems/SIGA/CMakeLists.txt b/src/problems/SIGA/CMakeLists.txt index e69de29..294ec59 100644 --- a/src/problems/SIGA/CMakeLists.txt +++ b/src/problems/SIGA/CMakeLists.txt @@ -0,0 +1,3 @@ +file(GLOB SOURCES "*.cpp" "*.h") +ListToString(SOURCES ";" ${SOURCES}) +LIST_APPEND("${SOURCES}") \ No newline at end of file From 3bdcd6663258f112151d5b6609d7befded4ee621 Mon Sep 17 00:00:00 2001 From: Sergio Vieira Date: Tue, 8 Aug 2017 08:37:15 -0300 Subject: [PATCH 22/29] - Adds Problems F1F3, F1F5 --- src/core/Solution.h | 22 ++-- src/main/OMOPSO_main.cpp | 27 ++--- src/metaheuristics/omopso/OMOPSO.cpp | 4 +- src/operators/mutation/NonUniformMutation.h | 8 +- .../SIGA/{BarrosF1_F3.cpp => BarrosF1F3.cpp} | 11 +- .../SIGA/{BarrosF1_F3.h => BarrosF1F3.h} | 3 +- src/problems/SIGA/BarrosF1F5.cpp | 109 ++++++++++++++++++ src/problems/SIGA/BarrosF1F5.h | 46 ++++++++ 8 files changed, 189 insertions(+), 41 deletions(-) rename src/problems/SIGA/{BarrosF1_F3.cpp => BarrosF1F3.cpp} (87%) rename src/problems/SIGA/{BarrosF1_F3.h => BarrosF1F3.h} (90%) create mode 100644 src/problems/SIGA/BarrosF1F5.cpp create mode 100644 src/problems/SIGA/BarrosF1F5.h diff --git a/src/core/Solution.h b/src/core/Solution.h index f519d21..c53f6dd 100644 --- a/src/core/Solution.h +++ b/src/core/Solution.h @@ -50,18 +50,18 @@ class Solution Problem * problem_; SolutionType * type_; Variable ** variable_; - int numberOfVariables_; + int numberOfVariables_ = 0; double *objective_; - int numberOfObjectives_; - double fitness_; - bool marked_; - int rank_; - double overallConstraintViolation_; - int numberOfViolatedConstraints_; - int location_; - double kDistance_; - double crowdingDistance_; - double distanceToSolutionSet_; + int numberOfObjectives_ = 0; + double fitness_ = 0.0; + bool marked_ = false; + int rank_ = 0; + double overallConstraintViolation_ = 0.0; + int numberOfViolatedConstraints_ = 0; + int location_ = 0; + double kDistance_ = 0.0; + double crowdingDistance_ = 0.0; + double distanceToSolutionSet_ = 0.0; public: Solution (); diff --git a/src/main/OMOPSO_main.cpp b/src/main/OMOPSO_main.cpp index 39b2487..4c7bf29 100644 --- a/src/main/OMOPSO_main.cpp +++ b/src/main/OMOPSO_main.cpp @@ -34,6 +34,8 @@ #include #include #include "problems/SIGA/BarrosF1F2.h" +#include "problems/SIGA/BarrosF1F3.h" +#include "problems/SIGA/BarrosF1F5.h" /** * Method for configuring and running the OMOPSO algorithm @@ -47,7 +49,6 @@ int main(int argc, char ** argv) Mutation *nonUniformMutation = nullptr; QualityIndicator *indicators = nullptr; // Object to get quality indicators MapOfStringFunct parameters; // Operator parameters - if (argc>=2) { problem = ProblemFactory::getProblem(argc, argv); @@ -58,49 +59,42 @@ int main(int argc, char ** argv) std::cout << "No problem selected." << std::endl; std::cout << "Default problem will be used: Kursawe" << std::endl; //problem = ProblemFactory::getProblem(const_cast("Kursawe")); - problem = snew BarrosF1F2("Real"); + problem = snew BarrosF1F5("Real"); } + //indicators = snew QualityIndicator(problem, "paretofront.txt"); algorithm = snew OMOPSO(problem); int maxIterations = 250; double perturbationIndex = 0.5; - double mutationProbability = 1.0/problem->getNumberOfVariables(); + double mutationProbability = 1.0 / problem->getNumberOfVariables(); int swarmSize = 100; int archiveSize = 100; - JMetal::MatrixOfShort indexZones{{0, 1}}; - //JMetal::VectorOfShort indexes{0, 1}; - //indexZones.push_back(indexes); - // Algorithm parameters algorithm->setInputParameter("swarmSize",&swarmSize); algorithm->setInputParameter("archiveSize",&archiveSize); algorithm->setInputParameter("maxIterations",&maxIterations); parameters["probability"] = &mutationProbability; parameters["perturbation"] = &perturbationIndex; - parameters["zone_index"] = &indexZones; - //uniformMutation = snew UniformMutation(parameters); - uniformMutation = snew RangeMutation(parameters); + uniformMutation = snew UniformMutation(parameters); parameters.clear(); parameters["probability"] = &mutationProbability; parameters["perturbation"] = &perturbationIndex; parameters["maxIterations"] = &maxIterations; nonUniformMutation = snew NonUniformMutation(parameters); - // Add the operators to the algorithm - algorithm->addOperator("uniformMutation",uniformMutation); - algorithm->addOperator("nonUniformMutation",nonUniformMutation); + algorithm->addOperator("uniformMutation", uniformMutation); + algorithm->addOperator("nonUniformMutation", nonUniformMutation); // Execute the Algorithm t_ini = clock(); SolutionSet * population = algorithm->execute(); t_fin = clock(); double secs = (double) (t_fin - t_ini); secs = secs / CLOCKS_PER_SEC; - // Print the results std::cout << "Total execution time: " << secs << "s" << std::endl; std::cout << "Variables values have been written to file VAR" << std::endl; - population->printVariablesToFile("VAR"); + population->printVariablesToFile("variables.txt"); std::cout << "Objectives values have been written to file FUN" << std::endl; - population->printObjectivesToFile("FUN"); + population->printObjectivesToFile("objectives.txt"); if (indicators != nullptr) { std::cout << "Quality indicators" << std::endl ; @@ -110,7 +104,6 @@ int main(int argc, char ** argv) std::cout << "Spread : " << indicators->getSpread(population) << std::endl ; std::cout << "Epsilon : " << indicators->getEpsilon(population) << std::endl ; } // if - delete uniformMutation; delete nonUniformMutation; delete population; diff --git a/src/metaheuristics/omopso/OMOPSO.cpp b/src/metaheuristics/omopso/OMOPSO.cpp index 024b0af..841fe2e 100644 --- a/src/metaheuristics/omopso/OMOPSO.cpp +++ b/src/metaheuristics/omopso/OMOPSO.cpp @@ -162,18 +162,18 @@ void OMOPSO::computeNewPositions() //particle.move(speed_[i]); for (int var = 0; var < particle->getNumberOfDecisionVariables(); var++) { - double diff = (speed[i][var] / 2.0) + PseudoRandom::randDouble(); particle->setValue(var, particle->getValue(var) + speed[i][var]); - if (particle->getValue(var) < problem_->getLowerLimit(var)) { //particle->setValue(var, problem_->getLowerLimit(var)); + double diff = (problem_->getLowerLimit(var) - particle->getValue(var)) / 2.0 + PseudoRandom::randDouble(); particle->setValue(var, problem_->getLowerLimit(var) + diff); speed[i][var] = speed[i][var] * -1.0; } if (particle->getValue(var) > problem_->getUpperLimit(var)) { //particle->setValue(var, problem_->getUpperLimit(var)); + double diff = (particle->getValue(var) - problem_->getUpperLimit(var)) / 2.0 + PseudoRandom::randDouble(); particle->setValue(var, problem_->getUpperLimit(var) - diff); speed[i][var] = speed[i][var] * -1.0; } diff --git a/src/operators/mutation/NonUniformMutation.h b/src/operators/mutation/NonUniformMutation.h index e2257b3..0999012 100644 --- a/src/operators/mutation/NonUniformMutation.h +++ b/src/operators/mutation/NonUniformMutation.h @@ -44,20 +44,20 @@ class NonUniformMutation : public Mutation * perturbation_ stores the perturbation value used in the Non Uniform * mutation operator */ - double perturbation_; + double perturbation_ = 0.0; /** * maxIterations_ stores the maximun number of iterations. */ - int maxIterations_; + int maxIterations_ = 0; /** * currentIteration_ stores the iteration in which the operator is going to be * applied */ - int currentIteration_; + int currentIteration_ = 0; - double mutationProbability_; + double mutationProbability_ = 0; /** * Performs the operation. diff --git a/src/problems/SIGA/BarrosF1_F3.cpp b/src/problems/SIGA/BarrosF1F3.cpp similarity index 87% rename from src/problems/SIGA/BarrosF1_F3.cpp rename to src/problems/SIGA/BarrosF1F3.cpp index 3a2a145..b0e1c03 100644 --- a/src/problems/SIGA/BarrosF1_F3.cpp +++ b/src/problems/SIGA/BarrosF1F3.cpp @@ -1,11 +1,12 @@ -#include "BarrosF1_F3.h" +//#include "BarrosF1_F3.h" +#include "problems/SIGA/BarrosF1F3.h" BarrosF1F3::BarrosF1F3(string solutionType, int numberOfVariables, int numberOfObjectives) { numberOfVariables_ = numberOfVariables; numberOfObjectives_ = numberOfObjectives; numberOfConstraints_ = 0; - problemName_ = "BarrosF1_F3"; + problemName_ = "BarrosF1F3"; lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); if (lowerLimit_ == nullptr) @@ -50,11 +51,11 @@ void BarrosF1F3::evaluate(Solution * solution) double x2 = vars->getValue(1); delete vars; double f1 = x1; - double a = std::exp(-pow ( (x2 - 0.2) / 0.004, 2)); - double b = std::exp(-pow ( (x2 - 0.6) / 0.4, 2)); + double a = std::exp(-pow ( (x2 - 0.2) / 0.004, 2.0)); + double b = std::exp(-pow ( (x2 - 0.6) / 0.4, 2.0)); double f3 = (2 - a - 0.8 * b) / x1; solution->setObjective(0, f1); - solution->setObjective(0, f3); + solution->setObjective(1, f3); } BarrosF1F3::~BarrosF1F3() diff --git a/src/problems/SIGA/BarrosF1_F3.h b/src/problems/SIGA/BarrosF1F3.h similarity index 90% rename from src/problems/SIGA/BarrosF1_F3.h rename to src/problems/SIGA/BarrosF1F3.h index e049ef6..9dfb81f 100644 --- a/src/problems/SIGA/BarrosF1_F3.h +++ b/src/problems/SIGA/BarrosF1F3.h @@ -17,8 +17,7 @@ class BarrosF1F3 : public Problem void evaluate(Solution *solution); virtual ~BarrosF1F3(); -private: - std::function callback_; + }; #endif /* __BARROS_F1_F3_H__ */ diff --git a/src/problems/SIGA/BarrosF1F5.cpp b/src/problems/SIGA/BarrosF1F5.cpp new file mode 100644 index 0000000..ca25c76 --- /dev/null +++ b/src/problems/SIGA/BarrosF1F5.cpp @@ -0,0 +1,109 @@ +// BarrosF1F5.cpp +// +// Authors: +// Sérgio Vieira +// +// Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo +// +// This program 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 3 of the License, or +// (at your option) any later version. +// +// This program 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 program. If not, see . + +#include "problems/SIGA/BarrosF1F5.h" + +/** + * Class constructor + */ +BarrosF1F5::BarrosF1F5(std::string solutionType) +{ + numberOfVariables_ = 2; + numberOfObjectives_ = 2; + numberOfConstraints_ = 0; + problemName_ = "BarrosF1F5"; + + lowerLimit_ = snew double[numberOfVariables_]; + if (lowerLimit_ == nullptr) + { + std::cout << "BarrosF1F5::BarrosF1F5. Error reserving memory for storing the array of lower limits" << std::endl; + } // if + + upperLimit_ = snew double[numberOfVariables_]; + if (upperLimit_ == nullptr) + { + std::cout << "BarrosF1F5::BarrosF1F5. Error reserving memory for storing the array of upper limits" << std::endl; + exit(-1) ; + } // if + + for (int i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = 0.0; + upperLimit_[i] = 1.0; + } // for + + if (solutionType.compare("BinaryReal") == 0) + { + //std::cout << "Selected solution type: BinaryReal" << std::endl; + solutionType_ = snew BinaryRealSolutionType(this) ; + } + else if (solutionType.compare("Real") == 0) + { + solutionType_ = snew RealSolutionType(this) ; + //std::cout << "Selected solution type: Real" << std::endl; + } + else if (solutionType.compare("ArrayReal") == 0) + { + solutionType_ = snew ArrayRealSolutionType(this) ; + } + else + { + std::cout << "Error: solution type " << solutionType << " invalid" << std::endl; + exit(-1) ; + } +} // BarrosF1F5 + + +/** + * Destructor + */ +BarrosF1F5::~BarrosF1F5() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; +} // ~BarrosF1F5 + + +/** + * Evaluates a solution + */ +void BarrosF1F5::evaluate(Solution *solution) +{ + VectorOfDouble fx(numberOfObjectives_); + VectorOfDouble x(numberOfVariables_); + Variable **variables = solution->getDecisionVariables(); + for (int i = 0; i < numberOfVariables_; i++) + { + x[i] = variables[i]->getValue() ; + } + fx[0] = x[0]; + double alpha = 2.0; + double q = 4.0; + double value1 = 1.0 + 10.0 * x[1]; + double value2 = x[0] / value1; + double value3 = 1.0 - pow(value2, alpha); + double value4 = -(value2 * sin(2.0 * PI * q * x[0])); + double value5 = value3 - value4; + fx[1] = value1 * value5; + solution->setObjective(0, fx[0]); + solution->setObjective(1, fx[1]); +} // evaluate + diff --git a/src/problems/SIGA/BarrosF1F5.h b/src/problems/SIGA/BarrosF1F5.h new file mode 100644 index 0000000..23d9b80 --- /dev/null +++ b/src/problems/SIGA/BarrosF1F5.h @@ -0,0 +1,46 @@ +// BarrosF1F2.h +// +// Authors: +// Sérgio Vieira +// +// +// Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo +// +// This program 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 3 of the License, or +// (at your option) any later version. +// +// This program 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 program. If not, see . + +#ifndef __BARROS_F1_F5__ +#define __BARROS_F1_F5__ + +#include +#include +#include +#include +#include +#include + +/** + * @class Barros F1 F5 + * @brief Class representing problem Barros + **/ +class BarrosF1F5 : public Problem +{ +protected: + const double PI = 3.141592653589793; +public: + BarrosF1F5(std::string solutionType); + ~BarrosF1F5(); + void evaluate(Solution *solution); +}; + +#endif /** __BARROS_F1_F2__ **/ From 3145e48458e0df5f715d65a37500c54d75a188de Mon Sep 17 00:00:00 2001 From: "joao.goncalves joao.goncalves" Date: Tue, 8 Aug 2017 08:47:25 -0300 Subject: [PATCH 23/29] Added the test functions F1 and F4. --- src/problems/SIGA/BarrosF1F4.cpp | 70 ++++++++++++++++++++++++++++++++ src/problems/SIGA/BarrosF1F4.h | 21 ++++++++++ 2 files changed, 91 insertions(+) create mode 100644 src/problems/SIGA/BarrosF1F4.cpp create mode 100644 src/problems/SIGA/BarrosF1F4.h diff --git a/src/problems/SIGA/BarrosF1F4.cpp b/src/problems/SIGA/BarrosF1F4.cpp new file mode 100644 index 0000000..9859d8b --- /dev/null +++ b/src/problems/SIGA/BarrosF1F4.cpp @@ -0,0 +1,70 @@ +#include "BarrosF1F4.h" + +BarrosF1F4::BarrosF1F4(string solutionType, int numberOfVariables, int numberOfObjectives) +{ + numberOfVariables_ = numberOfVariables; + numberOfObjectives_ = numberOfObjectives; + numberOfConstraints_ = 0; + problemName_ = "BarrosF1_F3"; + + lowerLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (lowerLimit_ == nullptr) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + upperLimit_ = snew double[numberOfVariables_];//(double *)malloc(sizeof(double)*numberOfVariables); + if (upperLimit_ == nullptr) + { + cout << "Impossible to reserve memory for storing the variable lower limits" << endl; + exit(-1); + } + + for (int i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = 0.0; + upperLimit_[i] = 1.0; + } + + if (solutionType.compare("BinaryReal") == 0) + solutionType_ = snew BinaryRealSolutionType(this); + else if (solutionType.compare("Real") == 0) + { + solutionType_ = snew RealSolutionType(this); + //cout << "Tipo seleccionado Real" << endl; + } + else if (solutionType.compare("ArrayReal") == 0) + solutionType_ = snew ArrayRealSolutionType(this); + else + { + cout << "Error: solution type " << solutionType << " invalid" << endl; + exit(-1); + } +} + +void BarrosF1F4::evaluate(Solution * solution) +{ + XReal * vars = snew XReal(solution); + double x1 = vars->getValue(0); + double x2 = vars->getValue(1); + delete vars; + double f1 = x1; + double gmin = 1.0; + double gmax = 2.0; + double xmin = 0.0; + double xmax = 1.0; + double num = x2 - xmin; + double den = xmax - xmin; + double g = gmin + (gmax - gmin) * pow(num / den, 0.25); + double f4 = 1 - pow(x1 / g, 2); + solution->setObjective(0, f1); + solution->setObjective(1, f4); +} + +BarrosF1F4::~BarrosF1F4() +{ + delete[] lowerLimit_; + delete[] upperLimit_; + delete solutionType_; +} diff --git a/src/problems/SIGA/BarrosF1F4.h b/src/problems/SIGA/BarrosF1F4.h new file mode 100644 index 0000000..4b9a0da --- /dev/null +++ b/src/problems/SIGA/BarrosF1F4.h @@ -0,0 +1,21 @@ +#ifndef __BARROS_F1_F4_H__ +#define __BARROS_F1_F4_H__ + +#include +#include +#include +#include +#include +#include +#include +#include + +class BarrosF1F4 : public Problem +{ +public: + BarrosF1F4(string solutionType, int numberOfVariables = 2, int numberOfObjectives = 2); + void evaluate(Solution *solution); + virtual ~BarrosF1F4(); +}; + +#endif /* __BARROS_F1_F4_H__ */ From 7b2326563949bcb275dbbc1d6b1ec6759136f485 Mon Sep 17 00:00:00 2001 From: Sergio Vieira Date: Tue, 8 Aug 2017 08:50:15 -0300 Subject: [PATCH 24/29] - Adds problem Barros F5 F3 --- src/problems/SIGA/BarrosF1F3.cpp | 2 +- src/problems/SIGA/BarrosF5F3.cpp | 112 +++++++++++++++++++++++++++++++ src/problems/SIGA/BarrosF5F3.h | 46 +++++++++++++ 3 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 src/problems/SIGA/BarrosF5F3.cpp create mode 100644 src/problems/SIGA/BarrosF5F3.h diff --git a/src/problems/SIGA/BarrosF1F3.cpp b/src/problems/SIGA/BarrosF1F3.cpp index b0e1c03..70c5dc5 100644 --- a/src/problems/SIGA/BarrosF1F3.cpp +++ b/src/problems/SIGA/BarrosF1F3.cpp @@ -53,7 +53,7 @@ void BarrosF1F3::evaluate(Solution * solution) double f1 = x1; double a = std::exp(-pow ( (x2 - 0.2) / 0.004, 2.0)); double b = std::exp(-pow ( (x2 - 0.6) / 0.4, 2.0)); - double f3 = (2 - a - 0.8 * b) / x1; + double f3 = (2.0 - a - 0.8 * b) / x1; solution->setObjective(0, f1); solution->setObjective(1, f3); } diff --git a/src/problems/SIGA/BarrosF5F3.cpp b/src/problems/SIGA/BarrosF5F3.cpp new file mode 100644 index 0000000..ac2e8ea --- /dev/null +++ b/src/problems/SIGA/BarrosF5F3.cpp @@ -0,0 +1,112 @@ +// BarrosF5F3.cpp +// +// Authors: +// Sérgio Vieira +// +// Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo +// +// This program 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 3 of the License, or +// (at your option) any later version. +// +// This program 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 program. If not, see . + +#include "problems/SIGA/BarrosF5F3.h" + +/** + * Class constructor + */ +BarrosF5F3::BarrosF5F3(std::string solutionType) +{ + numberOfVariables_ = 2; + numberOfObjectives_ = 2; + numberOfConstraints_ = 0; + problemName_ = "BarrosF5F3"; + + lowerLimit_ = snew double[numberOfVariables_]; + if (lowerLimit_ == nullptr) + { + std::cout << "BarrosF5F3::BarrosF5F3. Error reserving memory for storing the array of lower limits" << std::endl; + } // if + + upperLimit_ = snew double[numberOfVariables_]; + if (upperLimit_ == nullptr) + { + std::cout << "BarrosF5F3::BarrosF5F3. Error reserving memory for storing the array of upper limits" << std::endl; + exit(-1) ; + } // if + + for (int i = 0; i < numberOfVariables_; i++) + { + lowerLimit_[i] = -10.0; + upperLimit_[i] = 20.0; + } // for + + if (solutionType.compare("BinaryReal") == 0) + { + //std::cout << "Selected solution type: BinaryReal" << std::endl; + solutionType_ = snew BinaryRealSolutionType(this) ; + } + else if (solutionType.compare("Real") == 0) + { + solutionType_ = snew RealSolutionType(this) ; + //std::cout << "Selected solution type: Real" << std::endl; + } + else if (solutionType.compare("ArrayReal") == 0) + { + solutionType_ = snew ArrayRealSolutionType(this) ; + } + else + { + std::cout << "Error: solution type " << solutionType << " invalid" << std::endl; + exit(-1) ; + } +} // BarrosF5F3 + + +/** + * Destructor + */ +BarrosF5F3::~BarrosF5F3() +{ + delete [] lowerLimit_ ; + delete [] upperLimit_ ; + delete solutionType_ ; +} // ~BarrosF5F3 + + +/** + * Evaluates a solution + */ +void BarrosF5F3::evaluate(Solution *solution) +{ + VectorOfDouble fx(numberOfObjectives_); + VectorOfDouble x(numberOfVariables_); + Variable **variables = solution->getDecisionVariables(); + for (int i = 0; i < numberOfVariables_; i++) + { + x[i] = variables[i]->getValue(); + } + double alpha = 2.0; + double q = 4.0; + double value1 = 1.0 + 10.0 * x[1]; + double value2 = x[0] / value1; + double value3 = 1.0 - pow(value2, alpha); + double value4 = -(value2 * sin(2.0 * PI * q * x[0])); + double value5 = value3 - value4; + fx[0] = value1 * value5; + double a = std::exp(-pow((x[1] - 0.2) / 0.004, 2.0)); + double b = std::exp(-pow((x[1] - 0.6) / 0.4, 2.0)); + fx[1] = (2.0 - a - 0.8 * b) / x[0]; + solution->setObjective(0, fx[0]); + solution->setObjective(1, fx[1]); + +} // evaluate + diff --git a/src/problems/SIGA/BarrosF5F3.h b/src/problems/SIGA/BarrosF5F3.h new file mode 100644 index 0000000..d1c86ce --- /dev/null +++ b/src/problems/SIGA/BarrosF5F3.h @@ -0,0 +1,46 @@ +// BarrosF1F2.h +// +// Authors: +// Sérgio Vieira +// +// +// Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo +// +// This program 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 3 of the License, or +// (at your option) any later version. +// +// This program 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 program. If not, see . + +#ifndef __BARROS_F5_F3__ +#define __BARROS_F5_F3__ + +#include +#include +#include +#include +#include +#include + +/** + * @class Barros F5 F3 + * @brief Class representing problem Barros + **/ +class BarrosF5F3 : public Problem +{ +protected: + const double PI = 3.141592653589793; +public: + BarrosF5F3(std::string solutionType); + ~BarrosF5F3(); + void evaluate(Solution *solution); +}; + +#endif /** __BARROS_F5_F3__ **/ From e1c5391b0897fc4c983e5f0dd94c0245d8710d86 Mon Sep 17 00:00:00 2001 From: "joao.goncalves joao.goncalves" Date: Tue, 8 Aug 2017 09:58:39 -0300 Subject: [PATCH 25/29] Graphics of test of OMOPSO by functions Barros. --- src/problems/SIGA/graficos/f1f3.svg | 197 +++++++++++++++++++++++ src/problems/SIGA/graficos/f1f4.svg | 195 +++++++++++++++++++++++ src/problems/SIGA/graficos/f1f5.svg | 208 +++++++++++++++++++++++++ src/problems/SIGA/graficos/f5f3.svg | 203 ++++++++++++++++++++++++ src/problems/SIGA/graficos/genPlot.gnu | 12 ++ 5 files changed, 815 insertions(+) create mode 100644 src/problems/SIGA/graficos/f1f3.svg create mode 100644 src/problems/SIGA/graficos/f1f4.svg create mode 100644 src/problems/SIGA/graficos/f1f5.svg create mode 100644 src/problems/SIGA/graficos/f5f3.svg create mode 100644 src/problems/SIGA/graficos/genPlot.gnu diff --git a/src/problems/SIGA/graficos/f1f3.svg b/src/problems/SIGA/graficos/f1f3.svg new file mode 100644 index 0000000..dd878f3 --- /dev/null +++ b/src/problems/SIGA/graficos/f1f3.svg @@ -0,0 +1,197 @@ + + + + +Gnuplot +Produced by GNUPLOT 4.6 patchlevel 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + 2 + + + + + + + 4 + + + + + + + 6 + + + + + + + 8 + + + + + + + 10 + + + + + + + 12 + + + + + + + 14 + + + + + + + 0 + + + + + + + 0.2 + + + + + + + 0.4 + + + + + + + 0.6 + + + + + + + 0.8 + + + + + + + 1 + + + Function 3 + + + Function 1 + + + OMOPSO - It=100 PI=0.5 SIZE=100 ASIZE=50 + + + gnuplot_plot_1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/problems/SIGA/graficos/f1f4.svg b/src/problems/SIGA/graficos/f1f4.svg new file mode 100644 index 0000000..856f997 --- /dev/null +++ b/src/problems/SIGA/graficos/f1f4.svg @@ -0,0 +1,195 @@ + + + + +Gnuplot +Produced by GNUPLOT 4.6 patchlevel 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + 0.2 + + + + + + + 0.4 + + + + + + + 0.6 + + + + + + + 0.8 + + + + + + + 1 + + + + + + + 1.2 + + + + + + + 0 + + + + + + + 0.2 + + + + + + + 0.4 + + + + + + + 0.6 + + + + + + + 0.8 + + + + + + + 1 + + + Function 4 + + + Function 1 + + + OMOPSO - It=100 PI=0.5 SIZE=100 ASIZE=50 + + + gnuplot_plot_1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/problems/SIGA/graficos/f1f5.svg b/src/problems/SIGA/graficos/f1f5.svg new file mode 100644 index 0000000..777a745 --- /dev/null +++ b/src/problems/SIGA/graficos/f1f5.svg @@ -0,0 +1,208 @@ + + + + +Gnuplot +Produced by GNUPLOT 4.6 patchlevel 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -0.6 + + + + + + + -0.4 + + + + + + + -0.2 + + + + + + + 0 + + + + + + + 0.2 + + + + + + + 0.4 + + + + + + + 0.6 + + + + + + + 0.8 + + + + + + + 1 + + + + + + + 1.2 + + + + + + + 0 + + + + + + + 0.2 + + + + + + + 0.4 + + + + + + + 0.6 + + + + + + + 0.8 + + + + + + + 1 + + + Function 5 + + + Function 1 + + + OMOPSO - It=100 PI=0.5 SIZE=100 ASIZE=50 + + + gnuplot_plot_1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/problems/SIGA/graficos/f5f3.svg b/src/problems/SIGA/graficos/f5f3.svg new file mode 100644 index 0000000..155260f --- /dev/null +++ b/src/problems/SIGA/graficos/f5f3.svg @@ -0,0 +1,203 @@ + + + + +Gnuplot +Produced by GNUPLOT 4.6 patchlevel 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -2 + + + + + + + -1 + + + + + + + 0 + + + + + + + 1 + + + + + + + 2 + + + + + + + 3 + + + + + + + 4 + + + + + + + -2 + + + + + + + -1 + + + + + + + 0 + + + + + + + 1 + + + + + + + 2 + + + + + + + 3 + + + + + + + 4 + + + Function 3 + + + Function 5 + + + OMOPSO - It=100 PI=0.5 SIZE=100 ASIZE=50 + + + gnuplot_plot_1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/problems/SIGA/graficos/genPlot.gnu b/src/problems/SIGA/graficos/genPlot.gnu new file mode 100644 index 0000000..cf5d0c4 --- /dev/null +++ b/src/problems/SIGA/graficos/genPlot.gnu @@ -0,0 +1,12 @@ +# Scale font and line width (dpi) by changing the size! It will always display stretched. +set terminal svg size 400,300 enhanced fname 'arial' fsize 10 butt solid +set output 'out.svg' + +# Key means label... +set xlabel 'Function 1' +set ylabel 'Function 3' +set xrange[0:1] +set yrange[0:15] +set grid +set title 'OMOPSO - It=100 PI=0.5 SIZE=100 ASIZE=50' +plot "data.txt" notitle \ No newline at end of file From 93fa9b482821e9bb3539668d6cf5572a71225af2 Mon Sep 17 00:00:00 2001 From: Sergio Vieira Date: Tue, 8 Aug 2017 10:02:05 -0300 Subject: [PATCH 26/29] - Improvements on OMOPSO --- src/metaheuristics/omopso/OMOPSO.cpp | 16 ++++++++++------ src/problems/SIGA/BarrosF5F3.cpp | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/metaheuristics/omopso/OMOPSO.cpp b/src/metaheuristics/omopso/OMOPSO.cpp index 841fe2e..d70b42a 100644 --- a/src/metaheuristics/omopso/OMOPSO.cpp +++ b/src/metaheuristics/omopso/OMOPSO.cpp @@ -162,19 +162,23 @@ void OMOPSO::computeNewPositions() //particle.move(speed_[i]); for (int var = 0; var < particle->getNumberOfDecisionVariables(); var++) { - particle->setValue(var, particle->getValue(var) + speed[i][var]); + double oldPosition = particle->getValue(var); + double newPosition = oldPosition + speed[i][var]; + particle->setValue(var, newPosition); if (particle->getValue(var) < problem_->getLowerLimit(var)) { - //particle->setValue(var, problem_->getLowerLimit(var)); - double diff = (problem_->getLowerLimit(var) - particle->getValue(var)) / 2.0 + PseudoRandom::randDouble(); - particle->setValue(var, problem_->getLowerLimit(var) + diff); + particle->setValue(var, problem_->getLowerLimit(var)); + double diff = ((oldPosition - problem_->getLowerLimit(var)) / 2.0) * PseudoRandom::randDouble(); + newPosition = problem_->getLowerLimit(var) + diff; + particle->setValue(var, newPosition); speed[i][var] = speed[i][var] * -1.0; } if (particle->getValue(var) > problem_->getUpperLimit(var)) { //particle->setValue(var, problem_->getUpperLimit(var)); - double diff = (particle->getValue(var) - problem_->getUpperLimit(var)) / 2.0 + PseudoRandom::randDouble(); - particle->setValue(var, problem_->getUpperLimit(var) - diff); + double diff = ((problem_->getUpperLimit(var) - oldPosition) / 2.0) * PseudoRandom::randDouble(); + newPosition = problem_->getUpperLimit(var) - diff; + particle->setValue(var, newPosition); speed[i][var] = speed[i][var] * -1.0; } } diff --git a/src/problems/SIGA/BarrosF5F3.cpp b/src/problems/SIGA/BarrosF5F3.cpp index ac2e8ea..6201f5d 100644 --- a/src/problems/SIGA/BarrosF5F3.cpp +++ b/src/problems/SIGA/BarrosF5F3.cpp @@ -45,8 +45,8 @@ BarrosF5F3::BarrosF5F3(std::string solutionType) for (int i = 0; i < numberOfVariables_; i++) { - lowerLimit_[i] = -10.0; - upperLimit_[i] = 20.0; + lowerLimit_[i] = 0.0; + upperLimit_[i] = 1.0; } // for if (solutionType.compare("BinaryReal") == 0) From cd231283d5f1109481305dd8164d965728ac0ad2 Mon Sep 17 00:00:00 2001 From: "joao.goncalves joao.goncalves" Date: Tue, 8 Aug 2017 13:01:10 -0300 Subject: [PATCH 27/29] Graphic of OMOPSO on SIGA. --- src/problems/SIGA/graficos/omopso_no_siga.svg | 127 ++++++++++++++++++ .../SIGA/graficos/omopso_no_siga_scala.svg | 127 ++++++++++++++++++ 2 files changed, 254 insertions(+) create mode 100644 src/problems/SIGA/graficos/omopso_no_siga.svg create mode 100644 src/problems/SIGA/graficos/omopso_no_siga_scala.svg diff --git a/src/problems/SIGA/graficos/omopso_no_siga.svg b/src/problems/SIGA/graficos/omopso_no_siga.svg new file mode 100644 index 0000000..1b9df20 --- /dev/null +++ b/src/problems/SIGA/graficos/omopso_no_siga.svg @@ -0,0 +1,127 @@ + + + + +Gnuplot +Produced by GNUPLOT 4.6 patchlevel 3 + + + + + + + + + + + + + + + + + + + + + + + + + + 5e+09 + + + 5.2e+09 + + + 5.4e+09 + + + 5.6e+09 + + + 5.8e+09 + + + 6e+09 + + + 2.4e+08 + + + 2.5e+08 + + + 2.6e+08 + + + 2.7e+08 + + + 2.8e+08 + + + 2.9e+08 + + + 3e+08 + + + 3.1e+08 + + + Evaporação (m³) + + + Custo (R$) + + + OMOPSO - It=100 PI=0.5 SIZE=100 ASIZE=50 + + + gnuplot_plot_1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/problems/SIGA/graficos/omopso_no_siga_scala.svg b/src/problems/SIGA/graficos/omopso_no_siga_scala.svg new file mode 100644 index 0000000..f44a534 --- /dev/null +++ b/src/problems/SIGA/graficos/omopso_no_siga_scala.svg @@ -0,0 +1,127 @@ + + + + +Gnuplot +Produced by GNUPLOT 4.6 patchlevel 3 + + + + + + + + + + + + + + + + + + + + + + + + + + 5.00 + + + 5.20 + + + 5.40 + + + 5.60 + + + 5.80 + + + 6.00 + + + 2.20 + + + 2.40 + + + 2.60 + + + 2.80 + + + 3.00 + + + Evaporação (m³) + + + Custo (R$) + + + OMOPSO - It=100 PI=0.5 SIZE=100 ASIZE=50 + + + gnuplot_plot_1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 4f17749ab275fa874b8c01b74c66578a3595f0bd Mon Sep 17 00:00:00 2001 From: Sergio Vieira Date: Wed, 9 Aug 2017 10:55:09 -0300 Subject: [PATCH 28/29] - Adds true pareto fronts --- src/main/OMOPSO_main.cpp | 28 +- src/metaheuristics/omopso/OMOPSO.cpp | 4 +- src/problems/DTLZ/DTLZ1.txt | 1000 ++++++++++++++++++++++++++ src/problems/DTLZ/DTLZ2.txt | 1000 ++++++++++++++++++++++++++ src/problems/DTLZ/DTLZ3.txt | 1000 ++++++++++++++++++++++++++ src/problems/DTLZ/DTLZ4.txt | 1000 ++++++++++++++++++++++++++ src/problems/DTLZ/DTLZ7.txt | 1000 ++++++++++++++++++++++++++ src/problems/ZDT/ZDT1.txt | 1000 ++++++++++++++++++++++++++ src/problems/ZDT/ZDT2.txt | 1000 ++++++++++++++++++++++++++ src/problems/ZDT/ZDT3.txt | 1000 ++++++++++++++++++++++++++ src/problems/ZDT/ZDT4.txt | 1000 ++++++++++++++++++++++++++ src/problems/ZDT/ZDT6.txt | 1000 ++++++++++++++++++++++++++ 12 files changed, 10020 insertions(+), 12 deletions(-) create mode 100644 src/problems/DTLZ/DTLZ1.txt create mode 100644 src/problems/DTLZ/DTLZ2.txt create mode 100644 src/problems/DTLZ/DTLZ3.txt create mode 100644 src/problems/DTLZ/DTLZ4.txt create mode 100644 src/problems/DTLZ/DTLZ7.txt create mode 100644 src/problems/ZDT/ZDT1.txt create mode 100644 src/problems/ZDT/ZDT2.txt create mode 100644 src/problems/ZDT/ZDT3.txt create mode 100644 src/problems/ZDT/ZDT4.txt create mode 100644 src/problems/ZDT/ZDT6.txt diff --git a/src/main/OMOPSO_main.cpp b/src/main/OMOPSO_main.cpp index 4c7bf29..e62a61b 100644 --- a/src/main/OMOPSO_main.cpp +++ b/src/main/OMOPSO_main.cpp @@ -25,6 +25,8 @@ #include #include +#include "metaheuristics/smpso/SMPSO.h" +#include "operators/mutation/PolynomialMutation.h" #include #include @@ -35,7 +37,9 @@ #include #include "problems/SIGA/BarrosF1F2.h" #include "problems/SIGA/BarrosF1F3.h" +#include "problems/SIGA/BarrosF1F4.h" #include "problems/SIGA/BarrosF1F5.h" +#include "problems/SIGA/BarrosF5F3.h" /** * Method for configuring and running the OMOPSO algorithm @@ -59,30 +63,34 @@ int main(int argc, char ** argv) std::cout << "No problem selected." << std::endl; std::cout << "Default problem will be used: Kursawe" << std::endl; //problem = ProblemFactory::getProblem(const_cast("Kursawe")); - problem = snew BarrosF1F5("Real"); + problem = snew BarrosF1F3("Real"); } //indicators = snew QualityIndicator(problem, "paretofront.txt"); - algorithm = snew OMOPSO(problem); - int maxIterations = 250; + algorithm = snew SMPSO(problem); + int maxIterations = 100; double perturbationIndex = 0.5; double mutationProbability = 1.0 / problem->getNumberOfVariables(); - int swarmSize = 100; + int swarmSize = 150; int archiveSize = 100; // Algorithm parameters algorithm->setInputParameter("swarmSize",&swarmSize); algorithm->setInputParameter("archiveSize",&archiveSize); algorithm->setInputParameter("maxIterations",&maxIterations); parameters["probability"] = &mutationProbability; - parameters["perturbation"] = &perturbationIndex; - uniformMutation = snew UniformMutation(parameters); + //parameters["perturbation"] = &perturbationIndex; + parameters["distributionIndex"] = &perturbationIndex; + //uniformMutation = snew UniformMutation(parameters); + uniformMutation = snew PolynomialMutation(parameters); + parameters.clear(); parameters["probability"] = &mutationProbability; parameters["perturbation"] = &perturbationIndex; parameters["maxIterations"] = &maxIterations; nonUniformMutation = snew NonUniformMutation(parameters); // Add the operators to the algorithm - algorithm->addOperator("uniformMutation", uniformMutation); - algorithm->addOperator("nonUniformMutation", nonUniformMutation); + algorithm->addOperator("mutation", uniformMutation); + //algorithm->addOperator("uniformMutation", uniformMutation); + //algorithm->addOperator("nonUniformMutation", nonUniformMutation); // Execute the Algorithm t_ini = clock(); SolutionSet * population = algorithm->execute(); @@ -92,9 +100,9 @@ int main(int argc, char ** argv) // Print the results std::cout << "Total execution time: " << secs << "s" << std::endl; std::cout << "Variables values have been written to file VAR" << std::endl; - population->printVariablesToFile("variables.txt"); + //population->printVariablesToFile("variables.txt"); std::cout << "Objectives values have been written to file FUN" << std::endl; - population->printObjectivesToFile("objectives.txt"); + population->printObjectivesToFile("objectives-" + problem->getName() + ".txt"); if (indicators != nullptr) { std::cout << "Quality indicators" << std::endl ; diff --git a/src/metaheuristics/omopso/OMOPSO.cpp b/src/metaheuristics/omopso/OMOPSO.cpp index d70b42a..ecaf1a5 100644 --- a/src/metaheuristics/omopso/OMOPSO.cpp +++ b/src/metaheuristics/omopso/OMOPSO.cpp @@ -168,7 +168,7 @@ void OMOPSO::computeNewPositions() if (particle->getValue(var) < problem_->getLowerLimit(var)) { particle->setValue(var, problem_->getLowerLimit(var)); - double diff = ((oldPosition - problem_->getLowerLimit(var)) / 2.0) * PseudoRandom::randDouble(); + double diff = ((oldPosition - problem_->getLowerLimit(var))) * PseudoRandom::randDouble(); newPosition = problem_->getLowerLimit(var) + diff; particle->setValue(var, newPosition); speed[i][var] = speed[i][var] * -1.0; @@ -176,7 +176,7 @@ void OMOPSO::computeNewPositions() if (particle->getValue(var) > problem_->getUpperLimit(var)) { //particle->setValue(var, problem_->getUpperLimit(var)); - double diff = ((problem_->getUpperLimit(var) - oldPosition) / 2.0) * PseudoRandom::randDouble(); + double diff = ((problem_->getUpperLimit(var) - oldPosition)) * PseudoRandom::randDouble(); newPosition = problem_->getUpperLimit(var) - diff; particle->setValue(var, newPosition); speed[i][var] = speed[i][var] * -1.0; diff --git a/src/problems/DTLZ/DTLZ1.txt b/src/problems/DTLZ/DTLZ1.txt new file mode 100644 index 0000000..3714e31 --- /dev/null +++ b/src/problems/DTLZ/DTLZ1.txt @@ -0,0 +1,1000 @@ +0.0000000000 0.5000000000 +0.0005005005 0.4994994995 +0.0010010010 0.4989989990 +0.0015015015 0.4984984985 +0.0020020020 0.4979979980 +0.0025025025 0.4974974975 +0.0030030030 0.4969969970 +0.0035035035 0.4964964965 +0.0040040040 0.4959959960 +0.0045045045 0.4954954955 +0.0050050050 0.4949949950 +0.0055055055 0.4944944945 +0.0060060060 0.4939939940 +0.0065065065 0.4934934935 +0.0070070070 0.4929929930 +0.0075075075 0.4924924925 +0.0080080080 0.4919919920 +0.0085085085 0.4914914915 +0.0090090090 0.4909909910 +0.0095095095 0.4904904905 +0.0100100100 0.4899899900 +0.0105105105 0.4894894895 +0.0110110110 0.4889889890 +0.0115115115 0.4884884885 +0.0120120120 0.4879879880 +0.0125125125 0.4874874875 +0.0130130130 0.4869869870 +0.0135135135 0.4864864865 +0.0140140140 0.4859859860 +0.0145145145 0.4854854855 +0.0150150150 0.4849849850 +0.0155155155 0.4844844845 +0.0160160160 0.4839839840 +0.0165165165 0.4834834835 +0.0170170170 0.4829829830 +0.0175175175 0.4824824825 +0.0180180180 0.4819819820 +0.0185185185 0.4814814815 +0.0190190190 0.4809809810 +0.0195195195 0.4804804805 +0.0200200200 0.4799799800 +0.0205205205 0.4794794795 +0.0210210210 0.4789789790 +0.0215215215 0.4784784785 +0.0220220220 0.4779779780 +0.0225225225 0.4774774775 +0.0230230230 0.4769769770 +0.0235235235 0.4764764765 +0.0240240240 0.4759759760 +0.0245245245 0.4754754755 +0.0250250250 0.4749749750 +0.0255255255 0.4744744745 +0.0260260260 0.4739739740 +0.0265265265 0.4734734735 +0.0270270270 0.4729729730 +0.0275275275 0.4724724725 +0.0280280280 0.4719719720 +0.0285285285 0.4714714715 +0.0290290290 0.4709709710 +0.0295295295 0.4704704705 +0.0300300300 0.4699699700 +0.0305305305 0.4694694695 +0.0310310310 0.4689689690 +0.0315315315 0.4684684685 +0.0320320320 0.4679679680 +0.0325325325 0.4674674675 +0.0330330330 0.4669669670 +0.0335335335 0.4664664665 +0.0340340340 0.4659659660 +0.0345345345 0.4654654655 +0.0350350350 0.4649649650 +0.0355355355 0.4644644645 +0.0360360360 0.4639639640 +0.0365365365 0.4634634635 +0.0370370370 0.4629629630 +0.0375375375 0.4624624625 +0.0380380380 0.4619619620 +0.0385385385 0.4614614615 +0.0390390390 0.4609609610 +0.0395395395 0.4604604605 +0.0400400400 0.4599599600 +0.0405405405 0.4594594595 +0.0410410410 0.4589589590 +0.0415415415 0.4584584585 +0.0420420420 0.4579579580 +0.0425425425 0.4574574575 +0.0430430430 0.4569569570 +0.0435435435 0.4564564565 +0.0440440440 0.4559559560 +0.0445445445 0.4554554555 +0.0450450450 0.4549549550 +0.0455455455 0.4544544545 +0.0460460460 0.4539539540 +0.0465465465 0.4534534535 +0.0470470470 0.4529529530 +0.0475475475 0.4524524525 +0.0480480480 0.4519519520 +0.0485485485 0.4514514515 +0.0490490490 0.4509509510 +0.0495495495 0.4504504505 +0.0500500501 0.4499499499 +0.0505505506 0.4494494494 +0.0510510511 0.4489489489 +0.0515515516 0.4484484484 +0.0520520521 0.4479479479 +0.0525525526 0.4474474474 +0.0530530531 0.4469469469 +0.0535535536 0.4464464464 +0.0540540541 0.4459459459 +0.0545545546 0.4454454454 +0.0550550551 0.4449449449 +0.0555555556 0.4444444444 +0.0560560561 0.4439439439 +0.0565565566 0.4434434434 +0.0570570571 0.4429429429 +0.0575575576 0.4424424424 +0.0580580581 0.4419419419 +0.0585585586 0.4414414414 +0.0590590591 0.4409409409 +0.0595595596 0.4404404404 +0.0600600601 0.4399399399 +0.0605605606 0.4394394394 +0.0610610611 0.4389389389 +0.0615615616 0.4384384384 +0.0620620621 0.4379379379 +0.0625625626 0.4374374374 +0.0630630631 0.4369369369 +0.0635635636 0.4364364364 +0.0640640641 0.4359359359 +0.0645645646 0.4354354354 +0.0650650651 0.4349349349 +0.0655655656 0.4344344344 +0.0660660661 0.4339339339 +0.0665665666 0.4334334334 +0.0670670671 0.4329329329 +0.0675675676 0.4324324324 +0.0680680681 0.4319319319 +0.0685685686 0.4314314314 +0.0690690691 0.4309309309 +0.0695695696 0.4304304304 +0.0700700701 0.4299299299 +0.0705705706 0.4294294294 +0.0710710711 0.4289289289 +0.0715715716 0.4284284284 +0.0720720721 0.4279279279 +0.0725725726 0.4274274274 +0.0730730731 0.4269269269 +0.0735735736 0.4264264264 +0.0740740741 0.4259259259 +0.0745745746 0.4254254254 +0.0750750751 0.4249249249 +0.0755755756 0.4244244244 +0.0760760761 0.4239239239 +0.0765765766 0.4234234234 +0.0770770771 0.4229229229 +0.0775775776 0.4224224224 +0.0780780781 0.4219219219 +0.0785785786 0.4214214214 +0.0790790791 0.4209209209 +0.0795795796 0.4204204204 +0.0800800801 0.4199199199 +0.0805805806 0.4194194194 +0.0810810811 0.4189189189 +0.0815815816 0.4184184184 +0.0820820821 0.4179179179 +0.0825825826 0.4174174174 +0.0830830831 0.4169169169 +0.0835835836 0.4164164164 +0.0840840841 0.4159159159 +0.0845845846 0.4154154154 +0.0850850851 0.4149149149 +0.0855855856 0.4144144144 +0.0860860861 0.4139139139 +0.0865865866 0.4134134134 +0.0870870871 0.4129129129 +0.0875875876 0.4124124124 +0.0880880881 0.4119119119 +0.0885885886 0.4114114114 +0.0890890891 0.4109109109 +0.0895895896 0.4104104104 +0.0900900901 0.4099099099 +0.0905905906 0.4094094094 +0.0910910911 0.4089089089 +0.0915915916 0.4084084084 +0.0920920921 0.4079079079 +0.0925925926 0.4074074074 +0.0930930931 0.4069069069 +0.0935935936 0.4064064064 +0.0940940941 0.4059059059 +0.0945945946 0.4054054054 +0.0950950951 0.4049049049 +0.0955955956 0.4044044044 +0.0960960961 0.4039039039 +0.0965965966 0.4034034034 +0.0970970971 0.4029029029 +0.0975975976 0.4024024024 +0.0980980981 0.4019019019 +0.0985985986 0.4014014014 +0.0990990991 0.4009009009 +0.0995995996 0.4004004004 +0.1001001001 0.3998998999 +0.1006006006 0.3993993994 +0.1011011011 0.3988988989 +0.1016016016 0.3983983984 +0.1021021021 0.3978978979 +0.1026026026 0.3973973974 +0.1031031031 0.3968968969 +0.1036036036 0.3963963964 +0.1041041041 0.3958958959 +0.1046046046 0.3953953954 +0.1051051051 0.3948948949 +0.1056056056 0.3943943944 +0.1061061061 0.3938938939 +0.1066066066 0.3933933934 +0.1071071071 0.3928928929 +0.1076076076 0.3923923924 +0.1081081081 0.3918918919 +0.1086086086 0.3913913914 +0.1091091091 0.3908908909 +0.1096096096 0.3903903904 +0.1101101101 0.3898898899 +0.1106106106 0.3893893894 +0.1111111111 0.3888888889 +0.1116116116 0.3883883884 +0.1121121121 0.3878878879 +0.1126126126 0.3873873874 +0.1131131131 0.3868868869 +0.1136136136 0.3863863864 +0.1141141141 0.3858858859 +0.1146146146 0.3853853854 +0.1151151151 0.3848848849 +0.1156156156 0.3843843844 +0.1161161161 0.3838838839 +0.1166166166 0.3833833834 +0.1171171171 0.3828828829 +0.1176176176 0.3823823824 +0.1181181181 0.3818818819 +0.1186186186 0.3813813814 +0.1191191191 0.3808808809 +0.1196196196 0.3803803804 +0.1201201201 0.3798798799 +0.1206206206 0.3793793794 +0.1211211211 0.3788788789 +0.1216216216 0.3783783784 +0.1221221221 0.3778778779 +0.1226226226 0.3773773774 +0.1231231231 0.3768768769 +0.1236236236 0.3763763764 +0.1241241241 0.3758758759 +0.1246246246 0.3753753754 +0.1251251251 0.3748748749 +0.1256256256 0.3743743744 +0.1261261261 0.3738738739 +0.1266266266 0.3733733734 +0.1271271271 0.3728728729 +0.1276276276 0.3723723724 +0.1281281281 0.3718718719 +0.1286286286 0.3713713714 +0.1291291291 0.3708708709 +0.1296296296 0.3703703704 +0.1301301301 0.3698698699 +0.1306306306 0.3693693694 +0.1311311311 0.3688688689 +0.1316316316 0.3683683684 +0.1321321321 0.3678678679 +0.1326326326 0.3673673674 +0.1331331331 0.3668668669 +0.1336336336 0.3663663664 +0.1341341341 0.3658658659 +0.1346346346 0.3653653654 +0.1351351351 0.3648648649 +0.1356356356 0.3643643644 +0.1361361361 0.3638638639 +0.1366366366 0.3633633634 +0.1371371371 0.3628628629 +0.1376376376 0.3623623624 +0.1381381381 0.3618618619 +0.1386386386 0.3613613614 +0.1391391391 0.3608608609 +0.1396396396 0.3603603604 +0.1401401401 0.3598598599 +0.1406406406 0.3593593594 +0.1411411411 0.3588588589 +0.1416416416 0.3583583584 +0.1421421421 0.3578578579 +0.1426426426 0.3573573574 +0.1431431431 0.3568568569 +0.1436436436 0.3563563564 +0.1441441441 0.3558558559 +0.1446446446 0.3553553554 +0.1451451451 0.3548548549 +0.1456456456 0.3543543544 +0.1461461461 0.3538538539 +0.1466466466 0.3533533534 +0.1471471471 0.3528528529 +0.1476476476 0.3523523524 +0.1481481481 0.3518518519 +0.1486486486 0.3513513514 +0.1491491491 0.3508508509 +0.1496496496 0.3503503504 +0.1501501502 0.3498498498 +0.1506506507 0.3493493493 +0.1511511512 0.3488488488 +0.1516516517 0.3483483483 +0.1521521522 0.3478478478 +0.1526526527 0.3473473473 +0.1531531532 0.3468468468 +0.1536536537 0.3463463463 +0.1541541542 0.3458458458 +0.1546546547 0.3453453453 +0.1551551552 0.3448448448 +0.1556556557 0.3443443443 +0.1561561562 0.3438438438 +0.1566566567 0.3433433433 +0.1571571572 0.3428428428 +0.1576576577 0.3423423423 +0.1581581582 0.3418418418 +0.1586586587 0.3413413413 +0.1591591592 0.3408408408 +0.1596596597 0.3403403403 +0.1601601602 0.3398398398 +0.1606606607 0.3393393393 +0.1611611612 0.3388388388 +0.1616616617 0.3383383383 +0.1621621622 0.3378378378 +0.1626626627 0.3373373373 +0.1631631632 0.3368368368 +0.1636636637 0.3363363363 +0.1641641642 0.3358358358 +0.1646646647 0.3353353353 +0.1651651652 0.3348348348 +0.1656656657 0.3343343343 +0.1661661662 0.3338338338 +0.1666666667 0.3333333333 +0.1671671672 0.3328328328 +0.1676676677 0.3323323323 +0.1681681682 0.3318318318 +0.1686686687 0.3313313313 +0.1691691692 0.3308308308 +0.1696696697 0.3303303303 +0.1701701702 0.3298298298 +0.1706706707 0.3293293293 +0.1711711712 0.3288288288 +0.1716716717 0.3283283283 +0.1721721722 0.3278278278 +0.1726726727 0.3273273273 +0.1731731732 0.3268268268 +0.1736736737 0.3263263263 +0.1741741742 0.3258258258 +0.1746746747 0.3253253253 +0.1751751752 0.3248248248 +0.1756756757 0.3243243243 +0.1761761762 0.3238238238 +0.1766766767 0.3233233233 +0.1771771772 0.3228228228 +0.1776776777 0.3223223223 +0.1781781782 0.3218218218 +0.1786786787 0.3213213213 +0.1791791792 0.3208208208 +0.1796796797 0.3203203203 +0.1801801802 0.3198198198 +0.1806806807 0.3193193193 +0.1811811812 0.3188188188 +0.1816816817 0.3183183183 +0.1821821822 0.3178178178 +0.1826826827 0.3173173173 +0.1831831832 0.3168168168 +0.1836836837 0.3163163163 +0.1841841842 0.3158158158 +0.1846846847 0.3153153153 +0.1851851852 0.3148148148 +0.1856856857 0.3143143143 +0.1861861862 0.3138138138 +0.1866866867 0.3133133133 +0.1871871872 0.3128128128 +0.1876876877 0.3123123123 +0.1881881882 0.3118118118 +0.1886886887 0.3113113113 +0.1891891892 0.3108108108 +0.1896896897 0.3103103103 +0.1901901902 0.3098098098 +0.1906906907 0.3093093093 +0.1911911912 0.3088088088 +0.1916916917 0.3083083083 +0.1921921922 0.3078078078 +0.1926926927 0.3073073073 +0.1931931932 0.3068068068 +0.1936936937 0.3063063063 +0.1941941942 0.3058058058 +0.1946946947 0.3053053053 +0.1951951952 0.3048048048 +0.1956956957 0.3043043043 +0.1961961962 0.3038038038 +0.1966966967 0.3033033033 +0.1971971972 0.3028028028 +0.1976976977 0.3023023023 +0.1981981982 0.3018018018 +0.1986986987 0.3013013013 +0.1991991992 0.3008008008 +0.1996996997 0.3003003003 +0.2002002002 0.2997997998 +0.2007007007 0.2992992993 +0.2012012012 0.2987987988 +0.2017017017 0.2982982983 +0.2022022022 0.2977977978 +0.2027027027 0.2972972973 +0.2032032032 0.2967967968 +0.2037037037 0.2962962963 +0.2042042042 0.2957957958 +0.2047047047 0.2952952953 +0.2052052052 0.2947947948 +0.2057057057 0.2942942943 +0.2062062062 0.2937937938 +0.2067067067 0.2932932933 +0.2072072072 0.2927927928 +0.2077077077 0.2922922923 +0.2082082082 0.2917917918 +0.2087087087 0.2912912913 +0.2092092092 0.2907907908 +0.2097097097 0.2902902903 +0.2102102102 0.2897897898 +0.2107107107 0.2892892893 +0.2112112112 0.2887887888 +0.2117117117 0.2882882883 +0.2122122122 0.2877877878 +0.2127127127 0.2872872873 +0.2132132132 0.2867867868 +0.2137137137 0.2862862863 +0.2142142142 0.2857857858 +0.2147147147 0.2852852853 +0.2152152152 0.2847847848 +0.2157157157 0.2842842843 +0.2162162162 0.2837837838 +0.2167167167 0.2832832833 +0.2172172172 0.2827827828 +0.2177177177 0.2822822823 +0.2182182182 0.2817817818 +0.2187187187 0.2812812813 +0.2192192192 0.2807807808 +0.2197197197 0.2802802803 +0.2202202202 0.2797797798 +0.2207207207 0.2792792793 +0.2212212212 0.2787787788 +0.2217217217 0.2782782783 +0.2222222222 0.2777777778 +0.2227227227 0.2772772773 +0.2232232232 0.2767767768 +0.2237237237 0.2762762763 +0.2242242242 0.2757757758 +0.2247247247 0.2752752753 +0.2252252252 0.2747747748 +0.2257257257 0.2742742743 +0.2262262262 0.2737737738 +0.2267267267 0.2732732733 +0.2272272272 0.2727727728 +0.2277277277 0.2722722723 +0.2282282282 0.2717717718 +0.2287287287 0.2712712713 +0.2292292292 0.2707707708 +0.2297297297 0.2702702703 +0.2302302302 0.2697697698 +0.2307307307 0.2692692693 +0.2312312312 0.2687687688 +0.2317317317 0.2682682683 +0.2322322322 0.2677677678 +0.2327327327 0.2672672673 +0.2332332332 0.2667667668 +0.2337337337 0.2662662663 +0.2342342342 0.2657657658 +0.2347347347 0.2652652653 +0.2352352352 0.2647647648 +0.2357357357 0.2642642643 +0.2362362362 0.2637637638 +0.2367367367 0.2632632633 +0.2372372372 0.2627627628 +0.2377377377 0.2622622623 +0.2382382382 0.2617617618 +0.2387387387 0.2612612613 +0.2392392392 0.2607607608 +0.2397397397 0.2602602603 +0.2402402402 0.2597597598 +0.2407407407 0.2592592593 +0.2412412412 0.2587587588 +0.2417417417 0.2582582583 +0.2422422422 0.2577577578 +0.2427427427 0.2572572573 +0.2432432432 0.2567567568 +0.2437437437 0.2562562563 +0.2442442442 0.2557557558 +0.2447447447 0.2552552553 +0.2452452452 0.2547547548 +0.2457457457 0.2542542543 +0.2462462462 0.2537537538 +0.2467467467 0.2532532533 +0.2472472472 0.2527527528 +0.2477477477 0.2522522523 +0.2482482482 0.2517517518 +0.2487487487 0.2512512513 +0.2492492492 0.2507507508 +0.2497497497 0.2502502503 +0.2502502503 0.2497497497 +0.2507507508 0.2492492492 +0.2512512513 0.2487487487 +0.2517517518 0.2482482482 +0.2522522523 0.2477477477 +0.2527527528 0.2472472472 +0.2532532533 0.2467467467 +0.2537537538 0.2462462462 +0.2542542543 0.2457457457 +0.2547547548 0.2452452452 +0.2552552553 0.2447447447 +0.2557557558 0.2442442442 +0.2562562563 0.2437437437 +0.2567567568 0.2432432432 +0.2572572573 0.2427427427 +0.2577577578 0.2422422422 +0.2582582583 0.2417417417 +0.2587587588 0.2412412412 +0.2592592593 0.2407407407 +0.2597597598 0.2402402402 +0.2602602603 0.2397397397 +0.2607607608 0.2392392392 +0.2612612613 0.2387387387 +0.2617617618 0.2382382382 +0.2622622623 0.2377377377 +0.2627627628 0.2372372372 +0.2632632633 0.2367367367 +0.2637637638 0.2362362362 +0.2642642643 0.2357357357 +0.2647647648 0.2352352352 +0.2652652653 0.2347347347 +0.2657657658 0.2342342342 +0.2662662663 0.2337337337 +0.2667667668 0.2332332332 +0.2672672673 0.2327327327 +0.2677677678 0.2322322322 +0.2682682683 0.2317317317 +0.2687687688 0.2312312312 +0.2692692693 0.2307307307 +0.2697697698 0.2302302302 +0.2702702703 0.2297297297 +0.2707707708 0.2292292292 +0.2712712713 0.2287287287 +0.2717717718 0.2282282282 +0.2722722723 0.2277277277 +0.2727727728 0.2272272272 +0.2732732733 0.2267267267 +0.2737737738 0.2262262262 +0.2742742743 0.2257257257 +0.2747747748 0.2252252252 +0.2752752753 0.2247247247 +0.2757757758 0.2242242242 +0.2762762763 0.2237237237 +0.2767767768 0.2232232232 +0.2772772773 0.2227227227 +0.2777777778 0.2222222222 +0.2782782783 0.2217217217 +0.2787787788 0.2212212212 +0.2792792793 0.2207207207 +0.2797797798 0.2202202202 +0.2802802803 0.2197197197 +0.2807807808 0.2192192192 +0.2812812813 0.2187187187 +0.2817817818 0.2182182182 +0.2822822823 0.2177177177 +0.2827827828 0.2172172172 +0.2832832833 0.2167167167 +0.2837837838 0.2162162162 +0.2842842843 0.2157157157 +0.2847847848 0.2152152152 +0.2852852853 0.2147147147 +0.2857857858 0.2142142142 +0.2862862863 0.2137137137 +0.2867867868 0.2132132132 +0.2872872873 0.2127127127 +0.2877877878 0.2122122122 +0.2882882883 0.2117117117 +0.2887887888 0.2112112112 +0.2892892893 0.2107107107 +0.2897897898 0.2102102102 +0.2902902903 0.2097097097 +0.2907907908 0.2092092092 +0.2912912913 0.2087087087 +0.2917917918 0.2082082082 +0.2922922923 0.2077077077 +0.2927927928 0.2072072072 +0.2932932933 0.2067067067 +0.2937937938 0.2062062062 +0.2942942943 0.2057057057 +0.2947947948 0.2052052052 +0.2952952953 0.2047047047 +0.2957957958 0.2042042042 +0.2962962963 0.2037037037 +0.2967967968 0.2032032032 +0.2972972973 0.2027027027 +0.2977977978 0.2022022022 +0.2982982983 0.2017017017 +0.2987987988 0.2012012012 +0.2992992993 0.2007007007 +0.2997997998 0.2002002002 +0.3003003003 0.1996996997 +0.3008008008 0.1991991992 +0.3013013013 0.1986986987 +0.3018018018 0.1981981982 +0.3023023023 0.1976976977 +0.3028028028 0.1971971972 +0.3033033033 0.1966966967 +0.3038038038 0.1961961962 +0.3043043043 0.1956956957 +0.3048048048 0.1951951952 +0.3053053053 0.1946946947 +0.3058058058 0.1941941942 +0.3063063063 0.1936936937 +0.3068068068 0.1931931932 +0.3073073073 0.1926926927 +0.3078078078 0.1921921922 +0.3083083083 0.1916916917 +0.3088088088 0.1911911912 +0.3093093093 0.1906906907 +0.3098098098 0.1901901902 +0.3103103103 0.1896896897 +0.3108108108 0.1891891892 +0.3113113113 0.1886886887 +0.3118118118 0.1881881882 +0.3123123123 0.1876876877 +0.3128128128 0.1871871872 +0.3133133133 0.1866866867 +0.3138138138 0.1861861862 +0.3143143143 0.1856856857 +0.3148148148 0.1851851852 +0.3153153153 0.1846846847 +0.3158158158 0.1841841842 +0.3163163163 0.1836836837 +0.3168168168 0.1831831832 +0.3173173173 0.1826826827 +0.3178178178 0.1821821822 +0.3183183183 0.1816816817 +0.3188188188 0.1811811812 +0.3193193193 0.1806806807 +0.3198198198 0.1801801802 +0.3203203203 0.1796796797 +0.3208208208 0.1791791792 +0.3213213213 0.1786786787 +0.3218218218 0.1781781782 +0.3223223223 0.1776776777 +0.3228228228 0.1771771772 +0.3233233233 0.1766766767 +0.3238238238 0.1761761762 +0.3243243243 0.1756756757 +0.3248248248 0.1751751752 +0.3253253253 0.1746746747 +0.3258258258 0.1741741742 +0.3263263263 0.1736736737 +0.3268268268 0.1731731732 +0.3273273273 0.1726726727 +0.3278278278 0.1721721722 +0.3283283283 0.1716716717 +0.3288288288 0.1711711712 +0.3293293293 0.1706706707 +0.3298298298 0.1701701702 +0.3303303303 0.1696696697 +0.3308308308 0.1691691692 +0.3313313313 0.1686686687 +0.3318318318 0.1681681682 +0.3323323323 0.1676676677 +0.3328328328 0.1671671672 +0.3333333333 0.1666666667 +0.3338338338 0.1661661662 +0.3343343343 0.1656656657 +0.3348348348 0.1651651652 +0.3353353353 0.1646646647 +0.3358358358 0.1641641642 +0.3363363363 0.1636636637 +0.3368368368 0.1631631632 +0.3373373373 0.1626626627 +0.3378378378 0.1621621622 +0.3383383383 0.1616616617 +0.3388388388 0.1611611612 +0.3393393393 0.1606606607 +0.3398398398 0.1601601602 +0.3403403403 0.1596596597 +0.3408408408 0.1591591592 +0.3413413413 0.1586586587 +0.3418418418 0.1581581582 +0.3423423423 0.1576576577 +0.3428428428 0.1571571572 +0.3433433433 0.1566566567 +0.3438438438 0.1561561562 +0.3443443443 0.1556556557 +0.3448448448 0.1551551552 +0.3453453453 0.1546546547 +0.3458458458 0.1541541542 +0.3463463463 0.1536536537 +0.3468468468 0.1531531532 +0.3473473473 0.1526526527 +0.3478478478 0.1521521522 +0.3483483483 0.1516516517 +0.3488488488 0.1511511512 +0.3493493493 0.1506506507 +0.3498498498 0.1501501502 +0.3503503504 0.1496496496 +0.3508508509 0.1491491491 +0.3513513514 0.1486486486 +0.3518518519 0.1481481481 +0.3523523524 0.1476476476 +0.3528528529 0.1471471471 +0.3533533534 0.1466466466 +0.3538538539 0.1461461461 +0.3543543544 0.1456456456 +0.3548548549 0.1451451451 +0.3553553554 0.1446446446 +0.3558558559 0.1441441441 +0.3563563564 0.1436436436 +0.3568568569 0.1431431431 +0.3573573574 0.1426426426 +0.3578578579 0.1421421421 +0.3583583584 0.1416416416 +0.3588588589 0.1411411411 +0.3593593594 0.1406406406 +0.3598598599 0.1401401401 +0.3603603604 0.1396396396 +0.3608608609 0.1391391391 +0.3613613614 0.1386386386 +0.3618618619 0.1381381381 +0.3623623624 0.1376376376 +0.3628628629 0.1371371371 +0.3633633634 0.1366366366 +0.3638638639 0.1361361361 +0.3643643644 0.1356356356 +0.3648648649 0.1351351351 +0.3653653654 0.1346346346 +0.3658658659 0.1341341341 +0.3663663664 0.1336336336 +0.3668668669 0.1331331331 +0.3673673674 0.1326326326 +0.3678678679 0.1321321321 +0.3683683684 0.1316316316 +0.3688688689 0.1311311311 +0.3693693694 0.1306306306 +0.3698698699 0.1301301301 +0.3703703704 0.1296296296 +0.3708708709 0.1291291291 +0.3713713714 0.1286286286 +0.3718718719 0.1281281281 +0.3723723724 0.1276276276 +0.3728728729 0.1271271271 +0.3733733734 0.1266266266 +0.3738738739 0.1261261261 +0.3743743744 0.1256256256 +0.3748748749 0.1251251251 +0.3753753754 0.1246246246 +0.3758758759 0.1241241241 +0.3763763764 0.1236236236 +0.3768768769 0.1231231231 +0.3773773774 0.1226226226 +0.3778778779 0.1221221221 +0.3783783784 0.1216216216 +0.3788788789 0.1211211211 +0.3793793794 0.1206206206 +0.3798798799 0.1201201201 +0.3803803804 0.1196196196 +0.3808808809 0.1191191191 +0.3813813814 0.1186186186 +0.3818818819 0.1181181181 +0.3823823824 0.1176176176 +0.3828828829 0.1171171171 +0.3833833834 0.1166166166 +0.3838838839 0.1161161161 +0.3843843844 0.1156156156 +0.3848848849 0.1151151151 +0.3853853854 0.1146146146 +0.3858858859 0.1141141141 +0.3863863864 0.1136136136 +0.3868868869 0.1131131131 +0.3873873874 0.1126126126 +0.3878878879 0.1121121121 +0.3883883884 0.1116116116 +0.3888888889 0.1111111111 +0.3893893894 0.1106106106 +0.3898898899 0.1101101101 +0.3903903904 0.1096096096 +0.3908908909 0.1091091091 +0.3913913914 0.1086086086 +0.3918918919 0.1081081081 +0.3923923924 0.1076076076 +0.3928928929 0.1071071071 +0.3933933934 0.1066066066 +0.3938938939 0.1061061061 +0.3943943944 0.1056056056 +0.3948948949 0.1051051051 +0.3953953954 0.1046046046 +0.3958958959 0.1041041041 +0.3963963964 0.1036036036 +0.3968968969 0.1031031031 +0.3973973974 0.1026026026 +0.3978978979 0.1021021021 +0.3983983984 0.1016016016 +0.3988988989 0.1011011011 +0.3993993994 0.1006006006 +0.3998998999 0.1001001001 +0.4004004004 0.0995995996 +0.4009009009 0.0990990991 +0.4014014014 0.0985985986 +0.4019019019 0.0980980981 +0.4024024024 0.0975975976 +0.4029029029 0.0970970971 +0.4034034034 0.0965965966 +0.4039039039 0.0960960961 +0.4044044044 0.0955955956 +0.4049049049 0.0950950951 +0.4054054054 0.0945945946 +0.4059059059 0.0940940941 +0.4064064064 0.0935935936 +0.4069069069 0.0930930931 +0.4074074074 0.0925925926 +0.4079079079 0.0920920921 +0.4084084084 0.0915915916 +0.4089089089 0.0910910911 +0.4094094094 0.0905905906 +0.4099099099 0.0900900901 +0.4104104104 0.0895895896 +0.4109109109 0.0890890891 +0.4114114114 0.0885885886 +0.4119119119 0.0880880881 +0.4124124124 0.0875875876 +0.4129129129 0.0870870871 +0.4134134134 0.0865865866 +0.4139139139 0.0860860861 +0.4144144144 0.0855855856 +0.4149149149 0.0850850851 +0.4154154154 0.0845845846 +0.4159159159 0.0840840841 +0.4164164164 0.0835835836 +0.4169169169 0.0830830831 +0.4174174174 0.0825825826 +0.4179179179 0.0820820821 +0.4184184184 0.0815815816 +0.4189189189 0.0810810811 +0.4194194194 0.0805805806 +0.4199199199 0.0800800801 +0.4204204204 0.0795795796 +0.4209209209 0.0790790791 +0.4214214214 0.0785785786 +0.4219219219 0.0780780781 +0.4224224224 0.0775775776 +0.4229229229 0.0770770771 +0.4234234234 0.0765765766 +0.4239239239 0.0760760761 +0.4244244244 0.0755755756 +0.4249249249 0.0750750751 +0.4254254254 0.0745745746 +0.4259259259 0.0740740741 +0.4264264264 0.0735735736 +0.4269269269 0.0730730731 +0.4274274274 0.0725725726 +0.4279279279 0.0720720721 +0.4284284284 0.0715715716 +0.4289289289 0.0710710711 +0.4294294294 0.0705705706 +0.4299299299 0.0700700701 +0.4304304304 0.0695695696 +0.4309309309 0.0690690691 +0.4314314314 0.0685685686 +0.4319319319 0.0680680681 +0.4324324324 0.0675675676 +0.4329329329 0.0670670671 +0.4334334334 0.0665665666 +0.4339339339 0.0660660661 +0.4344344344 0.0655655656 +0.4349349349 0.0650650651 +0.4354354354 0.0645645646 +0.4359359359 0.0640640641 +0.4364364364 0.0635635636 +0.4369369369 0.0630630631 +0.4374374374 0.0625625626 +0.4379379379 0.0620620621 +0.4384384384 0.0615615616 +0.4389389389 0.0610610611 +0.4394394394 0.0605605606 +0.4399399399 0.0600600601 +0.4404404404 0.0595595596 +0.4409409409 0.0590590591 +0.4414414414 0.0585585586 +0.4419419419 0.0580580581 +0.4424424424 0.0575575576 +0.4429429429 0.0570570571 +0.4434434434 0.0565565566 +0.4439439439 0.0560560561 +0.4444444444 0.0555555556 +0.4449449449 0.0550550551 +0.4454454454 0.0545545546 +0.4459459459 0.0540540541 +0.4464464464 0.0535535536 +0.4469469469 0.0530530531 +0.4474474474 0.0525525526 +0.4479479479 0.0520520521 +0.4484484484 0.0515515516 +0.4489489489 0.0510510511 +0.4494494494 0.0505505506 +0.4499499499 0.0500500501 +0.4504504505 0.0495495495 +0.4509509510 0.0490490490 +0.4514514515 0.0485485485 +0.4519519520 0.0480480480 +0.4524524525 0.0475475475 +0.4529529530 0.0470470470 +0.4534534535 0.0465465465 +0.4539539540 0.0460460460 +0.4544544545 0.0455455455 +0.4549549550 0.0450450450 +0.4554554555 0.0445445445 +0.4559559560 0.0440440440 +0.4564564565 0.0435435435 +0.4569569570 0.0430430430 +0.4574574575 0.0425425425 +0.4579579580 0.0420420420 +0.4584584585 0.0415415415 +0.4589589590 0.0410410410 +0.4594594595 0.0405405405 +0.4599599600 0.0400400400 +0.4604604605 0.0395395395 +0.4609609610 0.0390390390 +0.4614614615 0.0385385385 +0.4619619620 0.0380380380 +0.4624624625 0.0375375375 +0.4629629630 0.0370370370 +0.4634634635 0.0365365365 +0.4639639640 0.0360360360 +0.4644644645 0.0355355355 +0.4649649650 0.0350350350 +0.4654654655 0.0345345345 +0.4659659660 0.0340340340 +0.4664664665 0.0335335335 +0.4669669670 0.0330330330 +0.4674674675 0.0325325325 +0.4679679680 0.0320320320 +0.4684684685 0.0315315315 +0.4689689690 0.0310310310 +0.4694694695 0.0305305305 +0.4699699700 0.0300300300 +0.4704704705 0.0295295295 +0.4709709710 0.0290290290 +0.4714714715 0.0285285285 +0.4719719720 0.0280280280 +0.4724724725 0.0275275275 +0.4729729730 0.0270270270 +0.4734734735 0.0265265265 +0.4739739740 0.0260260260 +0.4744744745 0.0255255255 +0.4749749750 0.0250250250 +0.4754754755 0.0245245245 +0.4759759760 0.0240240240 +0.4764764765 0.0235235235 +0.4769769770 0.0230230230 +0.4774774775 0.0225225225 +0.4779779780 0.0220220220 +0.4784784785 0.0215215215 +0.4789789790 0.0210210210 +0.4794794795 0.0205205205 +0.4799799800 0.0200200200 +0.4804804805 0.0195195195 +0.4809809810 0.0190190190 +0.4814814815 0.0185185185 +0.4819819820 0.0180180180 +0.4824824825 0.0175175175 +0.4829829830 0.0170170170 +0.4834834835 0.0165165165 +0.4839839840 0.0160160160 +0.4844844845 0.0155155155 +0.4849849850 0.0150150150 +0.4854854855 0.0145145145 +0.4859859860 0.0140140140 +0.4864864865 0.0135135135 +0.4869869870 0.0130130130 +0.4874874875 0.0125125125 +0.4879879880 0.0120120120 +0.4884884885 0.0115115115 +0.4889889890 0.0110110110 +0.4894894895 0.0105105105 +0.4899899900 0.0100100100 +0.4904904905 0.0095095095 +0.4909909910 0.0090090090 +0.4914914915 0.0085085085 +0.4919919920 0.0080080080 +0.4924924925 0.0075075075 +0.4929929930 0.0070070070 +0.4934934935 0.0065065065 +0.4939939940 0.0060060060 +0.4944944945 0.0055055055 +0.4949949950 0.0050050050 +0.4954954955 0.0045045045 +0.4959959960 0.0040040040 +0.4964964965 0.0035035035 +0.4969969970 0.0030030030 +0.4974974975 0.0025025025 +0.4979979980 0.0020020020 +0.4984984985 0.0015015015 +0.4989989990 0.0010010010 +0.4994994995 0.0005005005 +0.5000000000 0.0000000000 diff --git a/src/problems/DTLZ/DTLZ2.txt b/src/problems/DTLZ/DTLZ2.txt new file mode 100644 index 0000000..8e7a98f --- /dev/null +++ b/src/problems/DTLZ/DTLZ2.txt @@ -0,0 +1,1000 @@ +0.0000000000 1.0000000000 +0.0369034559 0.9993188355 +0.0554689064 0.9984604150 +0.0701154707 0.9975388818 +0.0825460836 0.9965872486 +0.0944933533 0.9955254925 +0.1052322500 0.9944476726 +0.1149755587 0.9933683209 +0.1240790518 0.9922723361 +0.1323880288 0.9911979670 +0.1401883532 0.9901248536 +0.1470407828 0.9891304303 +0.1540288320 0.9880663535 +0.1602847298 0.9870708209 +0.1664128767 0.9860561619 +0.1723284939 0.9850395374 +0.1779913023 0.9840320606 +0.1834929251 0.9830210305 +0.1888536496 0.9820052439 +0.1940749455 0.9809867051 +0.1990808625 0.9799830663 +0.2038239780 0.9790075516 +0.2085914966 0.9780028566 +0.2132114339 0.9770060821 +0.2178376178 0.9759850267 +0.2222055155 0.9749998507 +0.2265423242 0.9740013220 +0.2308470222 0.9729900577 +0.2350620607 0.9719803638 +0.2391443145 0.9709840353 +0.2431809463 0.9699809418 +0.2471722125 0.9689715669 +0.2510553101 0.9679727430 +0.2548588786 0.9669782583 +0.2586462636 0.9659721064 +0.2623167872 0.9649818149 +0.2660016761 0.9639725662 +0.2696215002 0.9629663788 +0.2731796937 0.9619630216 +0.2766542506 0.9609695238 +0.2801268556 0.9599629913 +0.2835449083 0.9589589590 +0.2869030002 0.9579596382 +0.2902298788 0.9569569570 +0.2935083252 0.9559565173 +0.2967507945 0.9549549550 +0.2999530859 0.9539539540 +0.3031103626 0.9529554597 +0.3062375464 0.9519551277 +0.3093316711 0.9509542141 +0.3124021328 0.9499499499 +0.3154217281 0.9489515970 +0.3184020635 0.9479557616 +0.3213660178 0.9469550584 +0.3243243243 0.9459459459 +0.3272221858 0.9449474277 +0.3300954464 0.9439475601 +0.3329379853 0.9429487250 +0.3357662943 0.9419453252 +0.3385707395 0.9409409409 +0.3413325513 0.9399425990 +0.3440838109 0.9389389389 +0.3468031496 0.9379379379 +0.3494914651 0.9369395476 +0.3521544727 0.9359418931 +0.3548192039 0.9349349349 +0.3574365344 0.9339374304 +0.3600347561 0.9329388910 +0.3626332503 0.9319319319 +0.3651931617 0.9309317669 +0.3677307710 0.9299322986 +0.3702561890 0.9289296822 +0.3727563119 0.9279292710 +0.3752418848 0.9269269269 +0.3777033956 0.9259266412 +0.3801498169 0.9249249249 +0.3825762444 0.9239239239 +0.3849807434 0.9229246054 +0.3873757477 0.9219219219 +0.3897494803 0.9209209209 +0.3921062878 0.9199199199 +0.3944464735 0.9189189189 +0.3967701220 0.9179180085 +0.3990771074 0.9169173694 +0.4013664253 0.9159175687 +0.4036459287 0.9149152771 +0.4059080659 0.9139139139 +0.4081514925 0.9129142124 +0.4103859950 0.9119119119 +0.4126030930 0.9109109109 +0.4148059255 0.9099099099 +0.4169947186 0.9089089089 +0.4191696921 0.9079079079 +0.4213310601 0.9069069069 +0.4234790309 0.9059059059 +0.4256138074 0.9049049049 +0.4277302163 0.9039064454 +0.4298445625 0.9029029029 +0.4319409211 0.9019019019 +0.4340248458 0.9009009009 +0.4360965147 0.8998998999 +0.4381524982 0.8989006554 +0.4402007852 0.8978993645 +0.4422397046 0.8968968969 +0.4442548729 0.8959004453 +0.4462716759 0.8948975312 +0.4482769549 0.8938947207 +0.4502691215 0.8928928929 +0.4522432984 0.8918946121 +0.4542173715 0.8908908909 +0.4561739547 0.8898906242 +0.4581228473 0.8888888889 +0.4600583792 0.8878886685 +0.4619863237 0.8868870484 +0.4639032196 0.8858858859 +0.4658097686 0.8848848849 +0.4677064034 0.8838838839 +0.4695932443 0.8828828829 +0.4714828031 0.8818752556 +0.4733427410 0.8808783398 +0.4751952113 0.8798803960 +0.4770406081 0.8788812538 +0.4788811021 0.8778797697 +0.4807150328 0.8768768769 +0.4825364754 0.8758758759 +0.4843489995 0.8748748749 +0.4861527050 0.8738738739 +0.4879476896 0.8728728729 +0.4897340493 0.8718718719 +0.4913662950 0.8709530206 +0.4930308523 0.8700118267 +0.4944409928 0.8692111968 +0.4958731824 0.8683949487 +0.4972038803 0.8676337369 +0.4984028062 0.8669455824 +0.4995380883 0.8662919244 +0.5006154830 0.8656697628 +0.5014559265 0.8651831909 +0.5022666475 0.8647127933 +0.5031221290 0.8642153223 +0.5038378201 0.8637982699 +0.5045948993 0.8633562344 +0.5052461589 0.8629752713 +0.5058661023 0.8626120139 +0.5064909416 0.8622452818 +0.5071004080 0.8618869858 +0.5077948321 0.8614780371 +0.5085028146 0.8610603275 +0.5091884560 0.8606550507 +0.5098623244 0.8602560143 +0.5104395997 0.8599136091 +0.5110220546 0.8595676004 +0.5116045741 0.8592210192 +0.5121824280 0.8588766853 +0.5127456864 0.8585405413 +0.5133164602 0.8581994009 +0.5139171891 0.8578398002 +0.5145203163 0.8574781887 +0.5151429121 0.8571042995 +0.5157917619 0.8567139886 +0.5164264251 0.8563315640 +0.5170709193 0.8559425591 +0.5176871000 0.8555700243 +0.5182871208 0.8552066770 +0.5188617486 0.8548581671 +0.5194335140 0.8545108686 +0.5200757604 0.8541201341 +0.5206731708 0.8537560830 +0.5212974684 0.8533750344 +0.5219719126 0.8529626735 +0.5226403853 0.8525532403 +0.5232753102 0.8521636872 +0.5238980396 0.8517809836 +0.5245113037 0.8514034839 +0.5251433508 0.8510137843 +0.5257516020 0.8506381446 +0.5263766517 0.8502515043 +0.5269964664 0.8498674746 +0.5276272887 0.8494759821 +0.5282513099 0.8490880717 +0.5288973285 0.8486858170 +0.5295458214 0.8482813348 +0.5301624602 0.8478960819 +0.5308048452 0.8474940804 +0.5314704031 0.8470768623 +0.5320732387 0.8466983339 +0.5326753017 0.8463196931 +0.5332994236 0.8459265481 +0.5339121576 0.8455399506 +0.5345345345 0.8451466331 +0.5351594859 0.8447510430 +0.5357890366 0.8443518865 +0.5364106345 0.8439571264 +0.5370230863 0.8435675461 +0.5376334769 0.8431786552 +0.5382034505 0.8428149535 +0.5387686643 0.8424537533 +0.5393584806 0.8420762611 +0.5399531958 0.8416950436 +0.5405405405 0.8413179684 +0.5411155897 0.8409482259 +0.5417229553 0.8405571008 +0.5423260737 0.8401680961 +0.5429669464 0.8397540682 +0.5435996064 0.8393446657 +0.5442146081 0.8389460413 +0.5448272687 0.8385482976 +0.5454368027 0.8381519517 +0.5460469885 0.8377545502 +0.5466735397 0.8373458312 +0.5473023850 0.8369349433 +0.5479290378 0.8365248171 +0.5485370289 0.8361262632 +0.5491247912 0.8357403686 +0.5497296206 0.8353426508 +0.5503275986 0.8349488213 +0.5509453978 0.8345412924 +0.5515814517 0.8341210356 +0.5521934967 0.8337159842 +0.5527651897 0.8333370537 +0.5533539033 0.8329462514 +0.5539294444 0.8325636136 +0.5545085146 0.8321780502 +0.5551259226 0.8317663194 +0.5557448952 0.8313528802 +0.5563254221 0.8309645147 +0.5568964635 0.8305819219 +0.5574640036 0.8302011110 +0.5580346413 0.8298176541 +0.5586159811 0.8294264197 +0.5592211739 0.8290185032 +0.5598067495 0.8286231974 +0.5603754700 0.8282386930 +0.5609717717 0.8278349300 +0.5615702950 0.8274290325 +0.5621655663 0.8270247131 +0.5627583491 0.8266214614 +0.5633666495 0.8262070069 +0.5639663209 0.8257977894 +0.5645982471 0.8253658700 +0.5652180106 0.8249415740 +0.5658627611 0.8244994455 +0.5665077826 0.8240563890 +0.5671386419 0.8236223411 +0.5677312926 0.8232139330 +0.5683074749 0.8228162699 +0.5688783385 0.8224216899 +0.5694700803 0.8220120606 +0.5700453735 0.8216132132 +0.5706220363 0.8212128176 +0.5711883696 0.8208190096 +0.5717565184 0.8204233564 +0.5723164842 0.8200328298 +0.5728546187 0.8196569928 +0.5734517451 0.8192393399 +0.5740430940 0.8188250889 +0.5746447945 0.8184029327 +0.5752422136 0.8179831268 +0.5758351001 0.8175658612 +0.5764334119 0.8171441254 +0.5770385373 0.8167169195 +0.5775944950 0.8163238324 +0.5781852812 0.8159054974 +0.5787508416 0.8155044227 +0.5793238635 0.8150974550 +0.5798826174 0.8147000368 +0.5804466148 0.8142983037 +0.5810258563 0.8138850990 +0.5816122879 0.8134661312 +0.5822313119 0.8130231850 +0.5828532438 0.8125774401 +0.5834723222 0.8121330243 +0.5840505573 0.8117172824 +0.5846356701 0.8112959591 +0.5851890576 0.8108968904 +0.5857589197 0.8104853410 +0.5863346929 0.8100689032 +0.5869043514 0.8096562741 +0.5874699609 0.8092459732 +0.5880140385 0.8088507220 +0.5885899410 0.8084317419 +0.5891712380 0.8080082007 +0.5897805084 0.8075635900 +0.5903722347 0.8071311074 +0.5909731865 0.8066912004 +0.5915521608 0.8062667307 +0.5921208026 0.8058492137 +0.5926768075 0.8054403776 +0.5932266964 0.8050354568 +0.5937712979 0.8046338582 +0.5943236246 0.8042259814 +0.5948727212 0.8038199087 +0.5954451305 0.8033959774 +0.5960177897 0.8029712289 +0.5965880254 0.8025476484 +0.5971592963 0.8021226682 +0.5977293661 0.8016979512 +0.5983197190 0.8012574579 +0.5989034379 0.8008212485 +0.5994961891 0.8003776104 +0.6000862860 0.7999352782 +0.6006803491 0.7994892859 +0.6012714947 0.7990447982 +0.6018623738 0.7985998266 +0.6024410249 0.7981633990 +0.6030140078 0.7977305976 +0.6035853496 0.7972983919 +0.6041675960 0.7968572745 +0.6047483389 0.7964166288 +0.6053359718 0.7959700756 +0.6059088682 0.7955340617 +0.6064873862 0.7950931080 +0.6070598467 0.7946561159 +0.6076082992 0.7942368379 +0.6081585019 0.7938156187 +0.6087008225 0.7933998416 +0.6092493277 0.7929787240 +0.6098030527 0.7925529869 +0.6103731258 0.7921140368 +0.6109665199 0.7916564353 +0.6115512499 0.7912048210 +0.6121478031 0.7907433637 +0.6127075106 0.7903097535 +0.6132794115 0.7898660415 +0.6138526102 0.7894206566 +0.6144516716 0.7889544621 +0.6150361282 0.7884989290 +0.6155715884 0.7880809727 +0.6161249092 0.7876484598 +0.6166805932 0.7872134691 +0.6172303276 0.7867825130 +0.6177829555 0.7863486631 +0.6183391364 0.7859113896 +0.6188979332 0.7854714179 +0.6194366405 0.7850466536 +0.6200040267 0.7845986279 +0.6205590118 0.7841597496 +0.6211145615 0.7837197851 +0.6216575860 0.7832891201 +0.6222173611 0.7828445284 +0.6227721219 0.7824032747 +0.6233246414 0.7819631650 +0.6239067112 0.7814988264 +0.6244931263 0.7810303037 +0.6250711759 0.7805677582 +0.6256102179 0.7801357928 +0.6261334159 0.7797159390 +0.6266502055 0.7793006608 +0.6271902164 0.7788661197 +0.6277586298 0.7784080566 +0.6283003785 0.7779708442 +0.6288407357 0.7775341338 +0.6293810109 0.7770968685 +0.6299102714 0.7766679149 +0.6304645970 0.7762180054 +0.6310086733 0.7757757758 +0.6316174909 0.7752801720 +0.6322085094 0.7747982967 +0.6328081424 0.7743086303 +0.6333784888 0.7738421609 +0.6339594258 0.7733663080 +0.6345165953 0.7729092381 +0.6350706268 0.7724540756 +0.6355849311 0.7720309549 +0.6361115568 0.7715971017 +0.6366398489 0.7711612690 +0.6371659714 0.7707266214 +0.6377124530 0.7702745143 +0.6382694686 0.7698130198 +0.6388120988 0.7693627898 +0.6393722504 0.7688973439 +0.6398901502 0.7684663920 +0.6404140943 0.7680298092 +0.6409410450 0.7675901099 +0.6414990653 0.7671238161 +0.6420366757 0.7666739248 +0.6425993635 0.7662023610 +0.6431668598 0.7657260544 +0.6437381844 0.7652458102 +0.6442759163 0.7647931378 +0.6447880509 0.7643614128 +0.6453596100 0.7638789000 +0.6458819044 0.7634373357 +0.6463891541 0.7630079039 +0.6469019786 0.7625731637 +0.6474281745 0.7621264717 +0.6479731485 0.7616631794 +0.6485163733 0.7612007052 +0.6490706137 0.7607281633 +0.6496196821 0.7602593430 +0.6501586847 0.7597984501 +0.6506855595 0.7593472873 +0.6512624614 0.7588525591 +0.6518486201 0.7583491125 +0.6524062744 0.7578694169 +0.6529552921 0.7573964527 +0.6534930151 0.7569325460 +0.6540287990 0.7564696491 +0.6545710321 0.7560005053 +0.6551098937 0.7555336043 +0.6556243355 0.7550872338 +0.6561249582 0.7546522638 +0.6566328735 0.7542103615 +0.6571569666 0.7537537538 +0.6576988639 0.7532809598 +0.6582401174 0.7528080418 +0.6587921703 0.7523249806 +0.6593218692 0.7518608068 +0.6598342919 0.7514111439 +0.6603684227 0.7509417729 +0.6608832360 0.7504887397 +0.6614001260 0.7500332482 +0.6619247438 0.7495702993 +0.6624657526 0.7490922016 +0.6630165568 0.7486047324 +0.6635694406 0.7481146954 +0.6641188509 0.7476270139 +0.6646432296 0.7471608778 +0.6651597065 0.7467011215 +0.6656823687 0.7462352069 +0.6661962464 0.7457764821 +0.6667464410 0.7452846324 +0.6672525404 0.7448315564 +0.6677715372 0.7443662903 +0.6682979983 0.7438936655 +0.6688166721 0.7434273731 +0.6693261124 0.7429687445 +0.6698347461 0.7425102107 +0.6703298317 0.7420632835 +0.6708735590 0.7415717550 +0.6714082569 0.7410876821 +0.6719538916 0.7405929837 +0.6725252041 0.7400742191 +0.6730822426 0.7395676404 +0.6736282685 0.7390703322 +0.6741566569 0.7385883847 +0.6746726115 0.7381171094 +0.6751854676 0.7376480085 +0.6756756757 0.7371990106 +0.6761607313 0.7367541418 +0.6766421534 0.7363120237 +0.6771586217 0.7358370751 +0.6776737898 0.7353626551 +0.6782096396 0.7348684813 +0.6787475351 0.7343716931 +0.6792935083 0.7338666974 +0.6798276103 0.7333719522 +0.6803548488 0.7328828553 +0.6808864775 0.7323889709 +0.6813888171 0.7319216351 +0.6819012364 0.7314442588 +0.6824316575 0.7309494051 +0.6829608407 0.7304549884 +0.6834903026 0.7299595922 +0.6840397074 0.7294447743 +0.6845764967 0.7289410265 +0.6850882559 0.7284600755 +0.6856044637 0.7279742573 +0.6860900097 0.7275166655 +0.6865771574 0.7270569489 +0.6870726626 0.7265887119 +0.6875677777 0.7261202043 +0.6880811093 0.7256337830 +0.6885950807 0.7251460645 +0.6891212070 0.7246460944 +0.6896491273 0.7241436882 +0.6901706210 0.7236466776 +0.6906770753 0.7231633133 +0.6911701553 0.7226920620 +0.6916916917 0.7221929130 +0.6922143667 0.7216919498 +0.6927315117 0.7211955718 +0.6932482963 0.7206988273 +0.6937626037 0.7202037556 +0.6942619006 0.7197224558 +0.6947787469 0.7192235347 +0.6952929865 0.7187264173 +0.6958120217 0.7182239418 +0.6963341710 0.7177177177 +0.6968524650 0.7172145021 +0.6973644298 0.7167167167 +0.6978707343 0.7162237347 +0.6983696435 0.7157372710 +0.6988439807 0.7152741367 +0.6993121350 0.7148164364 +0.6997858586 0.7143526805 +0.7002729450 0.7138752010 +0.7007571441 0.7133999054 +0.7012619608 0.7129036838 +0.7017843038 0.7123894939 +0.7023035839 0.7118775710 +0.7028540416 0.7113340961 +0.7033812989 0.7108127379 +0.7038927077 0.7103063114 +0.7044176915 0.7097856830 +0.7049148983 0.7092918906 +0.7053934668 0.7088159543 +0.7058758101 0.7083356131 +0.7063725126 0.7078402881 +0.7068638323 0.7073496466 +0.7073496466 0.7068638323 +0.7078402881 0.7063725126 +0.7083356131 0.7058758101 +0.7088159543 0.7053934668 +0.7092918906 0.7049148983 +0.7097856830 0.7044176915 +0.7103063114 0.7038927077 +0.7108127379 0.7033812989 +0.7113340961 0.7028540416 +0.7118775710 0.7023035839 +0.7123894939 0.7017843038 +0.7129036838 0.7012619608 +0.7133999054 0.7007571441 +0.7138752010 0.7002729450 +0.7143526805 0.6997858586 +0.7148164364 0.6993121350 +0.7152741367 0.6988439807 +0.7157372710 0.6983696435 +0.7162237347 0.6978707343 +0.7167167167 0.6973644298 +0.7172145021 0.6968524650 +0.7177177177 0.6963341710 +0.7182239418 0.6958120217 +0.7187264173 0.6952929865 +0.7192235347 0.6947787469 +0.7197224558 0.6942619006 +0.7202037556 0.6937626037 +0.7206988273 0.6932482963 +0.7211955718 0.6927315117 +0.7216919498 0.6922143667 +0.7221929130 0.6916916917 +0.7226920620 0.6911701553 +0.7231633133 0.6906770753 +0.7236466776 0.6901706210 +0.7241436882 0.6896491273 +0.7246460944 0.6891212070 +0.7251460645 0.6885950807 +0.7256337830 0.6880811093 +0.7261202043 0.6875677777 +0.7265887119 0.6870726626 +0.7270569489 0.6865771574 +0.7275166655 0.6860900097 +0.7279742573 0.6856044637 +0.7284600755 0.6850882559 +0.7289410265 0.6845764967 +0.7294447743 0.6840397074 +0.7299595922 0.6834903026 +0.7304549884 0.6829608407 +0.7309494051 0.6824316575 +0.7314442588 0.6819012364 +0.7319216351 0.6813888171 +0.7323889709 0.6808864775 +0.7328828553 0.6803548488 +0.7333719522 0.6798276103 +0.7338666974 0.6792935083 +0.7343716931 0.6787475351 +0.7348684813 0.6782096396 +0.7353626551 0.6776737898 +0.7358370751 0.6771586217 +0.7363120237 0.6766421534 +0.7367541418 0.6761607313 +0.7371990106 0.6756756757 +0.7376480085 0.6751854676 +0.7381171094 0.6746726115 +0.7385883847 0.6741566569 +0.7390703322 0.6736282685 +0.7395676404 0.6730822426 +0.7400742191 0.6725252041 +0.7405929837 0.6719538916 +0.7410876821 0.6714082569 +0.7415717550 0.6708735590 +0.7420632835 0.6703298317 +0.7425102107 0.6698347461 +0.7429687445 0.6693261124 +0.7434273731 0.6688166721 +0.7438936655 0.6682979983 +0.7443662903 0.6677715372 +0.7448315564 0.6672525404 +0.7452846324 0.6667464410 +0.7457764821 0.6661962464 +0.7462352069 0.6656823687 +0.7467011215 0.6651597065 +0.7471608778 0.6646432296 +0.7476270139 0.6641188509 +0.7481146954 0.6635694406 +0.7486047324 0.6630165568 +0.7490922016 0.6624657526 +0.7495702993 0.6619247438 +0.7500332482 0.6614001260 +0.7504887397 0.6608832360 +0.7509417729 0.6603684227 +0.7514111439 0.6598342919 +0.7518608068 0.6593218692 +0.7523249806 0.6587921703 +0.7528080418 0.6582401174 +0.7532809598 0.6576988639 +0.7537537538 0.6571569666 +0.7542103615 0.6566328735 +0.7546522638 0.6561249582 +0.7550872338 0.6556243355 +0.7555336043 0.6551098937 +0.7560005053 0.6545710321 +0.7564696491 0.6540287990 +0.7569325460 0.6534930151 +0.7573964527 0.6529552921 +0.7578694169 0.6524062744 +0.7583491125 0.6518486201 +0.7588525591 0.6512624614 +0.7593472873 0.6506855595 +0.7597984501 0.6501586847 +0.7602593430 0.6496196821 +0.7607281633 0.6490706137 +0.7612007052 0.6485163733 +0.7616631794 0.6479731485 +0.7621264717 0.6474281745 +0.7625731637 0.6469019786 +0.7630079039 0.6463891541 +0.7634373357 0.6458819044 +0.7638789000 0.6453596100 +0.7643614128 0.6447880509 +0.7647931378 0.6442759163 +0.7652458102 0.6437381844 +0.7657260544 0.6431668598 +0.7662023610 0.6425993635 +0.7666739248 0.6420366757 +0.7671238161 0.6414990653 +0.7675901099 0.6409410450 +0.7680298092 0.6404140943 +0.7684663920 0.6398901502 +0.7688973439 0.6393722504 +0.7693627898 0.6388120988 +0.7698130198 0.6382694686 +0.7702745143 0.6377124530 +0.7707266214 0.6371659714 +0.7711612690 0.6366398489 +0.7715971017 0.6361115568 +0.7720309549 0.6355849311 +0.7724540756 0.6350706268 +0.7729092381 0.6345165953 +0.7733663080 0.6339594258 +0.7738421609 0.6333784888 +0.7743086303 0.6328081424 +0.7747982967 0.6322085094 +0.7752801720 0.6316174909 +0.7757757758 0.6310086733 +0.7762180054 0.6304645970 +0.7766679149 0.6299102714 +0.7770968685 0.6293810109 +0.7775341338 0.6288407357 +0.7779708442 0.6283003785 +0.7784080566 0.6277586298 +0.7788661197 0.6271902164 +0.7793006608 0.6266502055 +0.7797159390 0.6261334159 +0.7801357928 0.6256102179 +0.7805677582 0.6250711759 +0.7810303037 0.6244931263 +0.7814988264 0.6239067112 +0.7819631650 0.6233246414 +0.7824032747 0.6227721219 +0.7828445284 0.6222173611 +0.7832891201 0.6216575860 +0.7837197851 0.6211145615 +0.7841597496 0.6205590118 +0.7845986279 0.6200040267 +0.7850466536 0.6194366405 +0.7854714179 0.6188979332 +0.7859113896 0.6183391364 +0.7863486631 0.6177829555 +0.7867825130 0.6172303276 +0.7872134691 0.6166805932 +0.7876484598 0.6161249092 +0.7880809727 0.6155715884 +0.7884989290 0.6150361282 +0.7889544621 0.6144516716 +0.7894206566 0.6138526102 +0.7898660415 0.6132794115 +0.7903097535 0.6127075106 +0.7907433637 0.6121478031 +0.7912048210 0.6115512499 +0.7916564353 0.6109665199 +0.7921140368 0.6103731258 +0.7925529869 0.6098030527 +0.7929787240 0.6092493277 +0.7933998416 0.6087008225 +0.7938156187 0.6081585019 +0.7942368379 0.6076082992 +0.7946561159 0.6070598467 +0.7950931080 0.6064873862 +0.7955340617 0.6059088682 +0.7959700756 0.6053359718 +0.7964166288 0.6047483389 +0.7968572745 0.6041675960 +0.7972983919 0.6035853496 +0.7977305976 0.6030140078 +0.7981633990 0.6024410249 +0.7985998266 0.6018623738 +0.7990447982 0.6012714947 +0.7994892859 0.6006803491 +0.7999352782 0.6000862860 +0.8003776104 0.5994961891 +0.8008212485 0.5989034379 +0.8012574579 0.5983197190 +0.8016979512 0.5977293661 +0.8021226682 0.5971592963 +0.8025476484 0.5965880254 +0.8029712289 0.5960177897 +0.8033959774 0.5954451305 +0.8038199087 0.5948727212 +0.8042259814 0.5943236246 +0.8046338582 0.5937712979 +0.8050354568 0.5932266964 +0.8054403776 0.5926768075 +0.8058492137 0.5921208026 +0.8062667307 0.5915521608 +0.8066912004 0.5909731865 +0.8071311074 0.5903722347 +0.8075635900 0.5897805084 +0.8080082007 0.5891712380 +0.8084317419 0.5885899410 +0.8088507220 0.5880140385 +0.8092459732 0.5874699609 +0.8096562741 0.5869043514 +0.8100689032 0.5863346929 +0.8104853410 0.5857589197 +0.8108968904 0.5851890576 +0.8112959591 0.5846356701 +0.8117172824 0.5840505573 +0.8121330243 0.5834723222 +0.8125774401 0.5828532438 +0.8130231850 0.5822313119 +0.8134661312 0.5816122879 +0.8138850990 0.5810258563 +0.8142983037 0.5804466148 +0.8147000368 0.5798826174 +0.8150974550 0.5793238635 +0.8155044227 0.5787508416 +0.8159054974 0.5781852812 +0.8163238324 0.5775944950 +0.8167169195 0.5770385373 +0.8171441254 0.5764334119 +0.8175658612 0.5758351001 +0.8179831268 0.5752422136 +0.8184029327 0.5746447945 +0.8188250889 0.5740430940 +0.8192393399 0.5734517451 +0.8196569928 0.5728546187 +0.8200328298 0.5723164842 +0.8204233564 0.5717565184 +0.8208190096 0.5711883696 +0.8212128176 0.5706220363 +0.8216132132 0.5700453735 +0.8220120606 0.5694700803 +0.8224216899 0.5688783385 +0.8228162699 0.5683074749 +0.8232139330 0.5677312926 +0.8236223411 0.5671386419 +0.8240563890 0.5665077826 +0.8244994455 0.5658627611 +0.8249415740 0.5652180106 +0.8253658700 0.5645982471 +0.8257977894 0.5639663209 +0.8262070069 0.5633666495 +0.8266214614 0.5627583491 +0.8270247131 0.5621655663 +0.8274290325 0.5615702950 +0.8278349300 0.5609717717 +0.8282386930 0.5603754700 +0.8286231974 0.5598067495 +0.8290185032 0.5592211739 +0.8294264197 0.5586159811 +0.8298176541 0.5580346413 +0.8302011110 0.5574640036 +0.8305819219 0.5568964635 +0.8309645147 0.5563254221 +0.8313528802 0.5557448952 +0.8317663194 0.5551259226 +0.8321780502 0.5545085146 +0.8325636136 0.5539294444 +0.8329462514 0.5533539033 +0.8333370537 0.5527651897 +0.8337159842 0.5521934967 +0.8341210356 0.5515814517 +0.8345412924 0.5509453978 +0.8349488213 0.5503275986 +0.8353426508 0.5497296206 +0.8357403686 0.5491247912 +0.8361262632 0.5485370289 +0.8365248171 0.5479290378 +0.8369349433 0.5473023850 +0.8373458312 0.5466735397 +0.8377545502 0.5460469885 +0.8381519517 0.5454368027 +0.8385482976 0.5448272687 +0.8389460413 0.5442146081 +0.8393446657 0.5435996064 +0.8397540682 0.5429669464 +0.8401680961 0.5423260737 +0.8405571008 0.5417229553 +0.8409482259 0.5411155897 +0.8413179684 0.5405405405 +0.8416950436 0.5399531958 +0.8420762611 0.5393584806 +0.8424537533 0.5387686643 +0.8428149535 0.5382034505 +0.8431786552 0.5376334769 +0.8435675461 0.5370230863 +0.8439571264 0.5364106345 +0.8443518865 0.5357890366 +0.8447510430 0.5351594859 +0.8451466331 0.5345345345 +0.8455399506 0.5339121576 +0.8459265481 0.5332994236 +0.8463196931 0.5326753017 +0.8466983339 0.5320732387 +0.8470768623 0.5314704031 +0.8474940804 0.5308048452 +0.8478960819 0.5301624602 +0.8482813348 0.5295458214 +0.8486858170 0.5288973285 +0.8490880717 0.5282513099 +0.8494759821 0.5276272887 +0.8498674746 0.5269964664 +0.8502515043 0.5263766517 +0.8506381446 0.5257516020 +0.8510137843 0.5251433508 +0.8514034839 0.5245113037 +0.8517809836 0.5238980396 +0.8521636872 0.5232753102 +0.8525532403 0.5226403853 +0.8529626735 0.5219719126 +0.8533750344 0.5212974684 +0.8537560830 0.5206731708 +0.8541201341 0.5200757604 +0.8545108686 0.5194335140 +0.8548581671 0.5188617486 +0.8552066770 0.5182871208 +0.8555700243 0.5176871000 +0.8559425591 0.5170709193 +0.8563315640 0.5164264251 +0.8567139886 0.5157917619 +0.8571042995 0.5151429121 +0.8574781887 0.5145203163 +0.8578398002 0.5139171891 +0.8581994009 0.5133164602 +0.8585405413 0.5127456864 +0.8588766853 0.5121824280 +0.8592210192 0.5116045741 +0.8595676004 0.5110220546 +0.8599136091 0.5104395997 +0.8602560143 0.5098623244 +0.8606550507 0.5091884560 +0.8610603275 0.5085028146 +0.8614780371 0.5077948321 +0.8618869858 0.5071004080 +0.8622452818 0.5064909416 +0.8626120139 0.5058661023 +0.8629752713 0.5052461589 +0.8633562344 0.5045948993 +0.8637982699 0.5038378201 +0.8642153223 0.5031221290 +0.8647127933 0.5022666475 +0.8651831909 0.5014559265 +0.8656697628 0.5006154830 +0.8662919244 0.4995380883 +0.8669455824 0.4984028062 +0.8676337369 0.4972038803 +0.8683949487 0.4958731824 +0.8692111968 0.4944409928 +0.8700118267 0.4930308523 +0.8709530206 0.4913662950 +0.8718718719 0.4897340493 +0.8728728729 0.4879476896 +0.8738738739 0.4861527050 +0.8748748749 0.4843489995 +0.8758758759 0.4825364754 +0.8768768769 0.4807150328 +0.8778797697 0.4788811021 +0.8788812538 0.4770406081 +0.8798803960 0.4751952113 +0.8808783398 0.4733427410 +0.8818752556 0.4714828031 +0.8828828829 0.4695932443 +0.8838838839 0.4677064034 +0.8848848849 0.4658097686 +0.8858858859 0.4639032196 +0.8868870484 0.4619863237 +0.8878886685 0.4600583792 +0.8888888889 0.4581228473 +0.8898906242 0.4561739547 +0.8908908909 0.4542173715 +0.8918946121 0.4522432984 +0.8928928929 0.4502691215 +0.8938947207 0.4482769549 +0.8948975312 0.4462716759 +0.8959004453 0.4442548729 +0.8968968969 0.4422397046 +0.8978993645 0.4402007852 +0.8989006554 0.4381524982 +0.8998998999 0.4360965147 +0.9009009009 0.4340248458 +0.9019019019 0.4319409211 +0.9029029029 0.4298445625 +0.9039064454 0.4277302163 +0.9049049049 0.4256138074 +0.9059059059 0.4234790309 +0.9069069069 0.4213310601 +0.9079079079 0.4191696921 +0.9089089089 0.4169947186 +0.9099099099 0.4148059255 +0.9109109109 0.4126030930 +0.9119119119 0.4103859950 +0.9129142124 0.4081514925 +0.9139139139 0.4059080659 +0.9149152771 0.4036459287 +0.9159175687 0.4013664253 +0.9169173694 0.3990771074 +0.9179180085 0.3967701220 +0.9189189189 0.3944464735 +0.9199199199 0.3921062878 +0.9209209209 0.3897494803 +0.9219219219 0.3873757477 +0.9229246054 0.3849807434 +0.9239239239 0.3825762444 +0.9249249249 0.3801498169 +0.9259266412 0.3777033956 +0.9269269269 0.3752418848 +0.9279292710 0.3727563119 +0.9289296822 0.3702561890 +0.9299322986 0.3677307710 +0.9309317669 0.3651931617 +0.9319319319 0.3626332503 +0.9329388910 0.3600347561 +0.9339374304 0.3574365344 +0.9349349349 0.3548192039 +0.9359418931 0.3521544727 +0.9369395476 0.3494914651 +0.9379379379 0.3468031496 +0.9389389389 0.3440838109 +0.9399425990 0.3413325513 +0.9409409409 0.3385707395 +0.9419453252 0.3357662943 +0.9429487250 0.3329379853 +0.9439475601 0.3300954464 +0.9449474277 0.3272221858 +0.9459459459 0.3243243243 +0.9469550584 0.3213660178 +0.9479557616 0.3184020635 +0.9489515970 0.3154217281 +0.9499499499 0.3124021328 +0.9509542141 0.3093316711 +0.9519551277 0.3062375464 +0.9529554597 0.3031103626 +0.9539539540 0.2999530859 +0.9549549550 0.2967507945 +0.9559565173 0.2935083252 +0.9569569570 0.2902298788 +0.9579596382 0.2869030002 +0.9589589590 0.2835449083 +0.9599629913 0.2801268556 +0.9609695238 0.2766542506 +0.9619630216 0.2731796937 +0.9629663788 0.2696215002 +0.9639725662 0.2660016761 +0.9649818149 0.2623167872 +0.9659721064 0.2586462636 +0.9669782583 0.2548588786 +0.9679727430 0.2510553101 +0.9689715669 0.2471722125 +0.9699809418 0.2431809463 +0.9709840353 0.2391443145 +0.9719803638 0.2350620607 +0.9729900577 0.2308470222 +0.9740013220 0.2265423242 +0.9749998507 0.2222055155 +0.9759850267 0.2178376178 +0.9770060821 0.2132114339 +0.9780028566 0.2085914966 +0.9790075516 0.2038239780 +0.9799830663 0.1990808625 +0.9809867051 0.1940749455 +0.9820052439 0.1888536496 +0.9830210305 0.1834929251 +0.9840320606 0.1779913023 +0.9850395374 0.1723284939 +0.9860561619 0.1664128767 +0.9870708209 0.1602847298 +0.9880663535 0.1540288320 +0.9891304303 0.1470407828 +0.9901248536 0.1401883532 +0.9911979670 0.1323880288 +0.9922723361 0.1240790518 +0.9933683209 0.1149755587 +0.9944476726 0.1052322500 +0.9955254925 0.0944933533 +0.9965872486 0.0825460836 +0.9975388818 0.0701154707 +0.9984604150 0.0554689064 +0.9993188355 0.0369034559 +1.0000000000 0.0000000000 diff --git a/src/problems/DTLZ/DTLZ3.txt b/src/problems/DTLZ/DTLZ3.txt new file mode 100644 index 0000000..b893913 --- /dev/null +++ b/src/problems/DTLZ/DTLZ3.txt @@ -0,0 +1,1000 @@ +0.0000000000 1.0000000000 +0.0023789418 0.9999971703 +0.0035957625 0.9999935352 +0.0046461501 0.9999892066 +0.0056164443 0.9999842277 +0.0065159141 0.9999787712 +0.0074534964 0.9999722223 +0.0083258899 0.9999653392 +0.0091587956 0.9999580574 +0.0099918644 0.9999500801 +0.0108327355 0.9999413242 +0.0117233814 0.9999312788 +0.0126708842 0.9999197211 +0.0135594612 0.9999080663 +0.0144810937 0.9998951435 +0.0154426100 0.9998807558 +0.0163588209 0.9998661855 +0.0172796659 0.9998506954 +0.0182956723 0.9998326202 +0.0192861105 0.9998140057 +0.0202946195 0.9997940430 +0.0212767154 0.9997736251 +0.0222383250 0.9997526979 +0.0232425368 0.9997298558 +0.0241988150 0.9997071658 +0.0251821942 0.9996828783 +0.0261513463 0.9996579951 +0.0271274637 0.9996319826 +0.0281038746 0.9996050081 +0.0291089804 0.9995762438 +0.0301146996 0.9995464496 +0.0311420800 0.9995149678 +0.0321305605 0.9994836802 +0.0331494292 0.9994504066 +0.0341224678 0.9994176590 +0.0351196254 0.9993831157 +0.0361104817 0.9993478039 +0.0371030349 0.9993114453 +0.0381098792 0.9992735547 +0.0391060032 0.9992350677 +0.0400819542 0.9991963956 +0.0410766009 0.9991560003 +0.0420738233 0.9991145046 +0.0430885441 0.9990712574 +0.0440880109 0.9990276509 +0.0450918416 0.9989828456 +0.0460950834 0.9989370567 +0.0471008766 0.9988901378 +0.0481098764 0.9988420495 +0.0491071431 0.9987935164 +0.0500806316 0.9987451779 +0.0510749448 0.9986948233 +0.0520726250 0.9986433005 +0.0530671044 0.9985909485 +0.0540624909 0.9985375542 +0.0550624603 0.9984829120 +0.0560756802 0.9984265211 +0.0570766944 0.9983697967 +0.0580787531 0.9983120046 +0.0590846125 0.9982529782 +0.0600803499 0.9981935441 +0.0610750549 0.9981331763 +0.0620820036 0.9980710520 +0.0630804729 0.9980084438 +0.0640708640 0.9979453514 +0.0650811265 0.9978799762 +0.0660806623 0.9978142844 +0.0670828705 0.9977474072 +0.0680916171 0.9976790725 +0.0690876065 0.9976105967 +0.0700892996 0.9975407210 +0.0710876698 0.9974700713 +0.0720852865 0.9973984718 +0.0730871962 0.9973255545 +0.0740941746 0.9972512488 +0.0750929511 0.9971765384 +0.0760929028 0.9971007322 +0.0770905309 0.9970240970 +0.0780853028 0.9969466814 +0.0790890122 0.9968675580 +0.0800843181 0.9967880928 +0.0810920505 0.9967066165 +0.0820960362 0.9966244232 +0.0831026587 0.9965409917 +0.0840977867 0.9964575065 +0.0850989512 0.9963725049 +0.0860976797 0.9962867005 +0.0871044729 0.9961991823 +0.0881031458 0.9961113571 +0.0891070246 0.9960220571 +0.0901066082 0.9959321258 +0.0911009665 0.9958416611 +0.0921012781 0.9957496445 +0.0930979201 0.9956569576 +0.0941009818 0.9955626576 +0.0951016757 0.9954675642 +0.0961036555 0.9953713314 +0.0971077489 0.9952738744 +0.0981081000 0.9951757637 +0.0991041628 0.9950770648 +0.1001077606 0.9949766009 +0.1011117730 0.9948750722 +0.1021127434 0.9947728322 +0.1031140974 0.9946695345 +0.1041165595 0.9945651020 +0.1051226787 0.9944592613 +0.1061153429 0.9943538274 +0.1071120699 0.9942469535 +0.1081102128 0.9941389148 +0.1091150101 0.9940291316 +0.1101122560 0.9939191572 +0.1111111111 0.9938079900 +0.1121136994 0.9936953851 +0.1131139276 0.9935820245 +0.1141231545 0.9934666102 +0.1151229650 0.9933512485 +0.1161257655 0.9932345174 +0.1171251493 0.9931171630 +0.1181284450 0.9929983235 +0.1191229956 0.9928795052 +0.1201258342 0.9927586736 +0.1211211211 0.9926377355 +0.1221221221 0.9925150816 +0.1231288797 0.9923906887 +0.1241286609 0.9922661314 +0.1251279986 0.9921406070 +0.1261333960 0.9920132894 +0.1271359168 0.9918853052 +0.1281380543 0.9917563406 +0.1291448225 0.9916257433 +0.1301428579 0.9914952529 +0.1311375140 0.9913641876 +0.1321343226 0.9912318199 +0.1331352793 0.9910978748 +0.1341341341 0.9909631850 +0.1351420164 0.9908262388 +0.1361438408 0.9906890807 +0.1371434507 0.9905511970 +0.1381422984 0.9904123916 +0.1391432443 0.9902722644 +0.1401403250 0.9901316525 +0.1411430141 0.9899892169 +0.1421455635 0.9898457651 +0.1431449617 0.9897017328 +0.1441476716 0.9895561878 +0.1451516891 0.9894094133 +0.1461565556 0.9892614726 +0.1471579737 0.9891130020 +0.1481567787 0.9889638866 +0.1491583681 0.9888133197 +0.1501545067 0.9886625431 +0.1511624053 0.9885089414 +0.1521608817 0.9883557386 +0.1531664898 0.9882003979 +0.1541589451 0.9880460615 +0.1551583027 0.9878896199 +0.1561619849 0.9877314587 +0.1571610807 0.9875729820 +0.1581629812 0.9874130196 +0.1591635308 0.9872522324 +0.1601631179 0.9870905610 +0.1611652964 0.9869274275 +0.1621621622 0.9867641224 +0.1631631632 0.9865990990 +0.1641641642 0.9864330323 +0.1651651652 0.9862659217 +0.1661661662 0.9860977666 +0.1671671672 0.9859285665 +0.1681710294 0.9857578328 +0.1691691692 0.9855870292 +0.1701726043 0.9854142706 +0.1711754161 0.9852405680 +0.1721785211 0.9850657627 +0.1731774838 0.9848906331 +0.1741768392 0.9847143894 +0.1751792598 0.9845365544 +0.1761813346 0.9843577283 +0.1771811334 0.9841782592 +0.1781785649 0.9839981702 +0.1791819245 0.9838159573 +0.1801815240 0.9836333760 +0.1811811812 0.9834497341 +0.1821849176 0.9832642858 +0.1831859705 0.9830782778 +0.1841861550 0.9828913777 +0.1851863886 0.9827034148 +0.1861889937 0.9825139483 +0.1871879123 0.9823241245 +0.1881881882 0.9821329879 +0.1891901325 0.9819404736 +0.1901908766 0.9817471316 +0.1911911912 0.9815528149 +0.1921921922 0.9813573056 +0.1931958360 0.9811602157 +0.1941991204 0.9809621306 +0.1951970208 0.9807640507 +0.1961969398 0.9805645113 +0.1971971972 0.9803638434 +0.1981997319 0.9801616531 +0.1992018002 0.9799584903 +0.2002040952 0.9797542142 +0.2012014977 0.9795498749 +0.2022030700 0.9793436161 +0.2032032032 0.9791365881 +0.2042060303 0.9789279326 +0.2052074063 0.9787185093 +0.2062097106 0.9785078208 +0.2072096854 0.9782965533 +0.2082098806 0.9780841710 +0.2092092092 0.9778709050 +0.2102102102 0.9776562113 +0.2112112112 0.9774404454 +0.2122138358 0.9772232539 +0.2132132132 0.9770056938 +0.2142177690 0.9767859271 +0.2152194718 0.9765657064 +0.2162268763 0.9763431456 +0.2172247210 0.9761216218 +0.2182252142 0.9758984352 +0.2192262943 0.9756740398 +0.2202286523 0.9754482768 +0.2212286337 0.9752219704 +0.2222264292 0.9749950842 +0.2232287358 0.9747660907 +0.2242272055 0.9745368953 +0.2252294622 0.9743057474 +0.2262295232 0.9740740233 +0.2272287819 0.9738414043 +0.2282282282 0.9736076601 +0.2292304065 0.9733721902 +0.2302302302 0.9731361884 +0.2312329865 0.9728984047 +0.2322325765 0.9726602852 +0.2332332332 0.9724208240 +0.2342342342 0.9721801909 +0.2352352352 0.9719384672 +0.2362373060 0.9716953922 +0.2372398441 0.9714511086 +0.2382404413 0.9712062047 +0.2392410008 0.9709602173 +0.2402405576 0.9707133843 +0.2412412412 0.9704651789 +0.2422450093 0.9702151078 +0.2432457261 0.9699646987 +0.2442479682 0.9697128080 +0.2452518361 0.9694594044 +0.2462527863 0.9692056362 +0.2472490611 0.9689519605 +0.2482482482 0.9686964474 +0.2492504764 0.9684390533 +0.2502502503 0.9681811877 +0.2512512513 0.9679219022 +0.2522522523 0.9676615117 +0.2532532533 0.9674000154 +0.2542542543 0.9671374123 +0.2552575598 0.9668730931 +0.2562597600 0.9666079533 +0.2572592603 0.9663424201 +0.2582593220 0.9660756299 +0.2592592593 0.9658077637 +0.2602609197 0.9655383233 +0.2612612613 0.9652681251 +0.2622648187 0.9649959403 +0.2632641986 0.9647237748 +0.2642660612 0.9644498167 +0.2652652653 0.9641754711 +0.2662678984 0.9638990644 +0.2672685868 0.9636220745 +0.2682693526 0.9633439440 +0.2692712328 0.9630643816 +0.2702722259 0.9627839446 +0.2712735368 0.9625022952 +0.2722722723 0.9622202501 +0.2732732733 0.9619364418 +0.2742761494 0.9616509730 +0.2752786807 0.9613644720 +0.2762795701 0.9610773117 +0.2772772773 0.9607899414 +0.2782792613 0.9605002097 +0.2792800783 0.9602096843 +0.2802823235 0.9599176106 +0.2812817558 0.9596252257 +0.2822831454 0.9593311346 +0.2832842485 0.9590359923 +0.2842880068 0.9587389265 +0.2852925352 0.9584404882 +0.2862915788 0.9581425426 +0.2872909969 0.9578433500 +0.2882899977 0.9575431464 +0.2892909832 0.9572412063 +0.2902902903 0.9569386330 +0.2912929148 0.9566339100 +0.2922922923 0.9563290312 +0.2932942328 0.9560222241 +0.2942942943 0.9557148468 +0.2952952953 0.9554060334 +0.2962969827 0.9550958581 +0.2972984499 0.9547845996 +0.2982993300 0.9544723724 +0.2993011060 0.9541587121 +0.3003006996 0.9538445837 +0.3013025019 0.9535286059 +0.3023030034 0.9532118831 +0.3033033033 0.9528940687 +0.3043043043 0.9525748739 +0.3053053053 0.9522545198 +0.3063067368 0.9519328669 +0.3073073073 0.9516103293 +0.3083083083 0.9512864905 +0.3093093093 0.9509614877 +0.3103108868 0.9506351317 +0.3113113113 0.9503079856 +0.3123123123 0.9499794838 +0.3133133133 0.9496498132 +0.3143154356 0.9493186014 +0.3153153153 0.9489869609 +0.3163163163 0.9486537767 +0.3173173173 0.9483194188 +0.3183187733 0.9479837333 +0.3193204370 0.9476468005 +0.3203210408 0.9473090472 +0.3213221831 0.9469699333 +0.3223223223 0.9466299808 +0.3233233233 0.9462885546 +0.3243243243 0.9459459459 +0.3253253253 0.9456021535 +0.3263272005 0.9452568742 +0.3273293622 0.9449103072 +0.3283288453 0.9445634808 +0.3293293293 0.9442151200 +0.3303303303 0.9438653892 +0.3313313313 0.9435144667 +0.3323335732 0.9431619141 +0.3333333333 0.9428090416 +0.3343343343 0.9424545362 +0.3353353353 0.9420988339 +0.3363363750 0.9417419194 +0.3373389033 0.9413832717 +0.3383385080 0.9410244705 +0.3393393393 0.9406640276 +0.3403411793 0.9403020162 +0.3413413413 0.9399394069 +0.3423423423 0.9395752874 +0.3433433433 0.9392099598 +0.3443451363 0.9388431323 +0.3453453453 0.9384756749 +0.3463466065 0.9381066188 +0.3473473473 0.9377365410 +0.3483483483 0.9373651520 +0.3493493493 0.9369925465 +0.3503510626 0.9366184564 +0.3513524033 0.9362432850 +0.3523523524 0.9358674157 +0.3533533739 0.9354899215 +0.3543548782 0.9351110203 +0.3553564497 0.9347308670 +0.3563595686 0.9343488952 +0.3573589347 0.9339671256 +0.3583583584 0.9335841082 +0.3593593594 0.9331992557 +0.3603603604 0.9328131703 +0.3613624468 0.9324254297 +0.3623623624 0.9320372945 +0.3633653536 0.9316467248 +0.3643651514 0.9312561605 +0.3653670219 0.9308635449 +0.3663671270 0.9304703801 +0.3673673674 0.9300759202 +0.3683693446 0.9296795286 +0.3693724147 0.9292814532 +0.3703712393 0.9288838168 +0.3713719774 0.9284841702 +0.3723723724 0.9280834102 +0.3733733734 0.9276811543 +0.3743743744 0.9272776433 +0.3753753754 0.9268728756 +0.3763774806 0.9264664010 +0.3773777160 0.9260594255 +0.3783792359 0.9256506651 +0.3793793794 0.9252412045 +0.3803803804 0.9248301283 +0.3813813814 0.9244177854 +0.3823823824 0.9240041740 +0.3833845378 0.9235888134 +0.3843877245 0.9231717485 +0.3853870001 0.9227550380 +0.3863891830 0.9223358386 +0.3873891583 0.9219162869 +0.3883907844 0.9214947632 +0.3893942570 0.9210711767 +0.3903917375 0.9206488425 +0.3913933222 0.9202234877 +0.3923929945 0.9197976614 +0.3933933934 0.9193702399 +0.3943943944 0.9189412722 +0.3953975550 0.9185100835 +0.3963971073 0.9180791542 +0.3973973974 0.9176466142 +0.3983997498 0.9172118836 +0.3994003620 0.9167766090 +0.4004012107 0.9163399317 +0.4014014014 0.9159022409 +0.4024024024 0.9154628920 +0.4034043517 0.9150218189 +0.4044067845 0.9145792216 +0.4054054054 0.9141370014 +0.4064064064 0.9136924170 +0.4074074074 0.9132465190 +0.4084084084 0.9127993054 +0.4094094094 0.9123507744 +0.4104115392 0.9119004159 +0.4114128541 0.9114491009 +0.4124129881 0.9109969963 +0.4134134134 0.9105434364 +0.4144144144 0.9100882886 +0.4154154154 0.9096318116 +0.4164164164 0.9091740032 +0.4174186674 0.9087142874 +0.4184201372 0.9082535928 +0.4194194194 0.9077925703 +0.4204204800 0.9073293889 +0.4214229047 0.9068642321 +0.4224241375 0.9063982834 +0.4234234234 0.9059318984 +0.4244244244 0.9054633664 +0.4254254254 0.9049934847 +0.4264264264 0.9045222512 +0.4274274274 0.9040496636 +0.4284284284 0.9035757200 +0.4294294294 0.9031004181 +0.4304304634 0.9026237401 +0.4314314314 0.9021457310 +0.4324330951 0.9016660237 +0.4334351935 0.9011847386 +0.4344353208 0.9007030321 +0.4354354354 0.9002199629 +0.4364364364 0.8997350927 +0.4374374374 0.8992488467 +0.4384384384 0.8987612229 +0.4394394394 0.8982722188 +0.4404404404 0.8977818323 +0.4414414414 0.8972900611 +0.4424437834 0.8967962414 +0.4434434434 0.8963023555 +0.4444444444 0.8958064165 +0.4454463415 0.8953086378 +0.4464477251 0.8948097165 +0.4474474972 0.8943102019 +0.4484484484 0.8938086983 +0.4494494494 0.8933057665 +0.4504518510 0.8928007224 +0.4514526015 0.8922951017 +0.4524531394 0.8917881793 +0.4534534535 0.8912799591 +0.4544544545 0.8907699753 +0.4554554555 0.8902585737 +0.4564564565 0.8897457521 +0.4574574575 0.8892315079 +0.4584589324 0.8887155941 +0.4594594595 0.8881987419 +0.4604604605 0.8876802151 +0.4614614615 0.8871602559 +0.4624625580 0.8866388117 +0.4634641023 0.8861156955 +0.4644644647 0.8855917575 +0.4654654700 0.8850660406 +0.4664664665 0.8845388831 +0.4674674675 0.8840102753 +0.4684701105 0.8834793464 +0.4694714720 0.8829476412 +0.4704729272 0.8824144291 +0.4714726513 0.8818806830 +0.4724724725 0.8813454276 +0.4734734735 0.8808080778 +0.4744744745 0.8802692617 +0.4754756000 0.8797289093 +0.4764764765 0.8791872197 +0.4774778479 0.8786437872 +0.4784784785 0.8780992801 +0.4794798626 0.8775528824 +0.4804804805 0.8770054207 +0.4814814815 0.8764562642 +0.4824824825 0.8759056194 +0.4834834835 0.8753534836 +0.4844852498 0.8747994300 +0.4854857936 0.8742445563 +0.4864864865 0.8736881014 +0.4874879901 0.8731296922 +0.4884884885 0.8725703391 +0.4894900830 0.8720088639 +0.4904904905 0.8714465438 +0.4914914915 0.8708823766 +0.4924924925 0.8703166923 +0.4934934935 0.8697494880 +0.4944944945 0.8691807608 +0.4954954955 0.8686105076 +0.4964967353 0.8680385889 +0.4974980710 0.8674650825 +0.4984992707 0.8668901182 +0.4995004652 0.8663136183 +0.5005005005 0.8657362468 +0.5015018074 0.8651565969 +0.5025047918 0.8645744238 +0.5035043517 0.8639926897 +0.5045045045 0.8634090600 +0.5055055055 0.8628233793 +0.5065065065 0.8622361387 +0.5075086402 0.8616466678 +0.5085100628 0.8610560470 +0.5095106642 0.8604643416 +0.5105105105 0.8598715129 +0.5115122540 0.8592759824 +0.5125125125 0.8586797567 +0.5135135135 0.8580815063 +0.5145154430 0.8574811128 +0.5155159317 0.8568799940 +0.5165165165 0.8562772262 +0.5175175303 0.8556726043 +0.5185196118 0.8550657356 +0.5195197838 0.8544584216 +0.5205205205 0.8538491598 +0.5215220771 0.8532377881 +0.5225238556 0.8526246655 +0.5235243128 0.8520107358 +0.5245245245 0.8513953389 +0.5255260434 0.8507775136 +0.5265265265 0.8501587010 +0.5275275275 0.8495379378 +0.5285306324 0.8489142304 +0.5295307330 0.8482907537 +0.5305305305 0.8476658281 +0.5315315315 0.8470385062 +0.5325325325 0.8464095355 +0.5335347999 0.8457781135 +0.5345345345 0.8451466331 +0.5355355355 0.8445126939 +0.5365365365 0.8438770911 +0.5375375375 0.8432398210 +0.5385393670 0.8426003502 +0.5395395395 0.8419602635 +0.5405405405 0.8413179684 +0.5415415415 0.8406739908 +0.5425425425 0.8400283266 +0.5435435435 0.8393809721 +0.5445445445 0.8387319232 +0.5455455455 0.8380811761 +0.5465465465 0.8374287268 +0.5475475475 0.8367745713 +0.5485485485 0.8361187056 +0.5495495495 0.8354611257 +0.5505505506 0.8348018276 +0.5515517276 0.8341406907 +0.5525525526 0.8334780601 +0.5535542448 0.8328131231 +0.5545552970 0.8321468756 +0.5555555556 0.8314794193 +0.5565565566 0.8308097251 +0.5575579506 0.8301380197 +0.5585585586 0.8294650907 +0.5595595596 0.8287901419 +0.5605605606 0.8281134330 +0.5615615616 0.8274349597 +0.5625625626 0.8267547177 +0.5635646789 0.8260719416 +0.5645645646 0.8253889098 +0.5655655656 0.8247033352 +0.5665665666 0.8240159741 +0.5675675676 0.8233268223 +0.5685685686 0.8226358750 +0.5695695696 0.8219431279 +0.5705717985 0.8212477231 +0.5715715716 0.8205522156 +0.5725727651 0.8198539069 +0.5735747959 0.8191531929 +0.5745745746 0.8184522333 +0.5755755756 0.8177485902 +0.5765765766 0.8170431147 +0.5775775776 0.8163358022 +0.5785785786 0.8156266477 +0.5795807837 0.8149147901 +0.5805810088 0.8142024885 +0.5815815816 0.8134880847 +0.5825827335 0.8127714061 +0.5835835836 0.8120530777 +0.5845851229 0.8113323820 +0.5855855856 0.8106105859 +0.5865869027 0.8098862918 +0.5875886488 0.8091597987 +0.5885907985 0.8084311176 +0.5895895896 0.8077029874 +0.5905905906 0.8069713466 +0.5915915916 0.8062377991 +0.5925932684 0.8055018425 +0.5935954680 0.8047635804 +0.5945945946 0.8040256638 +0.5955966761 0.8032836357 +0.5965965966 0.8025412768 +0.5975981234 0.8017957863 +0.5985985986 0.8010491357 +0.5995995996 0.8003001438 +0.6006006006 0.7995491971 +0.6016028124 0.7987953781 +0.6026031993 0.7980409665 +0.6036036036 0.7972845726 +0.6046053195 0.7965252084 +0.6056056056 0.7957649467 +0.6066066875 0.7950020922 +0.6076076076 0.7942373670 +0.6086086086 0.7934705801 +0.6096099182 0.7927015502 +0.6106113274 0.7919304306 +0.6116116116 0.7911581615 +0.6126129903 0.7903830236 +0.6136141937 0.7896059911 +0.6146146146 0.7888275322 +0.6156156717 0.7880465372 +0.6166172857 0.7872630583 +0.6176189981 0.7864774461 +0.6186186186 0.7856914182 +0.6196196196 0.7849022404 +0.6206206206 0.7841109904 +0.6216216216 0.7833176620 +0.6226231309 0.7825218444 +0.6236236236 0.7817247444 +0.6246246246 0.7809251426 +0.6256256256 0.7801234367 +0.6266270828 0.7793192536 +0.6276276276 0.7785136871 +0.6286295540 0.7777048822 +0.6296302197 0.7768949649 +0.6306306306 0.7760831191 +0.6316316316 0.7752686515 +0.6326326326 0.7744520335 +0.6336340432 0.7736329229 +0.6346346346 0.7728123191 +0.6356356356 0.7719892089 +0.6366378099 0.7711629523 +0.6376376376 0.7703364480 +0.6386386386 0.7695067831 +0.6396396396 0.7686749192 +0.6406406406 0.7678408491 +0.6416427965 0.7670035995 +0.6426442698 0.7661646967 +0.6436463401 0.7653230618 +0.6446457845 0.7644814010 +0.6456456456 0.7636371522 +0.6466466466 0.7627896921 +0.6476487003 0.7619390796 +0.6486486486 0.7610879914 +0.6496496496 0.7602337356 +0.6506506507 0.7593771993 +0.6516516517 0.7585183748 +0.6526526527 0.7576572543 +0.6536536537 0.7567938300 +0.6546546547 0.7559280939 +0.6556556557 0.7550600381 +0.6566566567 0.7541896547 +0.6576576577 0.7533169355 +0.6586597139 0.7524409487 +0.6596596597 0.7515644573 +0.6606606607 0.7506846818 +0.6616616617 0.7498025377 +0.6626626627 0.7489180165 +0.6636639380 0.7480308666 +0.6646655423 0.7471410288 +0.6656656657 0.7462501066 +0.6666666667 0.7453559925 +0.6676676677 0.7444594586 +0.6686687686 0.7435604064 +0.6696700121 0.7426587877 +0.6706708568 0.7417550821 +0.6716716717 0.7408489492 +0.6726726727 0.7399401837 +0.6736747602 0.7390279544 +0.6746746747 0.7381152236 +0.6756756757 0.7371990106 +0.6766766767 0.7362802967 +0.6776776777 0.7353590723 +0.6786786787 0.7344353281 +0.6796815187 0.7335073504 +0.6806834933 0.7325776286 +0.6816825186 0.7316481011 +0.6826831850 0.7307144920 +0.6836836837 0.7297784737 +0.6846846847 0.7288394079 +0.6856869699 0.7278965443 +0.6866885605 0.7269517321 +0.6876876877 0.7260066420 +0.6886886887 0.7250571633 +0.6896899925 0.7241047674 +0.6906910369 0.7231499786 +0.6916916917 0.7221929130 +0.6926940408 0.7212315619 +0.6936946854 0.7202691743 +0.6946963858 0.7193030874 +0.6956971197 0.7183352405 +0.6966966967 0.7173658152 +0.6976988128 0.7163912106 +0.6986986987 0.7154160527 +0.6996997298 0.7144370428 +0.7007007007 0.7134553441 +0.7017037971 0.7124687931 +0.7027036467 0.7114826667 +0.7037039479 0.7104933172 +0.7047047047 0.7095007253 +0.7057057057 0.7085050860 +0.7067070125 0.7075063240 +0.7077077077 0.7065053435 +0.7087087087 0.7055012163 +0.7097098302 0.7044941142 +0.7107107107 0.7034843891 +0.7117122799 0.7024710888 +0.7127127127 0.7014560493 +0.7137147039 0.7004365220 +0.7147148498 0.6994159589 +0.7157157157 0.6983917341 +0.7167167167 0.6973644298 +0.7177177177 0.6963341710 +0.7187187187 0.6953009445 +0.7197197197 0.6942647370 +0.7207207207 0.6932255353 +0.7217217217 0.6921833257 +0.7227227227 0.6911380948 +0.7237243839 0.6900891364 +0.7247258515 0.6890373286 +0.7257257257 0.6879841357 +0.7267277147 0.6869256355 +0.7277277277 0.6858661344 +0.7287287287 0.6848024824 +0.7297297297 0.6837357103 +0.7307318389 0.6826646172 +0.7317335427 0.6815908028 +0.7327341160 0.6805150368 +0.7337337337 0.6794371258 +0.7347348303 0.6783544274 +0.7357370699 0.6772672766 +0.7367367367 0.6761796956 +0.7377382823 0.6750868291 +0.7387404285 0.6739900439 +0.7397397397 0.6728930951 +0.7407409969 0.6717907230 +0.7417423300 0.6706849602 +0.7427429352 0.6695766813 +0.7437437437 0.6684648410 +0.7447447447 0.6673494326 +0.7457457457 0.6662306528 +0.7467468652 0.6651083516 +0.7477496769 0.6639807382 +0.7487507698 0.6628516310 +0.7497509003 0.6617201731 +0.7507507508 0.6605855813 +0.7517517518 0.6594462099 +0.7527527528 0.6583033444 +0.7537537538 0.6571569666 +0.7547547548 0.6560070580 +0.7557557558 0.6548536002 +0.7567572714 0.6536959785 +0.7577608951 0.6525323179 +0.7587598282 0.6513704961 +0.7597610024 0.6502024448 +0.7607615002 0.6490315399 +0.7617617618 0.6478572515 +0.7627636728 0.6466773380 +0.7637637638 0.6454958661 +0.7647647648 0.6443095953 +0.7657667975 0.6431183498 +0.7667667668 0.6419257943 +0.7677679668 0.6407279837 +0.7687687688 0.6395268408 +0.7697707260 0.6383204755 +0.7707728607 0.6371100354 +0.7717732667 0.6358978101 +0.7727727728 0.6346827882 +0.7737737738 0.6334620328 +0.7747757435 0.6322361484 +0.7757757758 0.6310086733 +0.7767767768 0.6297760229 +0.7777777778 0.6285393611 +0.7787799647 0.6272971916 +0.7797808234 0.6260526075 +0.7807810914 0.6248046793 +0.7817817818 0.6235521195 +0.7827827828 0.6222950385 +0.7837855860 0.6210315251 +0.7847858628 0.6197670123 +0.7857860662 0.6184983898 +0.7867876755 0.6172237468 +0.7877909140 0.6159427537 +0.7887915250 0.6146608253 +0.7897914009 0.6133755318 +0.7907924484 0.6120843925 +0.7917917918 0.6107910923 +0.7927927928 0.6094912532 +0.7937961556 0.6081839059 +0.7947956983 0.6068770864 +0.7957972547 0.6055631507 +0.7968006001 0.6042423385 +0.7978006176 0.6029213668 +0.7988012156 0.6015950614 +0.7998009797 0.6002652688 +0.8008020100 0.5989291617 +0.8018018018 0.5975900523 +0.8028033501 0.5962438940 +0.8038051655 0.5948926423 +0.8048048048 0.5935395742 +0.8058066380 0.5921787417 +0.8068068068 0.5908153489 +0.8078078078 0.5894459650 +0.8088090292 0.5880713854 +0.8098098098 0.5866924850 +0.8108108108 0.5853083197 +0.8118118118 0.5839191572 +0.8128128128 0.5825249620 +0.8138151346 0.5811238480 +0.8148148148 0.5797213275 +0.8158158158 0.5783118144 +0.8168174358 0.5768962441 +0.8178205144 0.5754733757 +0.8188210157 0.5740489040 +0.8198215946 0.5726190296 +0.8208227641 0.5711829741 +0.8218230662 0.5697427910 +0.8228285404 0.5682897088 +0.8238349478 0.5668297617 +0.8248384140 0.5653685442 +0.8258532896 0.5638850451 +0.8268672457 0.5623971533 +0.8278771762 0.5609094233 +0.8288727624 0.5594371670 +0.8298619650 0.5579687438 +0.8308483376 0.5564989128 +0.8318485214 0.5550027364 +0.8328354465 0.5535206582 +0.8338338338 0.5520155229 +0.8348361362 0.5504985247 +0.8358364463 0.5489785379 +0.8368382625 0.5474502009 +0.8378390119 0.5459173839 +0.8388388388 0.5443798329 +0.8398398398 0.5428342688 +0.8408408408 0.5412824405 +0.8418423655 0.5397234770 +0.8428431932 0.5381592252 +0.8438438438 0.5365888251 +0.8448448448 0.5350113907 +0.8458473234 0.5334250702 +0.8468468468 0.5318368340 +0.8478478478 0.5302395939 +0.8488516396 0.5286311512 +0.8498513361 0.5270224916 +0.8508508509 0.5254072988 +0.8518541278 0.5237790994 +0.8528538201 0.5221497502 +0.8538543001 0.5205120884 +0.8548548549 0.5188672057 +0.8558575680 0.5172115846 +0.8568599769 0.5155492024 +0.8578590836 0.5138849995 +0.8588601162 0.5122102116 +0.8598598599 0.5105301376 +0.8608635220 0.5088359229 +0.8618636728 0.5071400295 +0.8628679780 0.5054293745 +0.8638649378 0.5037235047 +0.8648656649 0.5020033683 +0.8658683931 0.5002718519 +0.8668677905 0.4985380967 +0.8678678679 0.4967950925 +0.8688718730 0.4950370373 +0.8698736211 0.4932746529 +0.8708723750 0.4915092130 +0.8718718719 0.4897340493 +0.8728728729 0.4879476896 +0.8738752272 0.4861502723 +0.8748774666 0.4843443181 +0.8758783709 0.4825319465 +0.8768768769 0.4807150328 +0.8778800077 0.4788806658 +0.8788808536 0.4770413453 +0.8798798799 0.4751961668 +0.8808817021 0.4733364839 +0.8818818819 0.4714704088 +0.8828841587 0.4695908456 +0.8838838839 0.4677064034 +0.8848864682 0.4658067607 +0.8858858859 0.4639032196 +0.8868880801 0.4619843432 +0.8878890006 0.4600577383 +0.8888888889 0.4581228473 +0.8898916606 0.4561719328 +0.8908916277 0.4542159262 +0.8918927976 0.4522468768 +0.8928951469 0.4502646518 +0.8938938939 0.4482786036 +0.8948948949 0.4462769623 +0.8958977603 0.4442602876 +0.8968979645 0.4422375395 +0.8979002899 0.4401988976 +0.8988988989 0.4381561018 +0.8998998999 0.4360965147 +0.9009023300 0.4340218795 +0.9019052986 0.4319338287 +0.9029056424 0.4298388081 +0.9039065779 0.4277299363 +0.9049132506 0.4255960630 +0.9059130618 0.4234637228 +0.9069101087 0.4213241682 +0.9079098397 0.4191655079 +0.9089127246 0.4169864014 +0.9099115880 0.4148022446 +0.9109114570 0.4126018875 +0.9119136867 0.4103820513 +0.9129129129 0.4081543990 +0.9139139139 0.4059080659 +0.9149167765 0.4036425300 +0.9159174342 0.4013667322 +0.9169192282 0.3990728367 +0.9179194591 0.3967667660 +0.9189213809 0.3944407379 +0.9199263475 0.3920912078 +0.9209313246 0.3897248970 +0.9219314736 0.3873530148 +0.9229364461 0.3849523562 +0.9239322618 0.3825561078 +0.9249289645 0.3801399881 +0.9259311199 0.3776924162 +0.9269299287 0.3752344697 +0.9279344792 0.3727433464 +0.9289377295 0.3702359987 +0.9299354536 0.3677227926 +0.9309309309 0.3651952927 +0.9319337420 0.3626285985 +0.9329401493 0.3600314956 +0.9339416807 0.3574254287 +0.9349441928 0.3547948088 +0.9359447383 0.3521469108 +0.9369519997 0.3494580809 +0.9379468684 0.3467789961 +0.9389476600 0.3440600119 +0.9399442674 0.3413279571 +0.9409457092 0.3385574874 +0.9419483491 0.3357578111 +0.9429462076 0.3329451148 +0.9439470603 0.3300968758 +0.9449524570 0.3272076619 +0.9459521587 0.3243062033 +0.9469537918 0.3213697499 +0.9479517402 0.3184140360 +0.9489543944 0.3154133119 +0.9499565125 0.3123821768 +0.9509555279 0.3093276320 +0.9519640614 0.3062097742 +0.9529639469 0.3030836780 +0.9539654496 0.2999165233 +0.9549600502 0.2967343973 +0.9559616024 0.2934917627 +0.9569658084 0.2902006919 +0.9579643450 0.2868872838 +0.9589720906 0.2835004929 +0.9599723687 0.2800947184 +0.9609664523 0.2766649194 +0.9619764369 0.2731324492 +0.9629758058 0.2695878288 +0.9639714133 0.2660058539 +0.9649758435 0.2623387533 +0.9659811043 0.2586126567 +0.9669917798 0.2548075701 +0.9679901121 0.2509883323 +0.9689941110 0.2470838173 +0.9700076093 0.2430745522 +0.9710116043 0.2390323500 +0.9720159574 0.2349148325 +0.9730324483 0.2306682781 +0.9740358201 0.2263939513 +0.9750207543 0.2221137741 +0.9760222141 0.2176709386 +0.9770250551 0.2131244746 +0.9780318938 0.2084553064 +0.9790453947 0.2036421252 +0.9800580079 0.1987116031 +0.9810811984 0.1935966999 +0.9821315948 0.1881954583 +0.9831871921 0.1826005072 +0.9841812952 0.1771642691 +0.9852222690 0.1712807072 +0.9862351536 0.1653487882 +0.9872695178 0.1590562770 +0.9883054593 0.1524871113 +0.9893535395 0.1455320372 +0.9904196033 0.1380905840 +0.9914345875 0.1306042062 +0.9925216962 0.1220683524 +0.9936003062 0.1129532269 +0.9946000689 0.1037819972 +0.9956227614 0.0934629176 +0.9966372661 0.0819399766 +0.9976101518 0.0690940309 +0.9985118883 0.0545344751 +0.9993366830 0.0364169478 +1.0000000000 0.0000000000 diff --git a/src/problems/DTLZ/DTLZ4.txt b/src/problems/DTLZ/DTLZ4.txt new file mode 100644 index 0000000..c599a8b --- /dev/null +++ b/src/problems/DTLZ/DTLZ4.txt @@ -0,0 +1,1000 @@ +0.0000000000 1.0000000000 +0.0024376240 0.9999970290 +0.0036802178 0.9999932280 +0.0047339714 0.9999887947 +0.0057080250 0.9999837091 +0.0065972495 0.9999782379 +0.0074750663 0.9999720613 +0.0082930392 0.9999656122 +0.0092130046 0.9999575594 +0.0101694069 0.9999482902 +0.0110864071 0.9999385439 +0.0119747142 0.9999283005 +0.0128499955 0.9999174354 +0.0137610854 0.9999053118 +0.0145690681 0.9998938655 +0.0155405037 0.9998792391 +0.0164983942 0.9998638922 +0.0174200448 0.9998482595 +0.0183730015 0.9998312022 +0.0193122038 0.9998135020 +0.0202840371 0.9997942578 +0.0212768482 0.9997736222 +0.0222809149 0.9997517496 +0.0232513323 0.9997296512 +0.0242029392 0.9997070660 +0.0251831875 0.9996828532 +0.0261748439 0.9996573801 +0.0271739884 0.9996307190 +0.0281525004 0.9996036398 +0.0291354196 0.9995754736 +0.0301282126 0.9995460424 +0.0311013086 0.9995162373 +0.0321139185 0.9994842151 +0.0330989146 0.9994520808 +0.0340917610 0.9994187070 +0.0351106506 0.9993834310 +0.0361201345 0.9993474550 +0.0371240356 0.9993106654 +0.0381147359 0.9992733695 +0.0391119534 0.9992348348 +0.0401116218 0.9991952051 +0.0411149177 0.9991544243 +0.0420874618 0.9991139302 +0.0430838499 0.9990714598 +0.0440956172 0.9990273152 +0.0450929276 0.9989827966 +0.0460960293 0.9989370131 +0.0471014257 0.9988901119 +0.0480916857 0.9988429255 +0.0490864970 0.9987945313 +0.0500776278 0.9987453285 +0.0510828172 0.9986944206 +0.0520683706 0.9986435224 +0.0530737986 0.9985905927 +0.0540673112 0.9985372932 +0.0550745741 0.9984822439 +0.0560703438 0.9984268208 +0.0570812977 0.9983695335 +0.0580806256 0.9983118956 +0.0590791197 0.9982533033 +0.0600760736 0.9981938015 +0.0610794219 0.9981329091 +0.0620921520 0.9980704207 +0.0630949569 0.9980075282 +0.0640874302 0.9979442877 +0.0650982022 0.9978788624 +0.0661023217 0.9978128497 +0.0670930983 0.9977467194 +0.0680862574 0.9976794383 +0.0690824980 0.9976109505 +0.0700963842 0.9975402232 +0.0710925827 0.9974697212 +0.0720982253 0.9973975365 +0.0730953602 0.9973249562 +0.0740907900 0.9972515003 +0.0750785689 0.9971776213 +0.0760807102 0.9971016626 +0.0770868071 0.9970243849 +0.0780948102 0.9969459367 +0.0790960303 0.9968670012 +0.0800934694 0.9967873575 +0.0810943834 0.9967064267 +0.0820953907 0.9966244763 +0.0830961419 0.9965415351 +0.0840875863 0.9964583673 +0.0850850851 0.9963736891 +0.0860864750 0.9962876687 +0.0870964432 0.9961998843 +0.0880968714 0.9961119120 +0.0890971860 0.9960229372 +0.0900939480 0.9959332711 +0.0910945671 0.9958422465 +0.0920937126 0.9957503443 +0.0931010419 0.9956566657 +0.0941055363 0.9955622271 +0.0951045577 0.9954672888 +0.0961077250 0.9953709385 +0.0971077215 0.9952738771 +0.0981104624 0.9951755308 +0.0991152388 0.9950759616 +0.1001131241 0.9949760612 +0.1011094437 0.9948753090 +0.1021111442 0.9947729963 +0.1031117383 0.9946697791 +0.1041118913 0.9945655906 +0.1051191129 0.9944596382 +0.1061118212 0.9943542032 +0.1071091685 0.9942472660 +0.1081100177 0.9941389360 +0.1091122245 0.9940294374 +0.1101121508 0.9939191689 +0.1111126274 0.9938078205 +0.1121164374 0.9936950762 +0.1131187770 0.9935814724 +0.1141166455 0.9934673579 +0.1151151151 0.9933521582 +0.1161181012 0.9932354135 +0.1171252355 0.9931171528 +0.1181243744 0.9929988077 +0.1191263594 0.9928791017 +0.1201254734 0.9927587172 +0.1211220864 0.9926376178 +0.1221272126 0.9925144553 +0.1231235628 0.9923913484 +0.1241241241 0.9922666989 +0.1251280973 0.9921405945 +0.1261297051 0.9920137587 +0.1271271271 0.9918864318 +0.1281318463 0.9917571426 +0.1291357881 0.9916269199 +0.1301339324 0.9914964244 +0.1311348537 0.9913645395 +0.1321321321 0.9912321119 +0.1331335013 0.9910981136 +0.1341341341 0.9909631850 +0.1351373794 0.9908268712 +0.1361361361 0.9906901395 +0.1371401854 0.9905516491 +0.1381430255 0.9904122902 +0.1391426332 0.9902723502 +0.1401426651 0.9901313213 +0.1411464108 0.9899887326 +0.1421459659 0.9898457074 +0.1431458244 0.9897016080 +0.1441441441 0.9895567016 +0.1451451917 0.9894103665 +0.1461492859 0.9892625467 +0.1471496571 0.9891142393 +0.1481506966 0.9889647977 +0.1491491491 0.9888147103 +0.1501501502 0.9886632047 +0.1511511512 0.9885106623 +0.1521521522 0.9883570825 +0.1531541342 0.9882023129 +0.1541562342 0.9880464845 +0.1551551552 0.9878901142 +0.1561561562 0.9877323802 +0.1571617368 0.9875728776 +0.1581673166 0.9874123252 +0.1591644644 0.9872520819 +0.1601629302 0.9870905915 +0.1611634143 0.9869277349 +0.1621710749 0.9867626576 +0.1631766408 0.9865968700 +0.1641805745 0.9864303011 +0.1651864816 0.9862623517 +0.1661850043 0.9860945920 +0.1671808690 0.9859262432 +0.1681738832 0.9857573459 +0.1691691692 0.9855870292 +0.1701714936 0.9854144624 +0.1711732166 0.9852409502 +0.1721738929 0.9850665717 +0.1731731732 0.9848913910 +0.1741741742 0.9847148608 +0.1751764980 0.9845370458 +0.1761761762 0.9843586516 +0.1771771772 0.9841789715 +0.1781803976 0.9839978384 +0.1791847030 0.9838154513 +0.1801862087 0.9836325179 +0.1811844530 0.9834491314 +0.1821862264 0.9832640433 +0.1831883610 0.9830778323 +0.1841859485 0.9828914164 +0.1851886409 0.9827029904 +0.1861889928 0.9825139485 +0.1871875126 0.9823242006 +0.1881907775 0.9821324917 +0.1891891892 0.9819406554 +0.1901901902 0.9817472646 +0.1911921208 0.9815526338 +0.1921964651 0.9813564688 +0.1931985642 0.9811596785 +0.1941986011 0.9809622334 +0.1952024094 0.9807629782 +0.1961971621 0.9805644668 +0.1971989718 0.9803634864 +0.1982001985 0.9801615588 +0.1991991992 0.9799590191 +0.2002002002 0.9797550101 +0.2012025911 0.9795496503 +0.2022022022 0.9793437953 +0.2032033034 0.9791365673 +0.2042056070 0.9789280209 +0.2052052052 0.9787189708 +0.2062068572 0.9785084221 +0.2072096983 0.9782965506 +0.2082132451 0.9780834548 +0.2092124293 0.9778702160 +0.2102141420 0.9776553659 +0.2112112112 0.9774404454 +0.2122143762 0.9772231365 +0.2132145302 0.9770054064 +0.2142175608 0.9767859728 +0.2152166788 0.9765663219 +0.2162183061 0.9763450436 +0.2172172172 0.9761232917 +0.2182182182 0.9758999996 +0.2192192192 0.9756756295 +0.2202202202 0.9754501805 +0.2212212212 0.9752236519 +0.2222223137 0.9749960222 +0.2232237113 0.9747672413 +0.2242253312 0.9745373266 +0.2252252252 0.9743067268 +0.2262276870 0.9740744497 +0.2272300563 0.9738411069 +0.2282282282 0.9736076601 +0.2292300768 0.9733722679 +0.2302307812 0.9731360580 +0.2312322399 0.9728985822 +0.2322324473 0.9726603160 +0.2332332332 0.9724208240 +0.2342342342 0.9721801909 +0.2352352352 0.9719384672 +0.2362362362 0.9716956523 +0.2372386447 0.9714514015 +0.2382405006 0.9712061902 +0.2392412812 0.9709601482 +0.2402402402 0.9707134629 +0.2412412412 0.9704651789 +0.2422422422 0.9702157987 +0.2432432432 0.9699653213 +0.2442442442 0.9697137460 +0.2452459588 0.9694608913 +0.2462462462 0.9692072979 +0.2472472472 0.9689524234 +0.2482482482 0.9686964474 +0.2492492492 0.9684393692 +0.2502502503 0.9681811877 +0.2512526720 0.9679215334 +0.2522522523 0.9676615117 +0.2532532533 0.9674000154 +0.2542542543 0.9671374123 +0.2552574003 0.9668731352 +0.2562571120 0.9666086553 +0.2572572573 0.9663429534 +0.2582583893 0.9660758792 +0.2592592593 0.9658077637 +0.2602613898 0.9655381965 +0.2612612613 0.9652681251 +0.2622622623 0.9649966351 +0.2632651100 0.9647235261 +0.2642654661 0.9644499798 +0.2652680004 0.9641747186 +0.2662662663 0.9638995152 +0.2672677791 0.9636222986 +0.2682682683 0.9633442460 +0.2692696608 0.9630648212 +0.2702702703 0.9627844935 +0.2712712713 0.9625029337 +0.2722722723 0.9622202501 +0.2732732733 0.9619364418 +0.2742742743 0.9616515078 +0.2752752753 0.9613654471 +0.2762762763 0.9610782586 +0.2772788149 0.9607894976 +0.2782782783 0.9605004944 +0.2792792793 0.9602099167 +0.2802802803 0.9599182072 +0.2812812813 0.9596253648 +0.2822822823 0.9593313886 +0.2832832833 0.9590362774 +0.2842849564 0.9587398310 +0.2852852853 0.9584426462 +0.2862867741 0.9581439782 +0.2872872873 0.9578444626 +0.2882882883 0.9575436611 +0.2892892893 0.9572417182 +0.2902902903 0.9569386330 +0.2912917893 0.9566342527 +0.2922930540 0.9563287984 +0.2932932933 0.9560225123 +0.2942966170 0.9557141315 +0.2952971643 0.9554054557 +0.2962962963 0.9550960710 +0.2972976632 0.9547848446 +0.2982994581 0.9544723324 +0.2993013384 0.9541586392 +0.3003003003 0.9538447094 +0.3013013013 0.9535289853 +0.3023023023 0.9532121055 +0.3033033033 0.9528940687 +0.3043053572 0.9525745375 +0.3053053053 0.9522545198 +0.3063080000 0.9519324604 +0.3073089810 0.9516097888 +0.3083083083 0.9512864905 +0.3093096236 0.9509613855 +0.3103103103 0.9506353198 +0.3113113113 0.9503079856 +0.3123123123 0.9499794838 +0.3133133133 0.9496498132 +0.3143143969 0.9493189453 +0.3153153153 0.9489869609 +0.3163163163 0.9486537767 +0.3173182203 0.9483191167 +0.3183188165 0.9479837188 +0.3193193193 0.9476471771 +0.3203219689 0.9473087333 +0.3213213213 0.9469702258 +0.3223223223 0.9466299808 +0.3233233233 0.9462885546 +0.3243243243 0.9459459459 +0.3253264361 0.9456017713 +0.3263263263 0.9452571760 +0.3273278545 0.9449108295 +0.3283283283 0.9445636605 +0.3293293293 0.9442151200 +0.3303303303 0.9438653892 +0.3313313313 0.9435144667 +0.3323345267 0.9431615781 +0.3333363614 0.9428079710 +0.3343376385 0.9424533641 +0.3353359355 0.9420986203 +0.3363363363 0.9417419333 +0.3373373373 0.9413838329 +0.3383383383 0.9410245315 +0.3393393393 0.9406640276 +0.3403403403 0.9403023199 +0.3413413413 0.9399394069 +0.3423426276 0.9395751834 +0.3433447556 0.9392094435 +0.3443443443 0.9388434228 +0.3453453453 0.9384756749 +0.3463469230 0.9381065019 +0.3473473473 0.9377365410 +0.3483492393 0.9373648209 +0.3493493493 0.9369925465 +0.3503505674 0.9366186417 +0.3513513514 0.9362436798 +0.3523523524 0.9358674157 +0.3533533534 0.9354899292 +0.3543553204 0.9351108528 +0.3553562021 0.9347309611 +0.3563563564 0.9343501203 +0.3573595451 0.9339668921 +0.3583592842 0.9335837528 +0.3593610561 0.9331986023 +0.3603608116 0.9328129960 +0.3613613614 0.9324258504 +0.3623623624 0.9320372945 +0.3633633634 0.9316475010 +0.3643643644 0.9312564684 +0.3653653654 0.9308641951 +0.3663687537 0.9304697396 +0.3673682839 0.9300755582 +0.3683695078 0.9296794640 +0.3693701930 0.9292823363 +0.3703703704 0.9288841633 +0.3713713714 0.9284844126 +0.3723723724 0.9280834102 +0.3733742155 0.9276808153 +0.3743743744 0.9272776433 +0.3753753754 0.9268728756 +0.3763769050 0.9264666348 +0.3773787553 0.9260590019 +0.3783783784 0.9256510157 +0.3793793794 0.9252412045 +0.3803804304 0.9248301077 +0.3813817812 0.9244176204 +0.3823850997 0.9240030495 +0.3833864307 0.9235880276 +0.3843850740 0.9231728521 +0.3853853854 0.9227557124 +0.3863863864 0.9223370102 +0.3873888039 0.9219164358 +0.3883883884 0.9214957731 +0.3893901834 0.9210728989 +0.3903903904 0.9206494138 +0.3913913914 0.9202243089 +0.3923923924 0.9197979182 +0.3933933934 0.9193702399 +0.3943943944 0.9189412722 +0.3953972258 0.9185102252 +0.3963992697 0.9180782205 +0.3973994635 0.9176457194 +0.3984020005 0.9172109060 +0.3994007345 0.9167764467 +0.4004009036 0.9163400659 +0.4014014014 0.9159022409 +0.4024024024 0.9154628920 +0.4034034034 0.9150222370 +0.4044044044 0.9145802741 +0.4054054054 0.9141370014 +0.4064064064 0.9136924170 +0.4074074074 0.9132465190 +0.4084089819 0.9127990488 +0.4094094094 0.9123507744 +0.4104128790 0.9118998129 +0.4114124307 0.9114492920 +0.4124124124 0.9109972569 +0.4134134134 0.9105434364 +0.4144152103 0.9100879262 +0.4154170659 0.9096310578 +0.4164164164 0.9091740032 +0.4174174174 0.9087148616 +0.4184184184 0.9082543846 +0.4194194194 0.9077925703 +0.4204204204 0.9073294165 +0.4214221831 0.9068645674 +0.4224237180 0.9063984789 +0.4234234234 0.9059318984 +0.4244250516 0.9054630724 +0.4254254254 0.9049934847 +0.4264264264 0.9045222512 +0.4274287698 0.9040490290 +0.4284284284 0.9035757200 +0.4294303298 0.9030999900 +0.4304320727 0.9026229727 +0.4314314314 0.9021457310 +0.4324335813 0.9016657905 +0.4334334334 0.9011855851 +0.4344353513 0.9007030174 +0.4354354354 0.9002199629 +0.4364364364 0.8997350927 +0.4374385065 0.8992483267 +0.4384397109 0.8987606021 +0.4394394394 0.8982722188 +0.4404404404 0.8977818323 +0.4414416607 0.8972899532 +0.4424424424 0.8967969029 +0.4434434434 0.8963023555 +0.4444444444 0.8958064165 +0.4454454454 0.8953090836 +0.4464464464 0.8948103545 +0.4474474474 0.8943102268 +0.4484484484 0.8938086983 +0.4494497560 0.8933056122 +0.4504504505 0.8928014290 +0.4514514515 0.8922956836 +0.4524524525 0.8917885278 +0.4534535412 0.8912799145 +0.4544550743 0.8907696590 +0.4554554555 0.8902585737 +0.4564564565 0.8897457521 +0.4574574575 0.8892315079 +0.4584584585 0.8887158387 +0.4594608197 0.8881980383 +0.4604611149 0.8876798757 +0.4614624797 0.8871597262 +0.4624641660 0.8866379730 +0.4634634635 0.8861160297 +0.4644650912 0.8855914290 +0.4654654655 0.8850660430 +0.4664674311 0.8845383744 +0.4674674675 0.8840102753 +0.4684684685 0.8834802171 +0.4694704188 0.8829482011 +0.4704704705 0.8824157390 +0.4714719089 0.8818810799 +0.4724733641 0.8813449496 +0.4734749367 0.8808072913 +0.4744752965 0.8802688186 +0.4754756692 0.8797288718 +0.4764775552 0.8791866351 +0.4774786626 0.8786433445 +0.4784784785 0.8780992801 +0.4794794795 0.8775530917 +0.4804804805 0.8770054207 +0.4814822202 0.8764558584 +0.4824824825 0.8759056194 +0.4834834835 0.8753534836 +0.4844844845 0.8747998538 +0.4854854855 0.8742447274 +0.4864873961 0.8736875949 +0.4874886019 0.8731293507 +0.4884897154 0.8725696522 +0.4894894895 0.8720091970 +0.4904904905 0.8714465438 +0.4914914915 0.8708823766 +0.4924931862 0.8703162997 +0.4934938730 0.8697492727 +0.4944954278 0.8691802298 +0.4954954955 0.8686105076 +0.4964964965 0.8680387255 +0.4974975104 0.8674654040 +0.4984994477 0.8668900164 +0.4995003265 0.8663136983 +0.5005016274 0.8657355953 +0.5015035026 0.8651556142 +0.5025037718 0.8645750166 +0.5035035189 0.8639931750 +0.5045045045 0.8634090600 +0.5055067750 0.8628226356 +0.5065065065 0.8622361387 +0.5075075075 0.8616473349 +0.5085085085 0.8610569649 +0.5095099539 0.8604647621 +0.5105105105 0.8598715129 +0.5115122721 0.8592759717 +0.5125132777 0.8586792999 +0.5135135135 0.8580815063 +0.5145145145 0.8574816700 +0.5155155155 0.8568802444 +0.5165165165 0.8562772262 +0.5175177849 0.8556724503 +0.5185185185 0.8550663986 +0.5195195195 0.8544585823 +0.5205215857 0.8538485105 +0.5215215215 0.8532381277 +0.5225225225 0.8526254825 +0.5235235235 0.8520112208 +0.5245245245 0.8513953389 +0.5255255255 0.8507778335 +0.5265265265 0.8501587010 +0.5275277980 0.8495377698 +0.5285285285 0.8489155403 +0.5295295295 0.8482915049 +0.5305311399 0.8476654467 +0.5315319825 0.8470382232 +0.5325333534 0.8464090190 +0.5335347073 0.8457781719 +0.5345345345 0.8451466331 +0.5355355355 0.8445126939 +0.5365365365 0.8438770911 +0.5375375375 0.8432398210 +0.5385389105 0.8426006420 +0.5395411221 0.8419592494 +0.5405413821 0.8413174278 +0.5415420331 0.8406736741 +0.5425425425 0.8400283266 +0.5435435435 0.8393809721 +0.5445445356 0.8387319290 +0.5455455455 0.8380811761 +0.5465465465 0.8374287268 +0.5475475475 0.8367745713 +0.5485491382 0.8361183188 +0.5495495495 0.8354611257 +0.5505517055 0.8348010659 +0.5515520726 0.8341404625 +0.5525525526 0.8334780601 +0.5535535536 0.8328135826 +0.5545556718 0.8321466258 +0.5555555556 0.8314794193 +0.5565565566 0.8308097251 +0.5575575576 0.8301382837 +0.5585589897 0.8294648004 +0.5595600109 0.8287898372 +0.5605607480 0.8281133061 +0.5615615616 0.8274349597 +0.5625625626 0.8267547177 +0.5635635636 0.8260727025 +0.5645648651 0.8253887042 +0.5655655656 0.8247033352 +0.5665665666 0.8240159741 +0.5675675676 0.8233268223 +0.5685685686 0.8226358750 +0.5695695696 0.8219431279 +0.5705705706 0.8212485763 +0.5715715716 0.8205522156 +0.5725737337 0.8198532305 +0.5735735736 0.8191540488 +0.5745745746 0.8184522333 +0.5755755756 0.8177485902 +0.5765765766 0.8170431147 +0.5775775776 0.8163358022 +0.5785794568 0.8156260247 +0.5795795796 0.8149156465 +0.5805814353 0.8142021843 +0.5815815816 0.8134880847 +0.5825825826 0.8127715143 +0.5835848928 0.8120521368 +0.5845855244 0.8113320927 +0.5855855856 0.8106105859 +0.5865865866 0.8098865207 +0.5875875876 0.8091605693 +0.5885893149 0.8084321977 +0.5895896677 0.8077029304 +0.5905905906 0.8069713466 +0.5915915916 0.8062377991 +0.5925936476 0.8055015635 +0.5935947019 0.8047641455 +0.5945968537 0.8040239932 +0.5955962815 0.8032839283 +0.5965965966 0.8025412768 +0.5975982942 0.8017956590 +0.5985985986 0.8010491357 +0.5995995996 0.8003001438 +0.6006006006 0.7995491971 +0.6016018645 0.7987960920 +0.6026026026 0.7980414171 +0.6036036036 0.7972845726 +0.6046046046 0.7965257511 +0.6056056056 0.7957649467 +0.6066066066 0.7950021540 +0.6076076076 0.7942373670 +0.6086086086 0.7934705801 +0.6096096096 0.7927017875 +0.6106106106 0.7919309832 +0.6116116116 0.7911581615 +0.6126126126 0.7903833164 +0.6136136136 0.7896064420 +0.6146152013 0.7888270751 +0.6156156156 0.7880465810 +0.6166175888 0.7872628209 +0.6176176176 0.7864785302 +0.6186192566 0.7856909159 +0.6196196196 0.7849022404 +0.6206206206 0.7841109904 +0.6216216216 0.7833176620 +0.6226226226 0.7825222488 +0.6236236240 0.7817247442 +0.6246246246 0.7809251426 +0.6256256256 0.7801234367 +0.6266266266 0.7793196204 +0.6276280342 0.7785133593 +0.6286286286 0.7777056302 +0.6296296296 0.7768954431 +0.6306312736 0.7760825966 +0.6316316316 0.7752686515 +0.6326326326 0.7744520335 +0.6336348665 0.7736322486 +0.6346346346 0.7728123191 +0.6356361249 0.7719888061 +0.6366375449 0.7711631711 +0.6376376376 0.7703364480 +0.6386386386 0.7695067831 +0.6396396396 0.7686749192 +0.6406408378 0.7678406846 +0.6416425329 0.7670038201 +0.6426426426 0.7661660615 +0.6436436436 0.7653253295 +0.6446446446 0.7644823622 +0.6456458656 0.7636369663 +0.6466479317 0.7627886027 +0.6476482022 0.7619395029 +0.6486486486 0.7610879914 +0.6496496496 0.7602337356 +0.6506506507 0.7593771993 +0.6516527191 0.7585174578 +0.6526530179 0.7576569397 +0.6536536537 0.7567938300 +0.6546546547 0.7559280939 +0.6556568938 0.7550589630 +0.6566575390 0.7541888865 +0.6576576577 0.7533169355 +0.6586586587 0.7524418724 +0.6596596597 0.7515644573 +0.6606606607 0.7506846818 +0.6616629033 0.7498014420 +0.6626635918 0.7489171944 +0.6636667064 0.7480284104 +0.6646659255 0.7471406879 +0.6656668809 0.7462490225 +0.6666666667 0.7453559925 +0.6676676677 0.7444594586 +0.6686686687 0.7435604962 +0.6696704909 0.7426583560 +0.6706728119 0.7417533143 +0.6716716717 0.7408489492 +0.6726741610 0.7399388307 +0.6736754328 0.7390273413 +0.6746746747 0.7381152236 +0.6756757933 0.7371989028 +0.6766781542 0.7362789387 +0.6776776777 0.7353590723 +0.6786786787 0.7344353281 +0.6796796797 0.7335090545 +0.6806814878 0.7325794920 +0.6816816817 0.7316488809 +0.6826847773 0.7307130044 +0.6836872970 0.7297750886 +0.6846856371 0.7288385133 +0.6856856857 0.7278977541 +0.6866866867 0.7269535022 +0.6876876877 0.7260066420 +0.6886886887 0.7250571633 +0.6896906033 0.7241041857 +0.6906906907 0.7231503093 +0.6916927176 0.7221919305 +0.6926926927 0.7212328566 +0.6936936937 0.7202701294 +0.6946960628 0.7193033994 +0.6956978996 0.7183344851 +0.6966972731 0.7173652554 +0.6976976977 0.7163922966 +0.6986998634 0.7154149152 +0.6996996997 0.7144370723 +0.7007007007 0.7134553441 +0.7017017017 0.7124708568 +0.7027027027 0.7114835990 +0.7037040193 0.7104932464 +0.7047047047 0.7095007253 +0.7057057057 0.7085050860 +0.7067076778 0.7075056594 +0.7077090516 0.7065039974 +0.7087087087 0.7055012163 +0.7097097097 0.7044942356 +0.7107116143 0.7034834762 +0.7117117117 0.7024716645 +0.7127127127 0.7014560493 +0.7137148537 0.7004363694 +0.7147147147 0.6994160969 +0.7157157157 0.6983917341 +0.7167167167 0.6973644298 +0.7177177177 0.6963341710 +0.7187187187 0.6953009445 +0.7197201077 0.6942643348 +0.7207218083 0.6932244045 +0.7217238051 0.6921811534 +0.7227227227 0.6911380948 +0.7237237237 0.6900898287 +0.7247247247 0.6890385137 +0.7257261578 0.6879836800 +0.7267267267 0.6869266807 +0.7277277277 0.6858661344 +0.7287291544 0.6848020295 +0.7297310644 0.6837342859 +0.7307318073 0.6826646511 +0.7317330380 0.6815913447 +0.7327327327 0.6805165262 +0.7337343109 0.6794365026 +0.7347351592 0.6783540711 +0.7357357357 0.6772687260 +0.7367381340 0.6761781732 +0.7377377377 0.6750874242 +0.7387387387 0.6739918960 +0.7397406562 0.6728920876 +0.7407407407 0.6717910055 +0.7417425852 0.6706846781 +0.7427440214 0.6695754765 +0.7437437437 0.6684648410 +0.7447447447 0.6673494326 +0.7457463363 0.6662299917 +0.7467467467 0.6651084846 +0.7477477477 0.6639829107 +0.7487502106 0.6628522626 +0.7497497497 0.6617214767 +0.7507507508 0.6605855813 +0.7517525774 0.6594452687 +0.7527527528 0.6583033444 +0.7537537538 0.6571569666 +0.7547547548 0.6560070580 +0.7557557558 0.6548536002 +0.7567572359 0.6536960195 +0.7577577578 0.6525359611 +0.7587587588 0.6513717418 +0.7597597598 0.6502038968 +0.7607617770 0.6490312155 +0.7617629059 0.6478559062 +0.7627635738 0.6466774548 +0.7637637638 0.6454958661 +0.7647658552 0.6443083010 +0.7657657658 0.6431195783 +0.7667667668 0.6419257943 +0.7677677678 0.6407282222 +0.7687687688 0.6395268408 +0.7697703971 0.6383208721 +0.7707707708 0.6371125638 +0.7717717718 0.6358996244 +0.7727727728 0.6346827882 +0.7737737738 0.6334620328 +0.7747747748 0.6322373355 +0.7757757758 0.6310086733 +0.7767767768 0.6297760229 +0.7777783334 0.6285386735 +0.7787787788 0.6272986639 +0.7797797798 0.6260539075 +0.7807820152 0.6248035249 +0.7817817818 0.6235521195 +0.7827827828 0.6222950385 +0.7837837838 0.6210337996 +0.7847863227 0.6197664300 +0.7857867449 0.6184975275 +0.7867867868 0.6172248797 +0.7877884300 0.6159459307 +0.7887887888 0.6146643366 +0.7897897898 0.6133776063 +0.7907926824 0.6120840902 +0.7917931700 0.6107893057 +0.7927931709 0.6094907614 +0.7937937938 0.6081869885 +0.7947952646 0.6068776543 +0.7957974082 0.6055629489 +0.7967972425 0.6042467661 +0.7977997788 0.6029224767 +0.7987992098 0.6015977248 +0.7997997998 0.6002668409 +0.8008025015 0.5989285046 +0.8018018018 0.5975900523 +0.8028029418 0.5962444436 +0.8038038038 0.5948944822 +0.8048048048 0.5935395742 +0.8058058058 0.5921798741 +0.8068077651 0.5908140403 +0.8078095627 0.5894435600 +0.8088105678 0.5880692693 +0.8098138065 0.5866869683 +0.8108114218 0.5853074733 +0.8118136242 0.5839166374 +0.8128128128 0.5825249620 +0.8138138138 0.5811256976 +0.8148148148 0.5797213275 +0.8158169878 0.5783101611 +0.8168184406 0.5768948215 +0.8178186541 0.5754760195 +0.8188188188 0.5740520377 +0.8198198198 0.5726215705 +0.8208208208 0.5711857667 +0.8218218218 0.5697445859 +0.8228238876 0.5682964455 +0.8238243384 0.5668451813 +0.8248248248 0.5653883695 +0.8258258258 0.5639252658 +0.8268275482 0.5624555142 +0.8278292609 0.5609801376 +0.8288298715 0.5595007096 +0.8298298298 0.5580165352 +0.8308308308 0.5565250493 +0.8318371804 0.5550197342 +0.8328370086 0.5535183078 +0.8338364467 0.5520115762 +0.8348366113 0.5504978043 +0.8358384509 0.5489754857 +0.8368390892 0.5474489372 +0.8378378378 0.5459191859 +0.8388388388 0.5443798329 +0.8398414856 0.5428317226 +0.8408438187 0.5412778146 +0.8418439693 0.5397209755 +0.8428428428 0.5381597739 +0.8438438438 0.5365888251 +0.8448452503 0.5350107504 +0.8458458458 0.5334274131 +0.8468468468 0.5318368340 +0.8478487676 0.5302381231 +0.8488498054 0.5286340964 +0.8498498498 0.5270248881 +0.8508508509 0.5254072988 +0.8518541147 0.5237791207 +0.8528550532 0.5221477360 +0.8538538539 0.5205128205 +0.8548555562 0.5188660502 +0.8558578594 0.5172111024 +0.8568570450 0.5155540751 +0.8578597590 0.5138838720 +0.8588588589 0.5122123198 +0.8598598599 0.5105301376 +0.8608643134 0.5088345840 +0.8618632894 0.5071406810 +0.8628648541 0.5054347076 +0.8638671547 0.5037197029 +0.8648698076 0.5019962309 +0.8658694806 0.5002699697 +0.8668740170 0.4985272697 +0.8678697721 0.4967917659 +0.8688688689 0.4950423100 +0.8698722052 0.4932771499 +0.8708724574 0.4915090670 +0.8718718719 0.4897340493 +0.8728733747 0.4879467919 +0.8738759654 0.4861489453 +0.8748748749 0.4843489995 +0.8758758759 0.4825364754 +0.8768797248 0.4807098379 +0.8778795992 0.4788814147 +0.8788788789 0.4770449835 +0.8798798799 0.4751961668 +0.8808831295 0.4733338274 +0.8818854618 0.4714637127 +0.8828865393 0.4695863699 +0.8838866019 0.4677012668 +0.8848848849 0.4658097686 +0.8858858859 0.4639032196 +0.8868868869 0.4619866339 +0.8878878879 0.4600598858 +0.8888910506 0.4581186529 +0.8898922851 0.4561707147 +0.8908921884 0.4542148265 +0.8918918919 0.4522486630 +0.8928928929 0.4502691215 +0.8938952094 0.4482759803 +0.8948967283 0.4462732860 +0.8958976713 0.4442604670 +0.8968968969 0.4422397046 +0.8979013757 0.4401966827 +0.8989033242 0.4381470229 +0.8999065407 0.4360828109 +0.9009078226 0.4340104782 +0.9019070573 0.4319301564 +0.9029043232 0.4298415792 +0.9039052369 0.4277327703 +0.9049049049 0.4256138074 +0.9059059059 0.4234790309 +0.9069073164 0.4213301786 +0.9079106989 0.4191636468 +0.9089089089 0.4169947186 +0.9099123421 0.4148005903 +0.9109118139 0.4126010994 +0.9119119119 0.4103859950 +0.9129153075 0.4081490430 +0.9139171372 0.4059008085 +0.9149181522 0.4036394119 +0.9159183186 0.4013647140 +0.9169169169 0.3990781471 +0.9179199782 0.3967655650 +0.9189243362 0.3944338530 +0.9199199199 0.3921062878 +0.9209237083 0.3897428942 +0.9219256800 0.3873668036 +0.9229272591 0.3849743816 +0.9239276539 0.3825672364 +0.9249261890 0.3801467414 +0.9259296651 0.3776959826 +0.9269332918 0.3752261618 +0.9279340293 0.3727444664 +0.9289356506 0.3702412148 +0.9299412641 0.3677080981 +0.9309390654 0.3651745561 +0.9319389049 0.3626153299 +0.9329391161 0.3600341729 +0.9339474741 0.3574102904 +0.9349400788 0.3548056497 +0.9359359359 0.3521703051 +0.9369418354 0.3494853316 +0.9379434473 0.3467882491 +0.9389480540 0.3440589367 +0.9399461273 0.3413228350 +0.9409458343 0.3385571399 +0.9419450762 0.3357669929 +0.9429524712 0.3329273751 +0.9439566796 0.3300693671 +0.9449532058 0.3272054994 +0.9459634153 0.3242733677 +0.9469570607 0.3213601176 +0.9479562419 0.3184006336 +0.9489550553 0.3154113235 +0.9499623323 0.3123644780 +0.9509578453 0.3093205078 +0.9519580020 0.3062286115 +0.9529605489 0.3030943619 +0.9539580838 0.2999399514 +0.9549602688 0.2967336937 +0.9559631744 0.2934866424 +0.9569620350 0.2902131348 +0.9579638589 0.2868889072 +0.9589662177 0.2835203579 +0.9599641443 0.2801229046 +0.9609627600 0.2766777437 +0.9619627470 0.2731806607 +0.9629684589 0.2696140707 +0.9639745872 0.2659943518 +0.9649749823 0.2623419211 +0.9659803434 0.2586154985 +0.9669725468 0.2548805479 +0.9679833242 0.2510145097 +0.9690027864 0.2470497925 +0.9699937542 0.2431298355 +0.9709965510 0.2390934921 +0.9719965453 0.2349951404 +0.9730039315 0.2307885378 +0.9740234618 0.2264471149 +0.9750130104 0.2221477650 +0.9760117713 0.2177177584 +0.9770276696 0.2131124886 +0.9780334118 0.2084481841 +0.9790432917 0.2036522355 +0.9800456180 0.1987727009 +0.9810352692 0.1938293078 +0.9820827955 0.1884499477 +0.9830927312 0.1831083882 +0.9840943996 0.1776463136 +0.9851091672 0.1719300108 +0.9861321242 0.1659621451 +0.9871738308 0.1596490769 +0.9882408359 0.1529053638 +0.9892959260 0.1459231674 +0.9903307490 0.1387263765 +0.9913727364 0.1310728709 +0.9924590538 0.1225766151 +0.9935239974 0.1136224742 +0.9945787371 0.1039862289 +0.9956080275 0.0936197396 +0.9966472117 0.0818189182 +0.9976157780 0.0690127481 +0.9985299609 0.0542025562 +0.9993397922 0.0363315259 +1.0000000000 0.0000000000 diff --git a/src/problems/DTLZ/DTLZ7.txt b/src/problems/DTLZ/DTLZ7.txt new file mode 100644 index 0000000..6bc2040 --- /dev/null +++ b/src/problems/DTLZ/DTLZ7.txt @@ -0,0 +1,1000 @@ +0.0000000000 4.0000000000 +0.0009738826 3.9990171786 +0.0021185454 3.9978391568 +0.0031014163 3.9968079417 +0.0033247671 3.9965710677 +0.0041389401 3.9956996467 +0.0042370907 3.9955937518 +0.0044078709 3.9954090647 +0.0051622953 3.9945866401 +0.0056873226 3.9940079729 +0.0062436174 3.9933891907 +0.0068748002 3.9926800693 +0.0084741814 3.9908497281 +0.0098138794 3.9892796929 +0.0105927268 3.9883515137 +0.0109233360 3.9879540917 +0.0117373895 3.9869668401 +0.0118939028 3.9867756122 +0.0127792315 3.9856853382 +0.0129905545 3.9854229422 +0.0139693571 3.9841967728 +0.0148298175 3.9831041944 +0.0160348552 3.9815510917 +0.0169483628 3.9803558959 +0.0173311486 3.9798505146 +0.0180930256 3.9788366325 +0.0191737339 3.9773802425 +0.0202115709 3.9759615777 +0.0210850210 3.9747524524 +0.0223301163 3.9730049831 +0.0234578231 3.9713981550 +0.0243118619 3.9701660841 +0.0254225442 3.9685442830 +0.0264845632 3.9669730304 +0.0275410896 3.9653901130 +0.0282223667 3.9643589852 +0.0285616787 3.9638423924 +0.0289989977 3.9631736161 +0.0296596349 3.9621569994 +0.0298419959 3.9618750366 +0.0302615496 3.9612241387 +0.0308546202 3.9602988430 +0.0316434352 3.9590587411 +0.0317781803 3.9588458363 +0.0323535977 3.9579331376 +0.0330624338 3.9568010280 +0.0338967257 3.9554575813 +0.0339922311 3.9553030365 +0.0348654790 3.9538828145 +0.0357283956 3.9524667789 +0.0360152710 3.9519932550 +0.0368884980 3.9505434325 +0.0378989591 3.9488499618 +0.0381338164 3.9484539405 +0.0390467462 3.9469059329 +0.0402523617 3.9448407824 +0.0407923244 3.9439082160 +0.0415408632 3.9426076523 +0.0423709071 3.9411549863 +0.0425504181 3.9408393789 +0.0436713836 3.9388570111 +0.0444894524 3.9373978183 +0.0455053454 3.9355712350 +0.0459079573 3.9348429122 +0.0466079978 3.9335706037 +0.0477207229 3.9315328403 +0.0487265431 3.9296747269 +0.0494508805 3.9283272197 +0.0498712059 3.9275416955 +0.0508173726 3.9257639047 +0.0519897512 3.9235428992 +0.0530015739 3.9216100720 +0.0544573872 3.9188034899 +0.0550821792 3.9175898281 +0.0558326722 3.9161248017 +0.0562268420 3.9153522290 +0.0573715047 3.9130966279 +0.0580195636 3.9118117226 +0.0585668434 3.9107222400 +0.0593504859 3.9091552849 +0.0601081416 3.9076325963 +0.0604639327 3.9069149622 +0.0610883437 3.9056515540 +0.0612794624 3.9052638480 +0.0615201304 3.9047749596 +0.0620355365 3.9037254880 +0.0624546309 3.9028696429 +0.0630259231 3.9016994292 +0.0635563606 3.9006092513 +0.0638492831 3.9000057290 +0.0644712439 3.8987207720 +0.0656749059 3.8962206645 +0.0665156863 3.8944639865 +0.0668195687 3.8938270135 +0.0679189654 3.8915135375 +0.0685695769 3.8901378742 +0.0699119967 3.8872842800 +0.0708948881 3.8851822238 +0.0720305420 3.8827403702 +0.0731752048 3.8802652443 +0.0743936739 3.8776155520 +0.0752937501 3.8756485495 +0.0765541514 3.8728806027 +0.0771962902 3.8714644827 +0.0777846274 3.8701635661 +0.0783861781 3.8688300744 +0.0793365130 3.8667166137 +0.0805047234 3.8641074647 +0.0813873496 3.8621282087 +0.0820711509 3.8605902207 +0.0826232688 3.8593455445 +0.0831150791 3.8582347015 +0.0837679315 3.8567570762 +0.0847190627 3.8545982683 +0.0851481529 3.8536220397 +0.0859518161 3.8517898357 +0.0861500802 3.8513370836 +0.0868603595 3.8497127241 +0.0870444927 3.8492910240 +0.0876843916 3.8478236459 +0.0887283159 3.8454236205 +0.0889789048 3.8448463950 +0.0902118047 3.8420003665 +0.0910974502 3.8399498949 +0.0917646076 3.8384020554 +0.0924820598 3.8367345387 +0.0932159955 3.8350255988 +0.0940413496 3.8331001599 +0.0943606583 3.8323542528 +0.0954383431 3.8298327855 +0.0963082960 3.8277930258 +0.0965368748 3.8272564648 +0.0971761859 3.8257544368 +0.0974530862 3.8251032821 +0.0983425671 3.8230092523 +0.0985817456 3.8224455825 +0.0992947716 3.8207637658 +0.0995716316 3.8201101708 +0.0996821994 3.8198490626 +0.1016901770 3.8150990793 +0.1028348397 3.8123849634 +0.1036808357 3.8103763535 +0.1049533851 3.8073511268 +0.1056776102 3.8056275381 +0.1063739928 3.8039690386 +0.1070719304 3.8023057750 +0.1074847873 3.8013214287 +0.1082165932 3.7995758603 +0.1085322264 3.7988227005 +0.1089206249 3.7978956929 +0.1096383226 3.7961821558 +0.1105070100 3.7941072484 +0.1110540090 3.7928002951 +0.1116539911 3.7913664430 +0.1122829037 3.7898631721 +0.1127988911 3.7886296569 +0.1134275665 3.7871266076 +0.1139507595 3.7858756746 +0.1145525834 3.7844367113 +0.1153441660 3.7825440896 +0.1155250510 3.7821116272 +0.1163019073 3.7802544608 +0.1165199944 3.7797331546 +0.1166639015 3.7793891814 +0.1173739928 3.7776921105 +0.1177749718 3.7767339859 +0.1186385398 3.7746710855 +0.1197832025 3.7719381507 +0.1207732368 3.7695760288 +0.1211230982 3.7687417116 +0.1218683697 3.7669652629 +0.1222162765 3.7661363851 +0.1228756305 3.7645662498 +0.1238963299 3.7621377539 +0.1247786369 3.7600408074 +0.1249941758 3.7595288892 +0.1261388386 3.7568126830 +0.1278064968 3.7528634667 +0.1292312665 3.7494978685 +0.1303759293 3.7468001636 +0.1313923703 3.7444096733 +0.1316800163 3.7437340828 +0.1334683573 3.7395433088 +0.1343277532 3.7375355430 +0.1346277524 3.7368356554 +0.1355869026 3.7346015396 +0.1366390206 3.7321573280 +0.1377054480 3.7296870944 +0.1386738467 3.7274505204 +0.1393324823 3.7259330848 +0.1398239933 3.7248027095 +0.1406622683 3.7228789389 +0.1409686561 3.7221771191 +0.1415118606 3.7209346082 +0.1421354708 3.7195110169 +0.1430443840 3.7174416992 +0.1430872014 3.7173443831 +0.1440312047 3.7152027158 +0.1452057468 3.7125486421 +0.1462757029 3.7101415108 +0.1473242921 3.7077926145 +0.1477319776 3.7068821650 +0.1485991862 3.7049508146 +0.1490055675 3.7040482960 +0.1497099199 3.7024879186 +0.1504167201 3.7009271700 +0.1509422772 3.6997699798 +0.1515613828 3.6984105267 +0.1517420113 3.6980146631 +0.1526761439 3.6959730359 +0.1529792367 3.6953126457 +0.1537448364 3.6936490657 +0.1546538108 3.6916825295 +0.1547727977 3.6914258052 +0.1556686112 3.6894982963 +0.1557771778 3.6892653348 +0.1567723561 3.6871364304 +0.1573183306 3.6859735487 +0.1583169343 3.6838560913 +0.1588909015 3.6826446814 +0.1600355643 3.6802413059 +0.1614275641 3.6773416222 +0.1625250256 3.6750737493 +0.1631279922 3.6738347312 +0.1642726550 3.6714965031 +0.1649097481 3.6702031113 +0.1655318234 3.6689458214 +0.1660553047 3.6678921470 +0.1665541662 3.6668917612 +0.1670211860 3.6659585604 +0.1673650829 3.6652734600 +0.1676542003 3.6646988609 +0.1678879292 3.6642352627 +0.1685199480 3.6629858100 +0.1689039760 3.6622295962 +0.1694836283 3.6610924713 +0.1698447235 3.6603867356 +0.1706282910 3.6588623392 +0.1723792208 3.6554913357 +0.1733541773 3.6536358619 +0.1737207190 3.6529423411 +0.1746829743 3.6511323676 +0.1754869219 3.6496321515 +0.1758392643 3.6489781340 +0.1763294968 3.6480717176 +0.1766788151 3.6474283815 +0.1773692958 3.6461629865 +0.1779578097 3.6450910695 +0.1783651564 3.6443527207 +0.1789892023 3.6432273282 +0.1794963969 3.6423178172 +0.1800763550 3.6412835338 +0.1809349785 3.6397635666 +0.1813708716 3.6389971293 +0.1821949004 3.6375578779 +0.1828932308 3.6363481380 +0.1833395631 3.6355797723 +0.1838906441 3.6346363142 +0.1845514205 3.6335127333 +0.1856402450 3.6316797389 +0.1864319911 3.6303614234 +0.1873286902 3.6288833218 +0.1877690887 3.6281632474 +0.1885505364 3.6268951360 +0.1898906807 3.6247492404 +0.1906690818 3.6235197476 +0.1918137446 3.6217345893 +0.1923619043 3.6208894241 +0.1929848161 3.6199367056 +0.1939322899 3.6185034054 +0.1948685850 3.6171059326 +0.1953441806 3.6164033383 +0.1960508353 3.6153684962 +0.1971028902 3.6138481287 +0.1975834986 3.6131617162 +0.1981693806 3.6123318963 +0.1983898103 3.6120216722 +0.1987011894 3.6115853040 +0.1991887682 3.6109063850 +0.1998044752 3.6100567208 +0.2004162011 3.6092210653 +0.2009843196 3.6084526221 +0.2012618086 3.6080799741 +0.2018273682 3.6073259488 +0.2021475769 3.6069023060 +0.2022969625 3.6067054772 +0.2029519659 3.6058485669 +0.2033803539 3.6052935315 +0.2035407971 3.6050867593 +0.2040096989 3.6044859173 +0.2045747966 3.6037686818 +0.2054988993 3.6026120541 +0.2057031995 3.6023590843 +0.2071532071 3.6005923203 +0.2076174446 3.6000373494 +0.2086381266 3.5988355294 +0.2097359900 3.5975711705 +0.2104519291 3.5967625876 +0.2106691217 3.5965197884 +0.2118545353 3.5952152144 +0.2120985438 3.5949510151 +0.2126507459 3.5943586123 +0.2133202755 3.5936505919 +0.2136066806 3.5933511644 +0.2139730807 3.5929711207 +0.2144904593 3.5924402574 +0.2145888284 3.5923400918 +0.2152882050 3.5916350309 +0.2156188675 3.5913060183 +0.2156444358 3.5912806938 +0.2160916260 3.5908404707 +0.2164331304 3.5905077358 +0.2166973309 3.5902523733 +0.2173413982 3.5896373770 +0.2182101714 3.5888247858 +0.2203287167 3.5869255264 +0.2208800685 3.5864505107 +0.2217852587 3.5856880158 +0.2220782856 3.5854458220 +0.2224472621 3.5851440909 +0.2231167240 3.5846058710 +0.2234392054 3.5843508677 +0.2244434955 3.5835745202 +0.2245658074 3.5834818143 +0.2266843528 3.5819399670 +0.2274560434 3.5814085025 +0.2281736358 3.5809288264 +0.2281948050 3.5809148889 +0.2288028981 3.5805197542 +0.2309214435 3.5792223144 +0.2330399889 3.5780487183 +0.2339833462 3.5775662492 +0.2349761704 3.5770853098 +0.2351585342 3.5769999684 +0.2359931464 3.5766212945 +0.2361125812 3.5765687053 +0.2372770796 3.5760769974 +0.2388090110 3.5754884421 +0.2393956249 3.5752806678 +0.2399315365 3.5750993919 +0.2415141703 3.5746117705 +0.2423823045 3.5743746488 +0.2428777149 3.5742489946 +0.2436327156 3.5740710245 +0.2436819325 3.5740599907 +0.2446026537 3.5738663998 +0.2457512610 3.5736590758 +0.2465743428 3.5735338939 +0.2469972539 3.5734771784 +0.2472010818 3.5734516888 +0.2478698063 3.5733764965 +0.2490891576 3.5732727100 +0.2490915488 3.5732725488 +0.2499883517 3.5732237846 +0.2501224171 3.5732185000 +0.2502849372 3.5732127936 +0.2503599162 3.5732104195 +0.2507514231 3.5732006759 +0.2507883400 3.5731999869 +0.2513470184 3.5731943962 +0.6330812276 3.5639816814 +0.6334450606 3.5616657454 +0.6340134317 3.5580385117 +0.6343446234 3.5559196884 +0.6352896658 3.5498527276 +0.6354518463 3.5488084593 +0.6355549314 3.5481442316 +0.6355636060 3.5480883205 +0.6357165151 3.5471023341 +0.6365294852 3.5418467263 +0.6376821513 3.5343566939 +0.6389769061 3.5258904323 +0.6391004290 3.5250798360 +0.6398006967 3.5204750234 +0.6406933400 3.5145821141 +0.6419192420 3.5064475591 +0.6440377874 3.4922786418 +0.6445635280 3.4887410721 +0.6461563327 3.4779727015 +0.6464289599 3.4761220081 +0.6470678281 3.4717765941 +0.6482748781 3.4635342559 +0.6503934234 3.4489679085 +0.6515255900 3.4411327239 +0.6525119688 3.4342783470 +0.6526061021 3.4336228622 +0.6531805689 3.4296175937 +0.6546305141 3.4194703417 +0.6566139524 3.4055036429 +0.6567490595 3.4045487435 +0.6579146471 3.3962924769 +0.6583933525 3.3928923025 +0.6588676048 3.3895184819 +0.6594631886 3.3852741607 +0.6603953135 3.3786153621 +0.6609861502 3.3743845634 +0.6610020697 3.3742704620 +0.6613145813 3.3720294471 +0.6621415689 3.3660889125 +0.6623508080 3.3645835512 +0.6631046956 3.3591520697 +0.6632154830 3.3583528846 +0.6635465343 3.3559632713 +0.6652232409 3.3438261552 +0.6673417863 3.3284120452 +0.6687566769 3.3180710849 +0.6694603316 3.3129150341 +0.6705684953 3.3047776648 +0.6706263518 3.3043522499 +0.6708984608 3.3023507063 +0.6715788770 3.2973404830 +0.6723030777 3.2919996850 +0.6727424949 3.2887550786 +0.6729080586 3.2875318011 +0.6736974223 3.2816938175 +0.6742969880 3.2772533476 +0.6751664927 3.2708044441 +0.6758159677 3.2659805259 +0.6774403378 3.2538908779 +0.6776204701 3.2525481107 +0.6779345130 3.2502061564 +0.6781073463 3.2489167422 +0.6783368384 3.2472040631 +0.6800530584 3.2343763154 +0.6813641339 3.2245546023 +0.6821716037 3.2184966647 +0.6824725854 3.2162369326 +0.6842901491 3.2025729198 +0.6844657467 3.2012512659 +0.6853724324 3.1944229350 +0.6856244214 3.1925240131 +0.6864086944 3.1866108467 +0.6864314181 3.1864394500 +0.6865016483 3.1859097036 +0.6871562813 3.1809701298 +0.6879012854 3.1753451268 +0.6885272398 3.1706162603 +0.6902806521 3.1573579403 +0.6903790616 3.1566133491 +0.6904770254 3.1558720850 +0.6906457851 3.1545950214 +0.6911530067 3.1507559195 +0.6913020319 3.1496277504 +0.6921386169 3.1432928530 +0.6927643305 3.1385530344 +0.6929469536 3.1371694033 +0.6937737906 3.1309036570 +0.6941958086 3.1277048923 +0.6944821688 3.1255341253 +0.6947570077 3.1234505255 +0.6948828759 3.1224962450 +0.6957631272 3.1158217436 +0.6968913117 3.1072657543 +0.6970014212 3.1064306375 +0.6971630733 3.1052045871 +0.6991199666 3.0903622322 +0.6995106062 3.0873995464 +0.7000552887 3.0832688261 +0.7011094994 3.0752751929 +0.7012385119 3.0742970827 +0.7025732494 3.0641800393 +0.7033570573 3.0582412738 +0.7037034471 3.0556173982 +0.7043519877 3.0507059587 +0.7054756026 3.0422009182 +0.7075941480 3.0261821545 +0.7079016447 3.0238592677 +0.7083348193 3.0205880154 +0.7092477605 3.0136978166 +0.7097126933 3.0101911439 +0.7113869537 2.9975773441 +0.7115219838 2.9965610498 +0.7118312387 2.9942340680 +0.7120193045 2.9928193875 +0.7133044190 2.9831612251 +0.7137340402 2.9799360252 +0.7139497840 2.9783171256 +0.7140066735 2.9778903180 +0.7145641218 2.9737099085 +0.7153584230 2.9677590829 +0.7160683294 2.9624465304 +0.7162337072 2.9612097721 +0.7165501489 2.9588442047 +0.7181868747 2.9466285081 +0.7193169789 2.9382142918 +0.7195390166 2.9365631533 +0.7199757744 2.9333173118 +0.7203054201 2.9308692935 +0.7208855013 2.9265653265 +0.7213196692 2.9233472447 +0.7213707787 2.9229686043 +0.7224239654 2.9151751277 +0.7236204202 2.9063429019 +0.7236834209 2.9058784826 +0.7239044725 2.9042494919 +0.7245425108 2.8995522555 +0.7249382074 2.8966426609 +0.7250226771 2.8960219008 +0.7266610562 2.8840069223 +0.7283117026 2.8719526608 +0.7287796015 2.8685453717 +0.7297222591 2.8616942439 +0.7298357787 2.8608704249 +0.7308981469 2.8531738422 +0.7319497895 2.8455787989 +0.7330166922 2.8378985644 +0.7351352376 2.8227257584 +0.7355475447 2.8197852968 +0.7357356123 2.8184454294 +0.7361168675 2.8157318932 +0.7372537829 2.8076616308 +0.7384667282 2.7990881766 +0.7384908910 2.7989177769 +0.7390386255 2.7950592312 +0.7393723283 2.7927123718 +0.7409895983 2.7813814432 +0.7412170367 2.7797937766 +0.7413565609 2.7788205288 +0.7414908736 2.7778841523 +0.7423206695 2.7721105332 +0.7427190294 2.7693458339 +0.7436094190 2.7631831212 +0.7445065632 2.7569974754 +0.7457279643 2.7486154021 +0.7457761232 2.7482858458 +0.7466508785 2.7423124190 +0.7470368070 2.7396847096 +0.7478465097 2.7341870910 +0.7499650550 2.7199042529 +0.7505627007 2.7159021757 +0.7507220110 2.7148374214 +0.7520836004 2.7057729193 +0.7521291976 2.7054704823 +0.7530117782 2.6996309601 +0.7537097040 2.6950328457 +0.7539453411 2.6934843696 +0.7542021457 2.6917990849 +0.7543380819 2.6909079731 +0.7563206911 2.6779887052 +0.7576834102 2.6691945476 +0.7584392364 2.6643476934 +0.7589484424 2.6610948894 +0.7593788351 2.6583534988 +0.7605212792 2.6511124169 +0.7605577818 2.6508819175 +0.7612736335 2.6463724985 +0.7616076370 2.6442756206 +0.7616141265 2.6442349244 +0.7621286609 2.6410137628 +0.7626763272 2.6375971976 +0.7633812059 2.6332182664 +0.7647948725 2.6244993028 +0.7660511447 2.6168229824 +0.7669134179 2.6115939489 +0.7690319632 2.5988867948 +0.7690405740 2.5988355591 +0.7697340918 2.5947200786 +0.7710333522 2.5870694630 +0.7711505086 2.5863834405 +0.7716514847 2.5834571501 +0.7732690539 2.5740894238 +0.7740864984 2.5694028913 +0.7751927503 2.5631120645 +0.7753875993 2.5620102177 +0.7775061446 2.5501512278 +0.7790748465 2.5415151432 +0.7793528373 2.5399977986 +0.7796246900 2.5385177891 +0.7801836824 2.5354864999 +0.7817432353 2.5271151640 +0.7817780123 2.5269299391 +0.7830151487 2.5203824055 +0.7838617807 2.5159485391 +0.7859803260 2.5050230224 +0.7870804097 2.4994465719 +0.7878506274 2.4955821229 +0.7880988714 2.4943436414 +0.7884438071 2.4926284926 +0.7900618219 2.4846725883 +0.7902174167 2.4839153397 +0.7911031329 2.4796310935 +0.7912836890 2.4787632570 +0.7921248217 2.4747451634 +0.7923359621 2.4737429749 +0.7925973344 2.4725059458 +0.7928291365 2.4714121940 +0.7929073777 2.4710437226 +0.7944545075 2.4638313159 +0.7946819845 2.4627827555 +0.7949051540 2.4617570293 +0.7965730528 2.4541850402 +0.7967564674 2.4533625401 +0.7969797895 2.4523638160 +0.7975283310 2.4499234559 +0.7986915982 2.4448087319 +0.8008101435 2.4357068786 +0.8012536104 2.4338367720 +0.8016586244 2.4321395310 +0.8016821142 2.4320414095 +0.8029286889 2.4268838695 +0.8048280562 2.4192142470 +0.8048625939 2.4190769100 +0.8050472342 2.4183439927 +0.8056681720 2.4158952494 +0.8061180972 2.4141363955 +0.8067483086 2.4116947195 +0.8070283550 2.4106179607 +0.8071657796 2.4100914332 +0.8076605996 2.4082057470 +0.8078901192 2.4073364929 +0.8084731028 2.4051440339 +0.8092843249 2.4021302699 +0.8103133806 2.3983695777 +0.8114028703 2.3944644743 +0.8114232599 2.3943921436 +0.8115117473 2.3940785627 +0.8118348531 2.3929379813 +0.8135214156 2.3870979072 +0.8148738767 2.3825533702 +0.8153232969 2.3810707267 +0.8156399610 2.3800343175 +0.8157571046 2.3796526535 +0.8169996930 2.3756620638 +0.8177585063 2.3732773392 +0.8185738482 2.3707593105 +0.8190910611 2.3691858983 +0.8196043067 2.3676429544 +0.8198770517 2.3668304899 +0.8199692781 2.3665569373 +0.8207066427 2.3643912397 +0.8210879833 2.3632861663 +0.8212402820 2.3628476802 +0.8215850676 2.3618610298 +0.8219955970 2.3606971683 +0.8241141424 2.3548806527 +0.8250799617 2.3523349707 +0.8259895672 2.3499985234 +0.8262326878 2.3493840984 +0.8276119726 2.3459789630 +0.8282235202 2.3445132131 +0.8283512331 2.3442105362 +0.8292892201 2.3420238591 +0.8304697785 2.3393628702 +0.8308497804 2.3385280338 +0.8313761560 2.3373891233 +0.8317563491 2.3365791679 +0.8322091044 2.3356285055 +0.8325308331 2.3349621461 +0.8325883238 2.3348438765 +0.8341221363 2.3317787777 +0.8347068692 2.3306562008 +0.8352830528 2.3295749134 +0.8355073756 2.3291606300 +0.8366446559 2.3271180881 +0.8368254145 2.3268023571 +0.8377825570 2.3251713447 +0.8388147376 2.3234896158 +0.8389439599 2.3232847257 +0.8389633134 2.3232541479 +0.8396695435 2.3221576681 +0.8398818087 2.3218354729 +0.8400747080 2.3215456281 +0.8408181456 2.3204549112 +0.8410625052 2.3201055521 +0.8420204328 2.3187797367 +0.8424643972 2.3181889358 +0.8431810506 2.3172669447 +0.8437414488 2.3165732857 +0.8451417197 2.3149450304 +0.8452995959 2.3147708739 +0.8461951392 2.3138191957 +0.8467407600 2.3132695970 +0.8474181413 2.3126191704 +0.8483422790 2.3117888758 +0.8484470477 2.3116989078 +0.8486959637 2.3114885582 +0.8495366866 2.3108135238 +0.8504359451 2.3101520851 +0.8516552320 2.3093554811 +0.8516951756 2.3093313388 +0.8518483203 2.3092399265 +0.8524981207 2.3088723592 +0.8528294659 2.3086975866 +0.8532981371 2.3084649890 +0.8537737773 2.3082464460 +0.8558923227 2.3074876768 +0.8559499775 2.3074719341 +0.8580108681 2.3070802860 +0.8582126833 2.3070598446 +0.8588489740 2.3070163374 +0.8591170606 2.3070075316 +1.3601061168 2.3003318728 +1.3611074854 2.2866569019 +1.3620625914 2.2736259107 +1.3622246621 2.2714159552 +1.3630662717 2.2599461700 +1.3631358677 2.2589981666 +1.3636252155 2.2523346385 +1.3643432075 2.2425646118 +1.3651210497 2.2319900028 +1.3664617528 2.2137889705 +1.3664974772 2.2133044484 +1.3665427774 2.2126900881 +1.3667772290 2.2095110987 +1.3674016879 2.2010492287 +1.3680478918 2.1923010960 +1.3685802982 2.1851001611 +1.3706988435 2.1565093111 +1.3710267651 2.1520933117 +1.3726674545 2.1300394398 +1.3728173889 2.1280275408 +1.3749359342 2.0996659583 +1.3750827137 2.0977057150 +1.3754586385 2.0926881280 +1.3760331535 2.0850280672 +1.3761160743 2.0839233036 +1.3767621575 2.0753227253 +1.3770544796 2.0714356558 +1.3779353991 2.0597383865 +1.3783749635 2.0539110935 +1.3785505955 2.0515845351 +1.3791074778 2.0442144935 +1.3791730249 2.0433477038 +1.3794106054 2.0402071926 +1.3795652117 2.0381645380 +1.3797502468 2.0357209486 +1.3798523424 2.0343731739 +1.3812915703 2.0154131473 +1.3814666178 2.0131122224 +1.3834101156 1.9876430006 +1.3839159211 1.9810383669 +1.3848459524 1.9689209279 +1.3855286610 1.9600482428 +1.3876472064 1.9326398133 +1.3881498151 1.9261659111 +1.3892641604 1.9118527938 +1.3897200053 1.9060140273 +1.3897657517 1.9054286066 +1.3900499118 1.9017943605 +1.3915980107 1.8820619441 +1.3918842971 1.8784254683 +1.3936099379 1.8565915680 +1.3940028424 1.8516411900 +1.3961213878 1.8250865047 +1.3970464335 1.8135663476 +1.3982399331 1.7987720824 +1.3999648495 1.7775317154 +1.4003584785 1.7727085251 +1.4008997726 1.7660907235 +1.4024770238 1.7469063626 +1.4045955692 1.7213760475 +1.4052131976 1.7139857603 +1.4053754731 1.7120480492 +1.4055397101 1.7100886258 +1.4066013654 1.6974643783 +1.4066562232 1.6968140391 +1.4067141145 1.6961279510 +1.4088326599 1.6711723582 +1.4097812217 1.6600961924 +1.4105131521 1.6515916402 +1.4109512052 1.6465194634 +1.4122029456 1.6320996891 +1.4130602346 1.6222879819 +1.4130697506 1.6221793659 +1.4151882959 1.5981620654 +1.4158448392 1.5907861038 +1.4173068413 1.5744774575 +1.4194253867 1.5511353294 +1.4195198307 1.5501028731 +1.4201487250 1.5432457505 +1.4215029803 1.5285863561 +1.4215439320 1.5281453555 +1.4222919198 1.5201142714 +1.4231397809 1.5110659061 +1.4236624774 1.5055170928 +1.4241651937 1.5002016957 +1.4247507796 1.4940366064 +1.4257810227 1.4832599772 +1.4278995681 1.4613833185 +1.4284979140 1.4552748095 +1.4287630528 1.4525780009 +1.4288184118 1.4520157043 +1.4293628327 1.4465002134 +1.4300181134 1.4398962967 +1.4300198983 1.4398783610 +1.4321366588 1.4188079578 +1.4321830947 1.4183502595 +1.4342552041 1.3981272093 +1.4355013559 1.3861564888 +1.4363737495 1.3778628163 +1.4376788610 1.3655901113 +1.4384922948 1.3580233979 +1.4386154186 1.3568836341 +1.4388784198 1.3544539287 +1.4390712355 1.3526768813 +1.4406108402 1.3386174223 +1.4416871459 1.3289271200 +1.4420616681 1.3255821234 +1.4427293855 1.3196532037 +1.4428896853 1.3182364838 +1.4429993458 1.3172687967 +1.4441366384 1.3073043284 +1.4448479309 1.3011388981 +1.4451744050 1.2983263100 +1.4454995097 1.2955363544 +1.4455711662 1.2949228755 +1.4460066924 1.2912055163 +1.4469664762 1.2830824992 +1.4478703001 1.2755204740 +1.4486627167 1.2689607738 +1.4490850216 1.2654918352 +1.4500214419 1.2578669879 +1.4505565847 1.2535513438 +1.4506209809 1.2530340783 +1.4512035669 1.2483745646 +1.4516125409 1.2451253133 +1.4519418840 1.2425217826 +1.4524709416 1.2383639354 +1.4533221123 1.2317381730 +1.4535425869 1.2300347653 +1.4541474545 1.2253887167 +1.4554092401 1.2158258421 +1.4554208729 1.2157384942 +1.4554406577 1.2155899688 +1.4573528500 1.2014397532 +1.4575592030 1.1999370807 +1.4591979075 1.1881736515 +1.4596777484 1.1847864532 +1.4599994821 1.1825299532 +1.4614593497 1.1724392065 +1.4617962937 1.1701448441 +1.4621686616 1.1676244413 +1.4631524962 1.1610421758 +1.4639148391 1.1560188204 +1.4647714565 1.1504549128 +1.4656103721 1.1450890902 +1.4660333844 1.1424147558 +1.4672146185 1.1350585012 +1.4681519298 1.1293388270 +1.4685959805 1.1266656018 +1.4686383909 1.1264115175 +1.4693633992 1.1221011513 +1.4702704751 1.1167970106 +1.4713198242 1.1107844327 +1.4722931832 1.1053262774 +1.4723890205 1.1047950806 +1.4739972866 1.0960478875 +1.4745075658 1.0933386048 +1.4747048973 1.0922994551 +1.4757108074 1.0870767481 +1.4766261112 1.0824329423 +1.4773831011 1.0786707330 +1.4784822764 1.0733347095 +1.4787446565 1.0720832408 +1.4803256013 1.0647250638 +1.4808632019 1.0622944334 +1.4812992363 1.0603497578 +1.4822388507 1.0562407949 +1.4829817472 1.0530712367 +1.4836102009 1.0504446778 +1.4837545390 1.0498485277 +1.4841361970 1.0482849800 +1.4844246265 1.0471156888 +1.4851002926 1.0444181476 +1.4853100051 1.0435927626 +1.4854330553 1.0431110844 +1.4863858015 1.0394472950 +1.4867019686 1.0382572381 +1.4869320508 1.0373992905 +1.4872188380 1.0363394412 +1.4883507597 1.0322598929 +1.4893373833 1.0288391682 +1.4896971074 1.0276233641 +1.4897772890 1.0273546543 +1.4897774490 1.0273541188 +1.4902736574 1.0257097877 +1.4909658730 1.0234694502 +1.4914559287 1.0219211530 +1.4935744740 1.0155889910 +1.4949604314 1.0117650964 +1.4954467755 1.0104831977 +1.4956930194 1.0098460470 +1.4971132811 1.0063274879 +1.4978115647 1.0046954527 +1.4982089981 1.0037954391 +1.4997189021 1.0005674588 +1.4999301101 1.0001401053 +1.5020486554 0.9961826650 +1.5021177788 0.9960636434 +1.5026217059 0.9952152661 +1.5041672008 0.9928255541 +1.5059167521 0.9905073126 +1.5060400811 0.9903594289 +1.5062857461 0.9900709547 +1.5083859943 0.9879367847 +1.5084042915 0.9879208073 +1.5105228368 0.9863768096 +1.5106304107 0.9863146080 +1.5108511345 0.9861918864 +1.5112532151 0.9859852885 +1.5116122828 0.9858193051 +1.5120113062 0.9856553500 +1.5126413822 0.9854404150 +1.5128357826 0.9853849696 +1.5134294210 0.9852473946 +1.5147599275 0.9851128310 +2.0520675476 0.9808637692 +2.0525010452 0.9728379241 +2.0528704473 0.9660091293 +2.0536325606 0.9519511728 +2.0536332467 0.9519385359 +2.0541821211 0.9418398194 +2.0549124382 0.9284367677 +2.0549889926 0.9270340856 +2.0551680107 0.9237556870 +2.0556373528 0.9151718558 +2.0566504361 0.8967001191 +2.0570105110 0.8901536920 +2.0571075380 0.8883913825 +2.0576496217 0.8785589266 +2.0579958754 0.8722905213 +2.0581398676 0.8696865409 +2.0592260833 0.8500964320 +2.0593858998 0.8472221162 +2.0595426804 0.8444044151 +2.0613446287 0.8121645366 +2.0631297600 0.7804953361 +2.0633747836 0.7761699469 +2.0634631740 0.7746108824 +2.0635463352 0.7731446791 +2.0655817194 0.7374505332 +2.0658245485 0.7332169856 +2.0675828589 0.7027242206 +2.0676568094 0.7014480784 +2.0677002647 0.7006984238 +2.0684803886 0.6872707781 +2.0698188101 0.6643693537 +2.0715680357 0.6347026803 +2.0719373554 0.6284779809 +2.0727279385 0.6151993955 +2.0730399202 0.6099768630 +2.0740559008 0.5930388155 +2.0744384974 0.5866880370 +2.0753355358 0.5718581006 +2.0761744461 0.5580662137 +2.0775390540 0.5357931716 +2.0782929915 0.5235743714 +2.0785223296 0.5198699706 +2.0793232334 0.5069790478 +2.0804115369 0.4895773184 +2.0819323801 0.4654846416 +2.0820884406 0.4630274162 +2.0825300822 0.4560889120 +2.0827305155 0.4529474439 +2.0828635507 0.4508649194 +2.0839399498 0.4340913877 +2.0845349139 0.4248788089 +2.0846486276 0.4231228315 +2.0867671729 0.3906925718 +2.0867826818 0.3904571739 +2.0883243707 0.3672047149 +2.0888857183 0.3588114377 +2.0890728818 0.3560217288 +2.0893286560 0.3522164774 +2.0907639355 0.3310166773 +2.0910042636 0.3274925382 +2.0913868559 0.3218975354 +2.0931228090 0.2967487809 +2.0951553166 0.2678059379 +2.0951962739 0.2672283450 +2.0952413543 0.2665928658 +2.0973145729 0.2376632594 +2.0973598997 0.2370372806 +2.0982789259 0.2244058506 +2.0990554239 0.2138239643 +2.0994279771 0.2087765578 +2.0994539203 0.2084257931 +2.0994784450 0.2080942942 +2.0998453512 0.2031448468 +2.1009207559 0.1887465020 +2.1009371708 0.1885279870 +2.1011356344 0.1858890380 +2.1015969904 0.1797759520 +2.1037155357 0.1520940705 +2.1058340811 0.1250602316 +2.1059023023 0.1242005883 +2.1066269143 0.1151121869 +2.1075231115 0.1039791166 +2.1079526264 0.0986857778 +2.1097524383 0.0768056700 +2.1100711718 0.0729818071 +2.1121897172 0.0479591679 +2.1125031673 0.0443154426 +2.1135132398 0.0326772273 +2.1143082625 0.0236284540 +2.1146791784 0.0194405723 +2.1149305116 0.0166151208 +2.1153029186 0.0124468289 +2.1153084216 0.0123853986 +2.1164268079 0.0000000000 diff --git a/src/problems/ZDT/ZDT1.txt b/src/problems/ZDT/ZDT1.txt new file mode 100644 index 0000000..d11058c --- /dev/null +++ b/src/problems/ZDT/ZDT1.txt @@ -0,0 +1,1000 @@ +0.0000000001 0.9999894843 +0.0002103152 0.9854977511 +0.0006297138 0.9749059012 +0.0011612996 0.9659221532 +0.0017723350 0.9579008909 +0.0024447099 0.9505559926 +0.0031687919 0.9437079768 +0.0039380100 0.9372464341 +0.0047489797 0.9310871584 +0.0055918795 0.9252211292 +0.0064691896 0.9195687275 +0.0073740671 0.9141276114 +0.0082978126 0.9089076698 +0.0092456824 0.9038455287 +0.0102191774 0.8989100531 +0.0112003220 0.8941684261 +0.0122039498 0.8895285116 +0.0132172119 0.8850338664 +0.0142420309 0.8806600198 +0.0152859804 0.8763635151 +0.0163211988 0.8722455529 +0.0173715220 0.8681989301 +0.0184382204 0.8642125910 +0.0194878329 0.8604011717 +0.0205429616 0.8566718395 +0.0216119982 0.8529898023 +0.0226874279 0.8493765361 +0.0237651448 0.8458405214 +0.0248553652 0.8423441558 +0.0259467988 0.8389198994 +0.0270374622 0.8355692784 +0.0281393522 0.8322521170 +0.0292192881 0.8290634968 +0.0302957541 0.8259432445 +0.0313819561 0.8228504697 +0.0324638454 0.8198227390 +0.0335461426 0.8168439391 +0.0346247771 0.8139226584 +0.0357119454 0.8110239556 +0.0367916279 0.8081885616 +0.0378793499 0.8053738202 +0.0389433189 0.8026593834 +0.0399997201 0.8000006998 +0.0410631898 0.7973594567 +0.0421245632 0.7947573067 +0.0431927077 0.7921714464 +0.0442485743 0.7896465491 +0.0453108161 0.7871366259 +0.0463678279 0.7846680983 +0.0474309334 0.7822135602 +0.0484718366 0.7798367956 +0.0495183888 0.7774727236 +0.0505548969 0.7751558387 +0.0515956857 0.7728531626 +0.0526417769 0.7705620413 +0.0536804267 0.7683096317 +0.0547163017 0.7660848407 +0.0557571264 0.7638705304 +0.0567949321 0.7616831268 +0.0578289419 0.7595235108 +0.0588553007 0.7573988856 +0.0598860753 0.7552836840 +0.0609083639 0.7532038009 +0.0619349783 0.7511326089 +0.0629606370 0.7490804173 +0.0639905072 0.7470365498 +0.0650075274 0.7450342624 +0.0660281646 0.7430405391 +0.0670527767 0.7410544909 +0.0680657495 0.7391058653 +0.0690825195 0.7371644630 +0.0700995404 0.7352368221 +0.0711165289 0.7333231751 +0.0721371795 0.7314163454 +0.0731538057 0.7295303978 +0.0741739887 0.7276509800 +0.0751937914 0.7257851364 +0.0762103252 0.7239378237 +0.0772231944 0.7221093842 +0.0782394068 0.7202869206 +0.0792528891 0.7184811034 +0.0802645371 0.7166900335 +0.0812793931 0.7149045895 +0.0822923094 0.7131336384 +0.0833020611 0.7113790356 +0.0843148914 0.7096297340 +0.0853240314 0.7078972246 +0.0863361730 0.7061698228 +0.0873494798 0.7044505459 +0.0883580677 0.7027491503 +0.0893676528 0.7010557698 +0.0903801054 0.6993671585 +0.0913873872 0.6976965312 +0.0923974601 0.6960304948 +0.0934058712 0.6943762587 +0.0944170189 0.6927264754 +0.0954268425 0.6910876460 +0.0964393518 0.6894531407 +0.0974469856 0.6878350026 +0.0984532027 0.6862274667 +0.0994620038 0.6846240278 +0.1004686769 0.6830320570 +0.1014778843 0.6814440642 +0.1024834037 0.6798697083 +0.1034889593 0.6783030008 +0.1044969695 0.6767400899 +0.1055029432 0.6751878340 +0.1065113264 0.6736392695 +0.1075171046 0.6721019905 +0.1085246735 0.6705691674 +0.1095345919 0.6690398938 +0.1105412889 0.6675224987 +0.1115502884 0.6660085504 +0.1125586220 0.6645024262 +0.1135692240 0.6629996676 +0.1145703720 0.6615175455 +0.1155736397 0.6600387673 +0.1165790942 0.6585631915 +0.1175826917 0.6570966730 +0.1185884398 0.6556332772 +0.1195925525 0.6541784384 +0.1205987817 0.6527266470 +0.1216048952 0.6512810657 +0.1226117877 0.6498403398 +0.1236138187 0.6484124309 +0.1246178887 0.6469874100 +0.1256223393 0.6455675814 +0.1266288059 0.6441505854 +0.1276331204 0.6427422214 +0.1286375304 0.6413392544 +0.1296439087 0.6399390208 +0.1306492659 0.6385456241 +0.1316565646 0.6371549028 +0.1326627997 0.6357709516 +0.1336661888 0.6343961312 +0.1346714681 0.6330238861 +0.1356757096 0.6316581621 +0.1366794375 0.6302981775 +0.1376834503 0.6289427937 +0.1386893002 0.6275898763 +0.1396927198 0.6262451073 +0.1406979479 0.6249027488 +0.1417017801 0.6235670311 +0.1427051064 0.6222367059 +0.1437102024 0.6209087150 +0.1447137172 0.6195874381 +0.1457167842 0.6182713212 +0.1467215834 0.6169574653 +0.1477250332 0.6156498560 +0.1487301929 0.6143444634 +0.1497321205 0.6130476509 +0.1507357298 0.6117530041 +0.1517373003 0.6104652772 +0.1527405289 0.6091796718 +0.1537442813 0.6078976138 +0.1547476447 0.6066202285 +0.1557526398 0.6053449104 +0.1567551035 0.6040768970 +0.1577568569 0.6028138259 +0.1587602057 0.6015527567 +0.1597621685 0.6002973999 +0.1607657072 0.5990440084 +0.1617683085 0.5977956881 +0.1627724681 0.5965492990 +0.1637763198 0.5953071291 +0.1647798412 0.5940691670 +0.1657848951 0.5928330870 +0.1667889969 0.5916019137 +0.1677946146 0.5903725906 +0.1687971345 0.5891507156 +0.1698011474 0.5879306521 +0.1708037274 0.5867159240 +0.1718067926 0.5855041706 +0.1728113261 0.5842941832 +0.1738141690 0.5830897351 +0.1748184625 0.5818870218 +0.1758228774 0.5806876136 +0.1768242806 0.5794952073 +0.1778252033 0.5783067427 +0.1788275384 0.5771199480 +0.1798308764 0.5759352922 +0.1808348055 0.5747532416 +0.1818367667 0.5735767752 +0.1828401120 0.5724019271 +0.1838421355 0.5712318395 +0.1848455281 0.5700633441 +0.1858496519 0.5688971679 +0.1868523609 0.5677357742 +0.1878564187 0.5665759366 +0.1888596307 0.5654201677 +0.1898641784 0.5642659315 +0.1908653578 0.5631185998 +0.1918678536 0.5619727707 +0.1928709340 0.5608292655 +0.1938736345 0.5596891615 +0.1948776348 0.5585505297 +0.1958799520 0.5574167287 +0.1968825267 0.5562855348 +0.1978863809 0.5551557791 +0.1988885986 0.5540307201 +0.1998908284 0.5529084787 +0.2008943177 0.5517876422 +0.2018966761 0.5506708599 +0.2029002818 0.5495554620 +0.2039023420 0.5484445305 +0.2049056364 0.5473349622 +0.2059090098 0.5462280200 +0.2069098050 0.5451266055 +0.2079116420 0.5440267091 +0.2089146888 0.5429281361 +0.2099165426 0.5418334991 +0.2109195946 0.5407401666 +0.2119213054 0.5396508875 +0.2129237064 0.5385634318 +0.2139272900 0.5374772546 +0.2149292816 0.5363953391 +0.2159324438 0.5353146830 +0.2169335265 0.5342387666 +0.2179354426 0.5331644373 +0.2189385128 0.5320913414 +0.2199411096 0.5310212056 +0.2209443987 0.5299527698 +0.2219479223 0.5288865080 +0.2229497945 0.5278244029 +0.2239527947 0.5267634896 +0.2249543898 0.5257064308 +0.2259571022 0.5246505473 +0.2269598923 0.5235969225 +0.2279637924 0.5225444603 +0.2289652239 0.5214968925 +0.2299677528 0.5204504689 +0.2309696262 0.5194070056 +0.2319710025 0.5183663192 +0.2329726679 0.5173275771 +0.2339754122 0.5162899502 +0.2349757427 0.5152570344 +0.2359771401 0.5142252167 +0.2369784365 0.5131956897 +0.2379807928 0.5121672492 +0.2389819466 0.5111422021 +0.2399841512 0.5101182274 +0.2409854406 0.5090973206 +0.2419877723 0.5080774732 +0.2429890820 0.5070607725 +0.2439914253 0.5060451181 +0.2449932324 0.5050320895 +0.2459960658 0.5040200954 +0.2469978573 0.5030112101 +0.2480006667 0.5020033467 +0.2490023296 0.5009986678 +0.2500037119 0.4999962881 +0.2510060990 0.4989949112 +0.2520081964 0.4979958203 +0.2530090762 0.4969999242 +0.2540106605 0.4960052971 +0.2550132341 0.4950116496 +0.2560153554 0.4940204002 +0.2570169550 0.4930316035 +0.2580190482 0.4920442458 +0.2590211470 0.4910587981 +0.2600222448 0.4900762363 +0.2610243081 0.4890946192 +0.2620263758 0.4881148803 +0.2630278416 0.4871375997 +0.2640302625 0.4861612486 +0.2650327522 0.4851866822 +0.2660342736 0.4842148959 +0.2670367394 0.4832440234 +0.2680384765 0.4822756752 +0.2690402992 0.4813090524 +0.2700420822 0.4803442657 +0.2710447960 0.4793803730 +0.2720467529 0.4784189872 +0.2730496341 0.4774584857 +0.2740510135 0.4765011810 +0.2750524520 0.4755455673 +0.2760548037 0.4745908226 +0.2770557516 0.4736391432 +0.2780568760 0.4726890140 +0.2790589031 0.4717397393 +0.2800605035 0.4707925704 +0.2810630011 0.4698462477 +0.2820640714 0.4689029548 +0.2830660316 0.4679604981 +0.2840671392 0.4670205077 +0.2850691304 0.4660813447 +0.2860712583 0.4651437032 +0.2870727459 0.4642082999 +0.2880751084 0.4632737118 +0.2890765211 0.4623416316 +0.2900778233 0.4614112670 +0.2910799911 0.4604817046 +0.2920820420 0.4595538491 +0.2930830765 0.4586285227 +0.2940849672 0.4577039856 +0.2950867089 0.4567811593 +0.2960893022 0.4558591155 +0.2970902136 0.4549401743 +0.2980913730 0.4540225527 +0.2990933745 0.4531057008 +0.3000947068 0.4521909942 +0.3010968758 0.4512770500 +0.3020989432 0.4503647181 +0.3031018428 0.4494531420 +0.3041017718 0.4485457663 +0.3051025241 0.4476391359 +0.3061030785 0.4467341702 +0.3071044517 0.4458299433 +0.3081053668 0.4449276022 +0.3091070962 0.4440259933 +0.3101083583 0.4431262636 +0.3111099191 0.4422277176 +0.3121122872 0.4413298941 +0.3131149498 0.4404332481 +0.3141158017 0.4395396520 +0.3151174522 0.4386467670 +0.3161181726 0.4377561271 +0.3171196864 0.4368661914 +0.3181217641 0.4359771599 +0.3191235216 0.4350898110 +0.3201260665 0.4342031579 +0.3211272782 0.4333190685 +0.3221292714 0.4324356676 +0.3231305050 0.4315543078 +0.3241321845 0.4306739207 +0.3251346391 0.4297942134 +0.3261355068 0.4289172505 +0.3271364512 0.4280415651 +0.3281381625 0.4271665490 +0.3291396056 0.4262931013 +0.3301418116 0.4254203175 +0.3311425891 0.4245500986 +0.3321436033 0.4236809883 +0.3331453728 0.4228125324 +0.3341459404 0.4219464208 +0.3351472582 0.4210809571 +0.3361489823 0.4202164350 +0.3371507677 0.4193531471 +0.3381524780 0.4184912056 +0.3391549311 0.4176299019 +0.3401567307 0.4167704305 +0.3411582977 0.4159124229 +0.3421606009 0.4150550446 +0.3431622914 0.4141994441 +0.3441647139 0.4133444674 +0.3451667125 0.4124910958 +0.3461677626 0.4116397680 +0.3471695375 0.4107890552 +0.3481717360 0.4099392099 +0.3491724318 0.4090918584 +0.3501738456 0.4082451135 +0.3511740724 0.4074005802 +0.3521750124 0.4065566477 +0.3531759396 0.4057139245 +0.3541775770 0.4048717979 +0.3551786772 0.4040313119 +0.3561801620 0.4031916874 +0.3571823517 0.4023526527 +0.3581834097 0.4015157398 +0.3591851682 0.4006794112 +0.3601857453 0.3998452322 +0.3611863629 0.3990121774 +0.3621875029 0.3981798417 +0.3631893357 0.3973480808 +0.3641910201 0.3965175892 +0.3651921942 0.3956886612 +0.3661940554 0.3948603009 +0.3671954009 0.3940334985 +0.3681962477 0.3932082337 +0.3691974477 0.3923837990 +0.3701989322 0.3915602476 +0.3712010950 0.3907372529 +0.3722026586 0.3899158594 +0.3732040997 0.3890956706 +0.3742062136 0.3882760316 +0.3752075512 0.3874581229 +0.3762095577 0.3866407597 +0.3772115816 0.3858244701 +0.3782126106 0.3850100728 +0.3792143028 0.3841962140 +0.3802158394 0.3833835557 +0.3812180365 0.3825714321 +0.3822199836 0.3817605775 +0.3832214717 0.3809511557 +0.3842236149 0.3801422623 +0.3852249508 0.3793350737 +0.3862261312 0.3785290585 +0.3872279612 0.3777235653 +0.3882290167 0.3769197349 +0.3892307183 0.3761164224 +0.3902315329 0.3753148530 +0.3912329899 0.3745137972 +0.3922341711 0.3737139862 +0.3932356676 0.3729149439 +0.3942368997 0.3721171290 +0.3952387682 0.3713198204 +0.3962404890 0.3705236390 +0.3972416358 0.3697289188 +0.3982426535 0.3689353017 +0.3992443010 0.3681421829 +0.4002458160 0.3673501632 +0.4012476451 0.3665588859 +0.4022491451 0.3657688551 +0.4032503499 0.3649800398 +0.4042521769 0.3641917137 +0.4052537047 0.3634045989 +0.4062556224 0.3626181502 +0.4072569386 0.3618331421 +0.4082588710 0.3610486161 +0.4092606576 0.3602651662 +0.4102617331 0.3594832296 +0.4112624413 0.3587025329 +0.4122637590 0.3579223108 +0.4132653697 0.3571428077 +0.4142662300 0.3563648316 +0.4152676955 0.3555873252 +0.4162692852 0.3548106594 +0.4172703805 0.3540353102 +0.4182720770 0.3532604257 +0.4192733529 0.3524867933 +0.4202752273 0.3517136225 +0.4212756052 0.3509425255 +0.4222765645 0.3501718962 +0.4232781177 0.3494017233 +0.4242787754 0.3486331484 +0.4252800238 0.3478650264 +0.4262810561 0.3470979736 +0.4272826768 0.3463313708 +0.4282838288 0.3455660241 +0.4292855666 0.3448011244 +0.4302867936 0.3440375060 +0.4312875044 0.3432751684 +0.4322886274 0.3425134013 +0.4332899081 0.3417523960 +0.4342917680 0.3409918301 +0.4352931925 0.3402324708 +0.4362941875 0.3394743097 +0.4372952371 0.3387169766 +0.4382968603 0.3379600765 +0.4392987002 0.3372038774 +0.4403003992 0.3364486461 +0.4413025499 0.3356939336 +0.4423036524 0.3349408655 +0.4433045196 0.3341888259 +0.4443059523 0.3334372105 +0.4453071467 0.3326866203 +0.4463088270 0.3319365097 +0.4473098391 0.3311877400 +0.4483114119 0.3304393889 +0.4493127632 0.3296920385 +0.4503146730 0.3289451044 +0.4513157024 0.3281996558 +0.4523164657 0.3274552315 +0.4533177831 0.3267112187 +0.4543188312 0.3259682269 +0.4553201613 0.3252258443 +0.4563210560 0.3244845997 +0.4573225003 0.3237437614 +0.4583238268 0.3230038207 +0.4593257008 0.3222642840 +0.4603267214 0.3215261823 +0.4613282868 0.3207884816 +0.4623293171 0.3200519747 +0.4633308899 0.3193158663 +0.4643320495 0.3185808562 +0.4653337494 0.3178462421 +0.4663344235 0.3171131693 +0.4673354687 0.3163806112 +0.4683365246 0.3156488294 +0.4693381161 0.3149174385 +0.4703397160 0.3141868214 +0.4713408502 0.3134573209 +0.4723419756 0.3127286012 +0.4733436321 0.3120002674 +0.4743446608 0.3112731596 +0.4753462181 0.3105464351 +0.4763472245 0.3098208751 +0.4773487573 0.3090956960 +0.4783501167 0.3083714026 +0.4793520007 0.3076474881 +0.4803525678 0.3069252798 +0.4813533187 0.3062036908 +0.4823545902 0.3054824766 +0.4833559019 0.3047619819 +0.4843571489 0.3040422794 +0.4853589138 0.3033229487 +0.4863606119 0.3026044079 +0.4873615883 0.3018871235 +0.4883630792 0.3011702073 +0.4893643031 0.3004542166 +0.4903654765 0.2997389940 +0.4913671616 0.2990241363 +0.4923677196 0.2983108098 +0.4933687866 0.2975978456 +0.4943702513 0.2968853214 +0.4953720027 0.2961733149 +0.4963729128 0.2954626250 +0.4973743280 0.2947522931 +0.4983753948 0.2940429228 +0.4993769647 0.2933339086 +0.5003777125 0.2926261861 +0.5013789612 0.2919188173 +0.5023800189 0.2912122893 +0.5033815757 0.2905061130 +0.5043826400 0.2898009856 +0.5053842016 0.2890962079 +0.5063854717 0.2883923330 +0.5073872373 0.2876888058 +0.5083889007 0.2869860445 +0.5093897165 0.2862845689 +0.5103909713 0.2855834749 +0.5113927177 0.2848827245 +0.5123935702 0.2841832845 +0.5133949120 0.2834841858 +0.5143963044 0.2827857332 +0.5153968896 0.2820885224 +0.5163976842 0.2813918424 +0.5173989641 0.2806954997 +0.5184004520 0.2799996861 +0.5194012903 0.2793049949 +0.5204018643 0.2786111560 +0.5214029196 0.2779176504 +0.5224037735 0.2772249496 +0.5234051073 0.2765325803 +0.5244057131 0.2758413757 +0.5254067967 0.2751505007 +0.5264080749 0.2744601493 +0.5274095904 0.2737702909 +0.5284107867 0.2730813066 +0.5294124578 0.2723926486 +0.5304134599 0.2717051010 +0.5314145860 0.2710181168 +0.5324161841 0.2703314560 +0.5334174758 0.2696456505 +0.5344186562 0.2689605645 +0.5354198349 0.2682761211 +0.5364214821 0.2675919975 +0.5374231840 0.2669084750 +0.5384241045 0.2662261217 +0.5394254907 0.2655440853 +0.5404269200 0.2648626523 +0.5414278987 0.2641821566 +0.5424285603 0.2635025049 +0.5434296837 0.2628231666 +0.5444310258 0.2621443056 +0.5454323428 0.2614660856 +0.5464335108 0.2607885886 +0.5474343417 0.2601119398 +0.5484352321 0.2594358690 +0.5494365797 0.2587601065 +0.5504375180 0.2580852354 +0.5514389117 0.2574106709 +0.5524404694 0.2567366083 +0.5534411993 0.2560637129 +0.5544423819 0.2553911215 +0.5554438198 0.2547189659 +0.5564448574 0.2540476843 +0.5574461165 0.2533768578 +0.5584478256 0.2527063324 +0.5594491886 0.2520366395 +0.5604500000 0.2513679142 +0.5614512125 0.2506995179 +0.5624528717 0.2500314195 +0.5634549518 0.2493636355 +0.5644561107 0.2486970579 +0.5654577141 0.2480307759 +0.5664582806 0.2473657724 +0.5674592894 0.2467010624 +0.5684602005 0.2460370032 +0.5694615527 0.2453732362 +0.5704629576 0.2447100175 +0.5714641608 0.2440475142 +0.5724654756 0.2433855172 +0.5734672286 0.2427238096 +0.5744680511 0.2420632935 +0.5754693100 0.2414030649 +0.5764697757 0.2407439327 +0.5774704561 0.2400852311 +0.5784715703 0.2394268146 +0.5794722894 0.2387692273 +0.5804734408 0.2381119237 +0.5814749025 0.2374549833 +0.5824759068 0.2367989081 +0.5834765886 0.2361436073 +0.5844776999 0.2354885875 +0.5854784090 0.2348343911 +0.5864795462 0.2341804742 +0.5874804650 0.2335272575 +0.5884814714 0.2328745400 +0.5894829039 0.2322220999 +0.5904841227 0.2315703528 +0.5914852917 0.2309191904 +0.5924868846 0.2302683035 +0.5934884263 0.2296179998 +0.5944895742 0.2289684998 +0.5954904730 0.2283197080 +0.5964917927 0.2276711888 +0.5974928613 0.2270233760 +0.5984940903 0.2263760020 +0.5994956347 0.2257289656 +0.6004967023 0.2250827771 +0.6014981875 0.2244368578 +0.6024993232 0.2237917012 +0.6035002904 0.2231471887 +0.6045016730 0.2225029434 +0.6055025383 0.2218595639 +0.6065038176 0.2212164501 +0.6075050713 0.2205738834 +0.6085062356 0.2199319032 +0.6095078120 0.2192901871 +0.6105086888 0.2186494456 +0.6115099762 0.2180089667 +0.6125114577 0.2173688879 +0.6135126807 0.2167294971 +0.6145143125 0.2160903671 +0.6155151153 0.2154522862 +0.6165163252 0.2148144645 +0.6175175368 0.2141771594 +0.6185185992 0.2135404657 +0.6195195973 0.2129043277 +0.6205210002 0.2122684466 +0.6215226154 0.2116329437 +0.6225233172 0.2109985316 +0.6235244214 0.2103643743 +0.6245257479 0.2097305852 +0.6255267345 0.2090975190 +0.6265281218 0.2084647059 +0.6275295273 0.2078323869 +0.6285308933 0.2072005971 +0.6295318748 0.2065695526 +0.6305332546 0.2059387589 +0.6315339696 0.2053088842 +0.6325350814 0.2046792588 +0.6335364007 0.2040500011 +0.6345377382 0.2034212291 +0.6355385583 0.2027932776 +0.6365397727 0.2021655732 +0.6375407380 0.2015385182 +0.6385419343 0.2009118107 +0.6395432199 0.2002855385 +0.6405448978 0.1996595113 +0.6415457759 0.1990344727 +0.6425470447 0.1984096778 +0.6435481693 0.1977854593 +0.6445496837 0.1971614835 +0.6455511954 0.1965379938 +0.6465521894 0.1959153096 +0.6475530688 0.1952931784 +0.6485543353 0.1946712874 +0.6495554858 0.1940499483 +0.6505563874 0.1934292422 +0.6515576742 0.1928087747 +0.6525587103 0.1921889390 +0.6535596358 0.1915696469 +0.6545609448 0.1909505918 +0.6555621420 0.1903320792 +0.6565628695 0.1897143285 +0.6575639075 0.1890968569 +0.6585649820 0.1884798326 +0.6595660804 0.1878632625 +0.6605675589 0.1872469263 +0.6615690601 0.1866310431 +0.6625702503 0.1860158169 +0.6635718189 0.1854008231 +0.6645734446 0.1847862583 +0.6655743074 0.1841726240 +0.6665755394 0.1835592248 +0.6675771477 0.1829460558 +0.6685778451 0.1823339037 +0.6695786084 0.1817221692 +0.6705795914 0.1811107575 +0.6715809484 0.1804995739 +0.6725815516 0.1798893053 +0.6735824170 0.1792793307 +0.6745836545 0.1786695826 +0.6755849960 0.1780602236 +0.6765863940 0.1774512817 +0.6775870496 0.1768432412 +0.6785880749 0.1762354251 +0.6795890291 0.1756281002 +0.6805903522 0.1750209989 +0.6815913005 0.1744145710 +0.6825923463 0.1738085293 +0.6835936242 0.1732027914 +0.6845952689 0.1725972752 +0.6855961635 0.1719926549 +0.6865974237 0.1713882552 +0.6875983946 0.1707844703 +0.6885995083 0.1701810389 +0.6896009860 0.1695778266 +0.6906018299 0.1689754336 +0.6916030367 0.1683732588 +0.6926040693 0.1677716243 +0.6936051583 0.1671703906 +0.6946066087 0.1665693738 +0.6956081144 0.1659687570 +0.6966087417 0.1653690985 +0.6976097286 0.1647696554 +0.6986107311 0.1641706328 +0.6996120925 0.1635718247 +0.7006128849 0.1629737848 +0.7016140349 0.1623759585 +0.7026149662 0.1617786890 +0.7036162542 0.1611816322 +0.7046173934 0.1605850886 +0.7056187329 0.1599888495 +0.7066196879 0.1593932620 +0.7076209976 0.1587978854 +0.7086222330 0.1582029740 +0.7096231569 0.1576086676 +0.7106242107 0.1570147032 +0.7116250435 0.1564212879 +0.7126259416 0.1558282511 +0.7136271913 0.1552354226 +0.7146280968 0.1546432133 +0.7156293530 0.1540512113 +0.7166303756 0.1534597614 +0.7176317479 0.1528685179 +0.7186332155 0.1522776306 +0.7196340181 0.1516875469 +0.7206351688 0.1510976683 +0.7216358525 0.1505084741 +0.7226367795 0.1499195453 +0.7236380533 0.1493308203 +0.7246394866 0.1487424088 +0.7256403528 0.1481547366 +0.7266412523 0.1475674500 +0.7276424968 0.1469803655 +0.7286437738 0.1463936658 +0.7296449298 0.1458074398 +0.7306464295 0.1452214149 +0.7316471101 0.1446362703 +0.7326481332 0.1440513256 +0.7336491728 0.1434667708 +0.7346501133 0.1428826724 +0.7356513949 0.1422987730 +0.7366525763 0.1417153291 +0.7376535200 0.1411324200 +0.7386546873 0.1405497761 +0.7396557111 0.1399676105 +0.7406570737 0.1393856417 +0.7416580993 0.1388042619 +0.7426591227 0.1382232756 +0.7436604837 0.1376424850 +0.7446618415 0.1370620871 +0.7456626999 0.1364823685 +0.7466638944 0.1359028444 +0.7476649673 0.1353237789 +0.7486659356 0.1347451615 +0.7496671382 0.1341667954 +0.7506682343 0.1335888769 +0.7516696643 0.1330111510 +0.7526706712 0.1324340537 +0.7536717145 0.1318573191 +0.7546730904 0.1312807759 +0.7556745018 0.1307045946 +0.7566754738 0.1301290476 +0.7576762216 0.1295540100 +0.7586773001 0.1289791621 +0.7596783202 0.1284047269 +0.7606796703 0.1278304808 +0.7616811144 0.1272565587 +0.7626823795 0.1266831162 +0.7636839735 0.1261098619 +0.7646847839 0.1255374314 +0.7656859219 0.1249651882 +0.7666872205 0.1243932273 +0.7676885121 0.1238216437 +0.7686896065 0.1232505452 +0.7696910270 0.1226796326 +0.7706919092 0.1221093979 +0.7716931166 0.1215393483 +0.7726940288 0.1209698362 +0.7736952654 0.1204005085 +0.7746962081 0.1198317160 +0.7756974744 0.1192631072 +0.7766986881 0.1186948950 +0.7776994921 0.1181272813 +0.7787005425 0.1175598930 +0.7797015898 0.1169928710 +0.7807029587 0.1164260310 +0.7817041419 0.1158596594 +0.7827056459 0.1152934691 +0.7837066697 0.1147279120 +0.7847075981 0.1141627700 +0.7857088459 0.1135978081 +0.7867097986 0.1130333723 +0.7877110700 0.1124691160 +0.7887118670 0.1119054853 +0.7897129817 0.1113420333 +0.7907138703 0.1107790655 +0.7917150758 0.1102162758 +0.7927158703 0.1096540727 +0.7937169808 0.1090920469 +0.7947177613 0.1085305607 +0.7957188569 0.1079692511 +0.7967200529 0.1074082384 +0.7977208339 0.1068478103 +0.7987219291 0.1062875580 +0.7997228517 0.1057277530 +0.8007240878 0.1051681232 +0.8017250764 0.1046089813 +0.8027261482 0.1040501419 +0.8037271570 0.1034916860 +0.8047284777 0.1029334040 +0.8057294740 0.1023756498 +0.8067307814 0.1018180689 +0.8077319714 0.1012608992 +0.8087331365 0.1007040885 +0.8097339845 0.1001477985 +0.8107351420 0.0995916804 +0.8117364375 0.0990358290 +0.8127375240 0.0984804361 +0.8137385638 0.0979254112 +0.8147399117 0.0973705568 +0.8157408920 0.0968162468 +0.8167421797 0.0962621068 +0.8177431682 0.0957084717 +0.8187444633 0.0951550059 +0.8197455532 0.0946019919 +0.8207469489 0.0940491466 +0.8217481147 0.0934967652 +0.8227495857 0.0929445520 +0.8237510513 0.0923926778 +0.8247522421 0.0918412903 +0.8257537368 0.0912900700 +0.8267544619 0.0907396072 +0.8277552475 0.0901894442 +0.8287562618 0.0896394880 +0.8297572276 0.0890898905 +0.8307584954 0.0885404587 +0.8317597138 0.0879913850 +0.8327606867 0.0874427762 +0.8337619605 0.0868943323 +0.8347627055 0.0863465069 +0.8357636616 0.0857988943 +0.8367649176 0.0852514457 +0.8377660281 0.0847044040 +0.8387667224 0.0841579162 +0.8397676397 0.0836116327 +0.8407688554 0.0830655119 +0.8417696709 0.0825199343 +0.8427707840 0.0819745189 +0.8437714494 0.0814296709 +0.8447724117 0.0808849845 +0.8457735560 0.0803405217 +0.8467747674 0.0797963446 +0.8477754203 0.0792527924 +0.8487763687 0.0787094005 +0.8497772153 0.0781663842 +0.8507783567 0.0776235277 +0.8517792627 0.0770811180 +0.8527804629 0.0765388677 +0.8537814690 0.0759970406 +0.8547825058 0.0754555144 +0.8557838358 0.0749141468 +0.8567851958 0.0743730796 +0.8577865119 0.0738323522 +0.8587879522 0.0732918732 +0.8597887845 0.0727520372 +0.8607898296 0.0722124006 +0.8617911659 0.0716729209 +0.8627921776 0.0711339291 +0.8637930359 0.0705953325 +0.8647941843 0.0700568919 +0.8657951783 0.0695188458 +0.8667961226 0.0689811373 +0.8677973561 0.0684435841 +0.8687986808 0.0679062918 +0.8697993534 0.0673696588 +0.8708001677 0.0668332584 +0.8718011741 0.0662970633 +0.8728024680 0.0657610220 +0.8738039536 0.0652251856 +0.8748050259 0.0646898771 +0.8758060549 0.0641548980 +0.8768073370 0.0636200894 +0.8778089051 0.0630854334 +0.8788095456 0.0625515771 +0.8798103062 0.0620179606 +0.8808113516 0.0614844958 +0.8818125165 0.0609512704 +0.8828136959 0.0604183400 +0.8838144803 0.0598859217 +0.8848153253 0.0593537725 +0.8858164535 0.0588217738 +0.8868176417 0.0582900438 +0.8878189258 0.0577585629 +0.8888198590 0.0572275678 +0.8898210742 0.0566967221 +0.8908220833 0.0561662841 +0.8918233738 0.0556359951 +0.8928243253 0.0551061831 +0.8938254322 0.0545765858 +0.8948268196 0.0540471367 +0.8958277659 0.0535182168 +0.8968289919 0.0529894447 +0.8978298680 0.0524611522 +0.8988308562 0.0519330951 +0.8998318860 0.0514053099 +0.9008331944 0.0508776715 +0.9018345438 0.0503503047 +0.9028354051 0.0498234874 +0.9038365440 0.0492968161 +0.9048375013 0.0487705317 +0.9058384620 0.0482445367 +0.9068395794 0.0477187499 +0.9078404128 0.0471934022 +0.9088415223 0.0466681993 +0.9098422743 0.0461434729 +0.9108432594 0.0456189129 +0.9118445198 0.0450944969 +0.9128455886 0.0445704691 +0.9138465602 0.0440467793 +0.9148478062 0.0435232328 +0.9158489542 0.0430000239 +0.9168497246 0.0424772982 +0.9178507100 0.0419547453 +0.9188519685 0.0414323349 +0.9198527005 0.0409104836 +0.9208537049 0.0403887741 +0.9218546764 0.0398673652 +0.9228559198 0.0393460978 +0.9238569337 0.0388252325 +0.9248581429 0.0383045477 +0.9258591557 0.0377842468 +0.9268604392 0.0372640865 +0.9278612824 0.0367444356 +0.9288623956 0.0362249248 +0.9298637098 0.0357055897 +0.9308645785 0.0351867650 +0.9318657163 0.0346680797 +0.9328668805 0.0341496594 +0.9338681670 0.0336314538 +0.9348693061 0.0331136023 +0.9358707132 0.0325958894 +0.9368716642 0.0320786891 +0.9378725827 0.0315617817 +0.9388735835 0.0310451076 +0.9398748514 0.0305285711 +0.9408762012 0.0300122675 +0.9418775077 0.0294962609 +0.9428785621 0.0289806582 +0.9438795318 0.0284653728 +0.9448807671 0.0279502240 +0.9458817890 0.0274354577 +0.9468830759 0.0269208275 +0.9478839859 0.0264066630 +0.9488851602 0.0258926342 +0.9498859806 0.0253790580 +0.9508870648 0.0248656171 +0.9518880089 0.0243525181 +0.9528892163 0.0238395540 +0.9538902006 0.0233269736 +0.9548914475 0.0228145276 +0.9558923190 0.0223025422 +0.9568933803 0.0217907278 +0.9578947035 0.0212790472 +0.9588958951 0.0207677012 +0.9598973482 0.0202564886 +0.9608982736 0.0197458117 +0.9618994598 0.0192352679 +0.9629006974 0.0187249634 +0.9639021955 0.0182147916 +0.9649037413 0.0177048604 +0.9659055471 0.0171950615 +0.9669069401 0.0166857369 +0.9679082355 0.0161767255 +0.9689097900 0.0156678457 +0.9699112462 0.0151592787 +0.9709126936 0.0146509788 +0.9719142405 0.0141428904 +0.9729159660 0.0136349733 +0.9739176212 0.0131273531 +0.9749193101 0.0126199769 +0.9759212564 0.0121127309 +0.9769232360 0.0116057285 +0.9779252391 0.0110989741 +0.9789272710 0.0105924647 +0.9799293395 0.0100861959 +0.9809313029 0.0095802390 +0.9819335223 0.0090744113 +0.9829358524 0.0085687858 +0.9839384382 0.0080632892 +0.9849411070 0.0075580082 +0.9859440311 0.0070528558 +0.9869468965 0.0065479898 +0.9879500168 0.0060432520 +0.9889530664 0.0055388060 +0.9899563704 0.0050344878 +0.9909598639 0.0045303300 +0.9919635394 0.0040263360 +0.9929674602 0.0035224738 +0.9939714188 0.0030188473 +0.9949756310 0.0025153480 +0.9959800294 0.0020120094 +0.9969846811 0.0015087977 +0.9979895491 0.0010057312 +0.9989946569 0.0005027980 +1.0000000000 0.0000000000 diff --git a/src/problems/ZDT/ZDT2.txt b/src/problems/ZDT/ZDT2.txt new file mode 100644 index 0000000..efbb93d --- /dev/null +++ b/src/problems/ZDT/ZDT2.txt @@ -0,0 +1,1000 @@ +0.0000000000 1.0000000000 +0.0037548734 0.9999859009 +0.0056323101 0.9999682771 +0.0072002711 0.9999481561 +0.0085975093 0.9999260828 +0.0098827783 0.9999023307 +0.0111021022 0.9998767433 +0.0122644749 0.9998495827 +0.0133717654 0.9998211959 +0.0144556768 0.9997910334 +0.0154989513 0.9997597825 +0.0165198262 0.9997270953 +0.0175091577 0.9996934294 +0.0184792182 0.9996585185 +0.0194383563 0.9996221503 +0.0203994415 0.9995838628 +0.0213502373 0.9995441674 +0.0222798620 0.9995036077 +0.0232135253 0.9994611322 +0.0241284123 0.9994178197 +0.0250545142 0.9993722713 +0.0259635001 0.9993258967 +0.0268835323 0.9992772757 +0.0277878213 0.9992278370 +0.0286988944 0.9991763735 +0.0295955060 0.9991241060 +0.0305002006 0.9990697378 +0.0313914778 0.9990145751 +0.0322999824 0.9989567111 +0.0331957101 0.9988980448 +0.0341024348 0.9988370239 +0.0350154214 0.9987739203 +0.0359165055 0.9987100046 +0.0368284765 0.9986436633 +0.0377291560 0.9985765108 +0.0386233194 0.9985082392 +0.0395347862 0.9984370007 +0.0404357461 0.9983649504 +0.0413838286 0.9982873787 +0.0423210511 0.9982089286 +0.0432598654 0.9981285840 +0.0441884928 0.9980473771 +0.0451274643 0.9979635120 +0.0460566673 0.9978787834 +0.0469936799 0.9977915940 +0.0479285927 0.9977028500 +0.0488543871 0.9976132489 +0.0498041848 0.9975195432 +0.0507558612 0.9974238426 +0.0516986155 0.9973272532 +0.0526435088 0.9972286610 +0.0536006512 0.9971269702 +0.0545492479 0.9970243796 +0.0554916186 0.9969206803 +0.0564497778 0.9968134226 +0.0573998053 0.9967052624 +0.0583678442 0.9965931948 +0.0593370928 0.9964791094 +0.0602984253 0.9963640999 +0.0612621068 0.9962469543 +0.0622182087 0.9961288945 +0.0631922258 0.9960067426 +0.0641587364 0.9958836565 +0.0651270265 0.9957584704 +0.0660978578 0.9956310732 +0.0670615596 0.9955027472 +0.0680279356 0.9953722000 +0.0690027495 0.9952386206 +0.0699706776 0.9951041043 +0.0709476107 0.9949664365 +0.0719178176 0.9948278275 +0.0728887192 0.9946872346 +0.0738666736 0.9945437145 +0.0748381543 0.9943992507 +0.0758104622 0.9942527738 +0.0767933220 0.9941027857 +0.0777698921 0.9939518439 +0.0787528783 0.9937979842 +0.0797353113 0.9936422801 +0.0807116919 0.9934856228 +0.0816950256 0.9933259228 +0.0826724413 0.9931652675 +0.0836520716 0.9930023309 +0.0846324853 0.9928373424 +0.0856122078 0.9926705499 +0.0865915946 0.9925018957 +0.0875654427 0.9923322932 +0.0885486165 0.9921591425 +0.0895263321 0.9919850359 +0.0905159446 0.9918068638 +0.0915001473 0.9916277230 +0.0924829805 0.9914468983 +0.0934713885 0.9912630995 +0.0944545706 0.9910783341 +0.0954460041 0.9908900603 +0.0964322884 0.9907008137 +0.0974231726 0.9905087254 +0.0984090176 0.9903156653 +0.0993933392 0.9901209641 +0.1003891393 0.9899220207 +0.1013800005 0.9897220955 +0.1023716462 0.9895200461 +0.1033584889 0.9893170228 +0.1043457257 0.9891119695 +0.1053366579 0.9889041885 +0.1063229292 0.9886954347 +0.1073171467 0.9884830300 +0.1083067588 0.9882696460 +0.1092942220 0.9880547730 +0.1102871736 0.9878367393 +0.1112792090 0.9876169376 +0.1122702940 0.9873953811 +0.1132570045 0.9871728509 +0.1142428580 0.9869485694 +0.1152287028 0.9867223461 +0.1162242907 0.9864919142 +0.1172176143 0.9862600309 +0.1182067291 0.9860271692 +0.1192005741 0.9857912231 +0.1201937044 0.9855534734 +0.1211827316 0.9853147456 +0.1221738421 0.9850735523 +0.1231674304 0.9848297841 +0.1241570110 0.9845850366 +0.1251513739 0.9843371336 +0.1261417866 0.9840882497 +0.1271305733 0.9838378173 +0.1281188446 0.9835855617 +0.1291120346 0.9833300825 +0.1301014046 0.9830736245 +0.1310981670 0.9828132706 +0.1320911402 0.9825519307 +0.1330828331 0.9822889595 +0.1340757168 0.9820237022 +0.1350667537 0.9817569720 +0.1360640059 0.9814865863 +0.1370576036 0.9812152133 +0.1380482074 0.9809426924 +0.1390442299 0.9806667021 +0.1400366851 0.9803897268 +0.1410285212 0.9801109562 +0.1420297497 0.9798275502 +0.1430279818 0.9795429964 +0.1440227304 0.9792574531 +0.1450201414 0.9789691586 +0.1460141225 0.9786798760 +0.1470106774 0.9783878607 +0.1480038546 0.9780948590 +0.1490008035 0.9777987606 +0.1499987966 0.9775003610 +0.1509934697 0.9772009721 +0.1519892171 0.9768992779 +0.1529845440 0.9765957293 +0.1539824730 0.9762893980 +0.1549812527 0.9759808113 +0.1559768141 0.9756712335 +0.1569732565 0.9753593967 +0.1579682628 0.9750460279 +0.1589635779 0.9747305809 +0.1599602369 0.9744127226 +0.1609537910 0.9740938772 +0.1619508157 0.9737719333 +0.1629447714 0.9734490015 +0.1639420183 0.9731230146 +0.1649362321 0.9727960394 +0.1659285601 0.9724677129 +0.1669263423 0.9721355962 +0.1679242718 0.9718014389 +0.1689192361 0.9714662917 +0.1699143812 0.9711291031 +0.1709136645 0.9707885193 +0.1719100267 0.9704469427 +0.1729091065 0.9701024409 +0.1739075198 0.9697561746 +0.1749039959 0.9694085922 +0.1758976333 0.9690600226 +0.1768930813 0.9687088378 +0.1778885982 0.9683556466 +0.1788857928 0.9679998731 +0.1798809668 0.9676428378 +0.1808733880 0.9672848175 +0.1818737507 0.9669219388 +0.1828713622 0.9665580649 +0.1838675279 0.9661927322 +0.1848647298 0.9658250317 +0.1858592422 0.9654563421 +0.1868578763 0.9650841341 +0.1878538419 0.9647109341 +0.1888480200 0.9643364254 +0.1898479302 0.9639577634 +0.1908452072 0.9635781069 +0.1918426183 0.9631964098 +0.1928374365 0.9628137231 +0.1938386413 0.9624265811 +0.1948372605 0.9620384419 +0.1958345643 0.9616488234 +0.1968348666 0.9612560353 +0.1978338730 0.9608617587 +0.1988303570 0.9604664891 +0.1998255835 0.9600697362 +0.2008227242 0.9596702334 +0.2018185255 0.9592692828 +0.2028169428 0.9588652877 +0.2038160948 0.9584589995 +0.2048127978 0.9580517178 +0.2058088595 0.9576427134 +0.2068084964 0.9572302458 +0.2078057174 0.9568167838 +0.2088052907 0.9564003506 +0.2098024715 0.9559829230 +0.2107996014 0.9555635281 +0.2118015707 0.9551400946 +0.2128016905 0.9547154405 +0.2138009672 0.9542891464 +0.2147979086 0.9538618584 +0.2157940366 0.9534329338 +0.2167962249 0.9529993969 +0.2177980650 0.9525640029 +0.2187976010 0.9521276098 +0.2197968130 0.9516893610 +0.2207968137 0.9512487671 +0.2217945498 0.9508071777 +0.2227934740 0.9503630679 +0.2237901588 0.9499179648 +0.2247867449 0.9494709193 +0.2257873735 0.9490200620 +0.2267874112 0.9485674701 +0.2277870983 0.9481130378 +0.2287845918 0.9476576106 +0.2297817570 0.9472003441 +0.2307815350 0.9467398831 +0.2317791474 0.9462784268 +0.2327802895 0.9458133368 +0.2337802672 0.9453467867 +0.2347788662 0.9448788840 +0.2357753414 0.9444099884 +0.2367704676 0.9439397457 +0.2377710737 0.9434649165 +0.2387695744 0.9429890903 +0.2397695434 0.9425105660 +0.2407685174 0.9420305210 +0.2417654190 0.9415494822 +0.2427650570 0.9410651271 +0.2437638578 0.9405791816 +0.2447606123 0.9400922427 +0.2457599204 0.9396020615 +0.2467571968 0.9391108858 +0.2477530477 0.9386184274 +0.2487530373 0.9381219264 +0.2497510170 0.9376244295 +0.2507525225 0.9371231724 +0.2517543782 0.9366197331 +0.2527542404 0.9361152940 +0.2537544657 0.9356086711 +0.2547540027 0.9351003981 +0.2557521225 0.9345908518 +0.2567536907 0.9340775423 +0.2577544535 0.9335626417 +0.2587538466 0.9330464469 +0.2597513096 0.9325292572 +0.2607499713 0.9320094525 +0.2617490401 0.9314874400 +0.2627462021 0.9309644333 +0.2637450953 0.9304385247 +0.2647450974 0.9299100334 +0.2657445968 0.9293798093 +0.2667422165 0.9288485899 +0.2677393514 0.9283156397 +0.2687367900 0.9277805377 +0.2697371886 0.9272418491 +0.2707357322 0.9267021633 +0.2717368092 0.9261591065 +0.2727361892 0.9256149711 +0.2737365126 0.9250683217 +0.2747350083 0.9245206752 +0.2757357028 0.9239698222 +0.2767345816 0.9234179714 +0.2777350726 0.9228632295 +0.2787337615 0.9223074902 +0.2797339559 0.9217489139 +0.2807342099 0.9211883034 +0.2817336042 0.9206261763 +0.2827326525 0.9200622472 +0.2837299357 0.9194973236 +0.2847306145 0.9189284771 +0.2857312198 0.9183576700 +0.2867316128 0.9177849822 +0.2877302606 0.9172112971 +0.2887297852 0.9166351111 +0.2897292567 0.9160569578 +0.2907278411 0.9154773224 +0.2917247107 0.9148966932 +0.2927247433 0.9143122247 +0.2937230677 0.9137267595 +0.2947242214 0.9131376333 +0.2957236747 0.9125475082 +0.2967222911 0.9119558819 +0.2977226397 0.9113612298 +0.2987226420 0.9107647832 +0.2997209704 0.9101673399 +0.3007211623 0.9095667826 +0.3017196908 0.9089652282 +0.3027213448 0.9083597874 +0.3037216001 0.9077531896 +0.3047224279 0.9071442419 +0.3057227202 0.9065336184 +0.3067213760 0.9059219975 +0.3077219257 0.9053072164 +0.3087217834 0.9046908604 +0.3097200220 0.9040735080 +0.3107204423 0.9034528067 +0.3117192522 0.9028311078 +0.3127202311 0.9022060571 +0.3137200906 0.9015797047 +0.3147183568 0.9009523559 +0.3157189242 0.9003215609 +0.3167186443 0.8996893003 +0.3177167867 0.8990560435 +0.3187167327 0.8984196443 +0.3197151101 0.8977822484 +0.3207150263 0.8971418719 +0.3217133837 0.8965004987 +0.3227122877 0.8958567794 +0.3237134545 0.8952095994 +0.3247145488 0.8945604618 +0.3257140999 0.8939103251 +0.3267132688 0.8932584400 +0.3277109098 0.8926055596 +0.3287103536 0.8919495035 +0.3297082779 0.8912924515 +0.3307106586 0.8906304603 +0.3317115202 0.8899674674 +0.3327117172 0.8893029132 +0.3337120990 0.8886362350 +0.3347117763 0.8879680268 +0.3357131074 0.8872967095 +0.3367129451 0.8866243926 +0.3377145017 0.8859489154 +0.3387145731 0.8852724380 +0.3397137097 0.8845945954 +0.3407131349 0.8839145597 +0.3417134322 0.8832319303 +0.3427127583 0.8825479653 +0.3437106274 0.8818630046 +0.3447112096 0.8811741820 +0.3457119036 0.8804832797 +0.3467111493 0.8797913789 +0.3477113852 0.8790967926 +0.3487101824 0.8784012087 +0.3497105997 0.8777024965 +0.3507095860 0.8770027863 +0.3517093257 0.8763005502 +0.3527082230 0.8755969094 +0.3537068614 0.8748914562 +0.3547084670 0.8741819034 +0.3557086584 0.8734713503 +0.3567096721 0.8727582098 +0.3577092813 0.8720440701 +0.3587087780 0.8713280126 +0.3597068822 0.8706109589 +0.3607042064 0.8698924755 +0.3617058245 0.8691688965 +0.3627060558 0.8684443171 +0.3637073052 0.8677169961 +0.3647071765 0.8669886754 +0.3657070569 0.8662583485 +0.3667086267 0.8655247831 +0.3677099490 0.8647893934 +0.3687099346 0.8640529841 +0.3697105071 0.8633141409 +0.3707097257 0.8625742993 +0.3717101517 0.8618315631 +0.3727095392 0.8610875994 +0.3737075868 0.8603426395 +0.3747084124 0.8595936056 +0.3757092915 0.8588425283 +0.3767088375 0.8580904518 +0.3777096188 0.8573354439 +0.3787090743 0.8565794370 +0.3797085811 0.8558213934 +0.3807097313 0.8550601005 +0.3817099675 0.8542975007 +0.3827088932 0.8535339031 +0.3837103797 0.8527663445 +0.3847105592 0.8519977857 +0.3857114715 0.8512266608 +0.3867110851 0.8504545367 +0.3877100118 0.8496809468 +0.3887116145 0.8489032808 +0.3897119267 0.8481246142 +0.3907130047 0.8473433479 +0.3917134253 0.8465605924 +0.3927125683 0.8457768387 +0.3937119675 0.8449908866 +0.3947140174 0.8442008444 +0.3957147954 0.8434098007 +0.3967148913 0.8426172950 +0.3977152137 0.8418226088 +0.3987156539 0.8410258274 +0.3997162157 0.8402269469 +0.4007155251 0.8394270679 +0.4017167430 0.8386236584 +0.4027176025 0.8378185326 +0.4037172184 0.8370124076 +0.4047181532 0.8362032164 +0.4057191940 0.8353919356 +0.4067189998 0.8345796552 +0.4077185048 0.8337656208 +0.4087181103 0.8329495063 +0.4097169711 0.8321320036 +0.4107155685 0.8313127218 +0.4117172434 0.8304889115 +0.4127176998 0.8296641003 +0.4137174051 0.8288379087 +0.4147187587 0.8280083512 +0.4157189034 0.8271777934 +0.4167185316 0.8263456654 +0.4177183326 0.8255113946 +0.4187195083 0.8246739733 +0.4197194872 0.8238355521 +0.4207198251 0.8229948287 +0.4217204761 0.8221518401 +0.4227199399 0.8213078524 +0.4237197207 0.8204615983 +0.4247210901 0.8196119956 +0.4257212790 0.8187613926 +0.4267222242 0.8179081434 +0.4277232266 0.8170528414 +0.4287233936 0.8161962518 +0.4297236851 0.8153375545 +0.4307234570 0.8144773036 +0.4317220687 0.8136160554 +0.4327227208 0.8127510469 +0.4337242582 0.8118832678 +0.4347246393 0.8110144880 +0.4357256663 0.8101431438 +0.4367255433 0.8092707998 +0.4377254253 0.8083964521 +0.4387259858 0.8075195094 +0.4397258095 0.8066412125 +0.4407267822 0.8057599035 +0.4417266182 0.8048775948 +0.4427282448 0.8039917012 +0.4437287384 0.8031048067 +0.4447285233 0.8022165406 +0.4457296196 0.8013251062 +0.4467295917 0.8004326719 +0.4477300390 0.7995378122 +0.4487308600 0.7986406153 +0.4497305649 0.7977424190 +0.4507311698 0.7968414125 +0.4517306641 0.7959394071 +0.4527309640 0.7950346742 +0.4537301589 0.7941289429 +0.4547317747 0.7932190131 +0.4557322873 0.7923080823 +0.4567331553 0.7913948249 +0.4577329265 0.7904805680 +0.4587341907 0.7895629423 +0.4597349938 0.7886437354 +0.4607358668 0.7877224611 +0.4617356526 0.7868001871 +0.4627355127 0.7858758453 +0.4637356656 0.7849492325 +0.4647373456 0.7840191996 +0.4657391298 0.7830870630 +0.4667403516 0.7821534442 +0.4677404995 0.7812188252 +0.4687410432 0.7802818344 +0.4697414800 0.7793429420 +0.4707408513 0.7784030509 +0.4717417862 0.7774596872 +0.4727416591 0.7765153237 +0.4737421366 0.7755683880 +0.4747424913 0.7746195670 +0.4757417920 0.7736697474 +0.4767427173 0.7727163815 +0.4777431196 0.7717615117 +0.4787424745 0.7708056431 +0.4797437215 0.7698459617 +0.4807446946 0.7688845387 +0.4817454071 0.7679213628 +0.4827450802 0.7669571875 +0.4837444982 0.7659912605 +0.4847441394 0.7650231193 +0.4857427498 0.7640539810 +0.4867439287 0.7630803479 +0.4877440779 0.7621057145 +0.4887446887 0.7611286293 +0.4897442752 0.7601505450 +0.4907434877 0.7591708293 +0.4917429738 0.7581888477 +0.4927440231 0.7572033277 +0.4937440555 0.7562168077 +0.4947448247 0.7552275584 +0.4957450165 0.7542368786 +0.4967458918 0.7532435189 +0.4977457588 0.7522491596 +0.4987468469 0.7512515827 +0.4997469302 0.7502530058 +0.5007479399 0.7492515007 +0.5017479491 0.7482489956 +0.5027480910 0.7472443570 +0.5037472381 0.7462387201 +0.5047479628 0.7452294940 +0.5057476955 0.7442192685 +0.5067487937 0.7432056600 +0.5077489031 0.7421910514 +0.5087482942 0.7411751731 +0.5097494511 0.7401554971 +0.5107504552 0.7391339725 +0.5117513863 0.7381105186 +0.5127513385 0.7370860649 +0.5137512217 0.7360596822 +0.5147525094 0.7350298540 +0.5157529053 0.7339989406 +0.5167523310 0.7329670284 +0.5177543851 0.7319303967 +0.5187554695 0.7308927629 +0.5197570929 0.7298525644 +0.5207577512 0.7288113646 +0.5217592124 0.7277673242 +0.5227597126 0.7267222829 +0.5237611018 0.7256743082 +0.5247624920 0.7246243270 +0.5257629266 0.7235733450 +0.5267641490 0.7225195313 +0.5277644199 0.7214647171 +0.5287656287 0.7204069099 +0.5297673309 0.7193465751 +0.5307680861 0.7182852388 +0.5317684741 0.7172222900 +0.5327690726 0.7161571152 +0.5337707582 0.7150887777 +0.5347715039 0.7140194386 +0.5357718028 0.7129485753 +0.5367721463 0.7118756630 +0.5377728983 0.7108003098 +0.5387727192 0.7097239570 +0.5397735992 0.7086444616 +0.5407735512 0.7075639664 +0.5417749442 0.7064799098 +0.5427754119 0.7053948523 +0.5437751045 0.7043086357 +0.5447764053 0.7032186682 +0.5457767860 0.7021276999 +0.5467779259 0.7010338997 +0.5477781493 0.6999390992 +0.5487797162 0.6988408231 +0.5497803692 0.6977415456 +0.5507808823 0.6966404197 +0.5517822930 0.6955363012 +0.5527827950 0.6944311816 +0.5537827522 0.6933246634 +0.5547837348 0.6922150076 +0.5557839327 0.6911042202 +0.5567832306 0.6899924341 +0.5577845788 0.6888763636 +0.5587850282 0.6877592923 +0.5597850731 0.6866406719 +0.5607861014 0.6855189485 +0.5617862362 0.6843962249 +0.5627868694 0.6832709396 +0.5637866132 0.6821446548 +0.5647869812 0.6810156659 +0.5657864632 0.6798856781 +0.5667863677 0.6787532134 +0.5677880813 0.6776166947 +0.5687889112 0.6764791744 +0.5697903369 0.6753389720 +0.5707914239 0.6741971504 +0.5717916330 0.6730543284 +0.5727922091 0.6719090851 +0.5737919114 0.6707628424 +0.5747928556 0.6696131731 +0.5757940029 0.6684612663 +0.5767942797 0.6673083589 +0.5777954536 0.6661524138 +0.5787957601 0.6649954681 +0.5797958927 0.6638367229 +0.5807957294 0.6626763207 +0.5817966026 0.6615127133 +0.5827969968 0.6603476605 +0.5837965324 0.6591816087 +0.5847986687 0.6580105171 +0.5857999463 0.6568384229 +0.5868017357 0.6556637229 +0.5878026701 0.6544880211 +0.5888030814 0.6533109313 +0.5898044159 0.6521307510 +0.5908049003 0.6509495698 +0.5918060868 0.6497655556 +0.5928064265 0.6485805407 +0.5938072464 0.6473929541 +0.5948087191 0.6462025877 +0.5958099128 0.6450105478 +0.5968102653 0.6438175072 +0.5978103153 0.6426228269 +0.5988105996 0.6414258658 +0.5998121828 0.6402253454 +0.6008129297 0.6390238235 +0.6018134084 0.6378206215 +0.6028143007 0.6366149188 +0.6038147499 0.6354077478 +0.6048143703 0.6341995775 +0.6058156411 0.6329874090 +0.6068165160 0.6317737159 +0.6078165655 0.6305590228 +0.6088174526 0.6293413094 +0.6098175170 0.6281225960 +0.6108184435 0.6269008291 +0.6118185500 0.6256780619 +0.6128191996 0.6244526286 +0.6138190323 0.6232261956 +0.6148189560 0.6219976513 +0.6158192562 0.6207666437 +0.6168200734 0.6195329971 +0.6178200786 0.6182983505 +0.6188212651 0.6170602419 +0.6198216417 0.6158211325 +0.6208229481 0.6145788672 +0.6218243862 0.6133344327 +0.6228252818 0.6120886684 +0.6238253731 0.6108419038 +0.6248249263 0.6095938115 +0.6258256208 0.6083422924 +0.6268255152 0.6070897735 +0.6278268897 0.6058333966 +0.6288274656 0.6045760185 +0.6298277409 0.6033170168 +0.6308284625 0.6020554509 +0.6318283903 0.6007928852 +0.6328297731 0.5995264782 +0.6338303637 0.5982590701 +0.6348314384 0.5969890449 +0.6358317238 0.5957180191 +0.6368322957 0.5944446271 +0.6378334062 0.5931685459 +0.6388337311 0.5918914641 +0.6398346033 0.5906116804 +0.6408352031 0.5893302425 +0.6418350217 0.5880478049 +0.6428361808 0.5867616446 +0.6438365603 0.5854744836 +0.6448382648 0.5841836123 +0.6458398106 0.5828909390 +0.6468411991 0.5815964631 +0.6478418124 0.5803009861 +0.6488417767 0.5790043488 +0.6498430841 0.5777039660 +0.6508436201 0.5764025821 +0.6518444272 0.5750988428 +0.6528453459 0.5737929544 +0.6538454973 0.5724860657 +0.6548457623 0.5711770276 +0.6558466176 0.5698652142 +0.6568467091 0.5685524007 +0.6578483101 0.5672356009 +0.6588491486 0.5659177994 +0.6598495399 0.5645985847 +0.6608506818 0.5632763764 +0.6618520295 0.5619518910 +0.6628526198 0.5606264044 +0.6638532352 0.5592988821 +0.6648546560 0.5579682864 +0.6658557484 0.5566361223 +0.6668561595 0.5553028625 +0.6678570275 0.5539669908 +0.6688577411 0.5526293222 +0.6698577061 0.5512906536 +0.6708589585 0.5499482579 +0.6718604722 0.5486035059 +0.6728617433 0.5472570744 +0.6738622695 0.5459096417 +0.6748631339 0.5445597505 +0.6758642604 0.5432075016 +0.6768646453 0.5418542519 +0.6778657070 0.5404980833 +0.6788660295 0.5391409141 +0.6798673730 0.5377803551 +0.6808679791 0.5364187950 +0.6818689868 0.5350546849 +0.6828700058 0.5336885552 +0.6838702912 0.5323214249 +0.6848716407 0.5309508358 +0.6858722582 0.5295792455 +0.6868733810 0.5282049585 +0.6878737742 0.5268296708 +0.6888743691 0.5254521036 +0.6898754989 0.5240717961 +0.6908762384 0.5226900232 +0.6918770254 0.5213061817 +0.6928770886 0.5199213402 +0.6938772011 0.5185344298 +0.6948778114 0.5171448272 +0.6958789205 0.5157525280 +0.6968793095 0.5143592280 +0.6978801979 0.5129632293 +0.6988809228 0.5115654558 +0.6998811742 0.5101663419 +0.7008807109 0.5087662290 +0.7018824250 0.5073610614 +0.7028834243 0.5059548918 +0.7038844436 0.5045466901 +0.7048847511 0.5031374877 +0.7058852015 0.5017260823 +0.7068859163 0.5003123013 +0.7078859228 0.4988975203 +0.7088875851 0.4974783917 +0.7098885397 0.4960582612 +0.7108888828 0.4946369963 +0.7118903868 0.4932120771 +0.7128911864 0.4917861563 +0.7138919825 0.4903582373 +0.7148930803 0.4889278837 +0.7158942397 0.4874954376 +0.7168953773 0.4860610180 +0.7178958158 0.4846255976 +0.7188962346 0.4831882039 +0.7198965507 0.4817489563 +0.7208968372 0.4803077501 +0.7218969152 0.4788648438 +0.7228980439 0.4774184181 +0.7238984794 0.4759709916 +0.7248985473 0.4745220961 +0.7258985725 0.4730712625 +0.7268995657 0.4716170214 +0.7278998696 0.4701617798 +0.7289000165 0.4687047659 +0.7299007776 0.4672448548 +0.7309013965 0.4657831485 +0.7319013305 0.4643204424 +0.7329017974 0.4628549554 +0.7339029342 0.4613864831 +0.7349033882 0.4599170100 +0.7359041834 0.4584450328 +0.7369050893 0.4569708893 +0.7379053155 0.4554957453 +0.7389060278 0.4540178821 +0.7399060623 0.4525390189 +0.7409068101 0.4510570987 +0.7419084637 0.4495718315 +0.7429094411 0.4480855623 +0.7439105660 0.4465970698 +0.7449110172 0.4451075765 +0.7459121306 0.4436150934 +0.7469125722 0.4421216095 +0.7479130782 0.4406260275 +0.7489143233 0.4391273363 +0.7499154898 0.4376267582 +0.7509159879 0.4361251791 +0.7519164094 0.4346217133 +0.7529177058 0.4331149283 +0.7539191070 0.4316059801 +0.7549198431 0.4300960305 +0.7559213352 0.4285829350 +0.7569224886 0.4270683463 +0.7579229798 0.4255527567 +0.7589246123 0.4240334328 +0.7599255838 0.4225131070 +0.7609265638 0.4209907644 +0.7619278812 0.4194659038 +0.7629290969 0.4179391932 +0.7639296555 0.4164114814 +0.7649301145 0.4148819199 +0.7659303794 0.4133506538 +0.7669302055 0.4118180599 +0.7679308016 0.4102822839 +0.7689307459 0.4087455081 +0.7699310321 0.4072062058 +0.7709329274 0.4056624214 +0.7719341717 0.4041176345 +0.7729352533 0.4025710942 +0.7739363623 0.4010225071 +0.7749368238 0.3994729192 +0.7759377998 0.3979205308 +0.7769383207 0.3963668458 +0.7779381974 0.3948121611 +0.7789392652 0.3932536211 +0.7799405976 0.3916926642 +0.7809414697 0.3901304209 +0.7819417004 0.3885671771 +0.7829428248 0.3870005331 +0.7839433091 0.3854328881 +0.7849447045 0.3838618109 +0.7859461881 0.3822885894 +0.7869470336 0.3807143663 +0.7879475411 0.3791386725 +0.7889477963 0.3775613747 +0.7899486202 0.3759811774 +0.7909491668 0.3743994155 +0.7919490806 0.3728166538 +0.7929497720 0.3712306591 +0.7939498320 0.3696436642 +0.7949503135 0.3680539990 +0.7959503011 0.3664631181 +0.7969515721 0.3648681917 +0.7979528927 0.3632711811 +0.7989535850 0.3616731691 +0.7999548002 0.3600723177 +0.8009553888 0.3584704652 +0.8019561006 0.3568664128 +0.8029563271 0.3552611368 +0.8039576438 0.3536521070 +0.8049589254 0.3520411284 +0.8059595843 0.3504291485 +0.8069609103 0.3488140893 +0.8079616150 0.3471980287 +0.8089628692 0.3455790762 +0.8099635779 0.3439590025 +0.8109647699 0.3423361420 +0.8119658521 0.3407114550 +0.8129663173 0.3390857670 +0.8139677166 0.3374565563 +0.8149684999 0.3358263441 +0.8159695655 0.3341936681 +0.8169700171 0.3325599912 +0.8179705438 0.3309241895 +0.8189717626 0.3292852520 +0.8199729459 0.3276443680 +0.8209735179 0.3260024829 +0.8219740559 0.3243586514 +0.8229745108 0.3227129546 +0.8239760623 0.3210634487 +0.8249770051 0.3194129410 +0.8259776978 0.3177608427 +0.8269788523 0.3161059779 +0.8279800667 0.3144490092 +0.8289809674 0.3127905557 +0.8299812639 0.3111311016 +0.8309812489 0.3094701639 +0.8319817746 0.3078063267 +0.8329830448 0.3061392471 +0.8339838437 0.3044709485 +0.8349840421 0.3028016494 +0.8359858560 0.3011276486 +0.8369870696 0.2994526454 +0.8379877848 0.2977764725 +0.8389888231 0.2960977546 +0.8399892643 0.2944180358 +0.8409905999 0.2927348108 +0.8419913394 0.2910505844 +0.8429918039 0.2893648186 +0.8439929114 0.2876759655 +0.8449934252 0.2859861113 +0.8459945215 0.2842932696 +0.8469950254 0.2825994269 +0.8479960615 0.2809026797 +0.8489965067 0.2792049316 +0.8499975511 0.2775041632 +0.8509980060 0.2758023938 +0.8519985154 0.2740985298 +0.8529995778 0.2723917202 +0.8540000529 0.2706839097 +0.8550002400 0.2689745897 +0.8560004378 0.2672632505 +0.8570019396 0.2655476756 +0.8580028562 0.2638310988 +0.8590037053 0.2621126343 +0.8600039714 0.2603931692 +0.8610051818 0.2586700768 +0.8620058102 0.2569459832 +0.8630067094 0.2552194195 +0.8640080614 0.2534900698 +0.8650088331 0.2517597186 +0.8660097076 0.2500271864 +0.8670106433 0.2482925444 +0.8680112546 0.2465564619 +0.8690112892 0.2448193792 +0.8700130267 0.2430773334 +0.8710141875 0.2413342852 +0.8720152654 0.2395893770 +0.8730164118 0.2378423446 +0.8740175616 0.2360933021 +0.8750181379 0.2343432583 +0.8760187188 0.2325912043 +0.8770192391 0.2308372543 +0.8780206123 0.2290798044 +0.8790214144 0.2273213529 +0.8800219663 0.2255613389 +0.8810225877 0.2237991999 +0.8820239210 0.2220338029 +0.8830246858 0.2202674043 +0.8840256459 0.2184986575 +0.8850260393 0.2167289098 +0.8860270515 0.2149560640 +0.8870274983 0.2131822173 +0.8880283489 0.2114056515 +0.8890286356 0.2096280851 +0.8900302999 0.2078460652 +0.8910318396 0.2060622609 +0.8920328163 0.2042774546 +0.8930340663 0.2024901564 +0.8940347550 0.2007018568 +0.8950360844 0.1989104077 +0.8960368536 0.1971179570 +0.8970377732 0.1953232334 +0.8980385729 0.1935267217 +0.8990397954 0.1917274463 +0.9000404604 0.1899271697 +0.9010406568 0.1881257348 +0.9020418368 0.1863205247 +0.9030424612 0.1845143133 +0.9040437450 0.1827049072 +0.9050446075 0.1808942585 +0.9060456802 0.1790812254 +0.9070468502 0.1772660116 +0.9080474676 0.1754497966 +0.9090481832 0.1736314005 +0.9100489200 0.1718109631 +0.9110499684 0.1699879550 +0.9120504668 0.1681639460 +0.9130512773 0.1663373650 +0.9140523715 0.1645082622 +0.9150529174 0.1626781584 +0.9160534651 0.1608460490 +0.9170547161 0.1590106478 +0.9180554204 0.1571742451 +0.9190562956 0.1553355256 +0.9200571762 0.1534947925 +0.9210575125 0.1516530588 +0.9220585205 0.1498080847 +0.9230589853 0.1479621097 +0.9240597622 0.1461135559 +0.9250608477 0.1442624280 +0.9260614803 0.1424101348 +0.9270615722 0.1405568413 +0.9280630850 0.1386989102 +0.9290640575 0.1368399771 +0.9300655418 0.1349780880 +0.9310664869 0.1331151969 +0.9320675835 0.1312500198 +0.9330687497 0.1293827084 +0.9340693788 0.1275143956 +0.9350700730 0.1256439587 +0.9360702317 0.1237725214 +0.9370710634 0.1218978221 +0.9380713607 0.1200221222 +0.9390721206 0.1181435523 +0.9400723473 0.1162639819 +0.9410738335 0.1143800399 +0.9420747868 0.1124950960 +0.9430764485 0.1106068123 +0.9440775782 0.1087175264 +0.9450787494 0.1068261575 +0.9460800707 0.1049324998 +0.9470808622 0.1030378405 +0.9480818340 0.1011408360 +0.9490822775 0.0992428306 +0.9500834795 0.0973413820 +0.9510845102 0.0954382545 +0.9520850141 0.0935341259 +0.9530859384 0.0916271940 +0.9540863371 0.0897192613 +0.9550868011 0.0878092024 +0.9560877695 0.0858961770 +0.9570882140 0.0839821507 +0.9580884059 0.0820666065 +0.9590886162 0.0801490263 +0.9600896778 0.0782278105 +0.9610902176 0.0763055936 +0.9620904461 0.0743819735 +0.9630915722 0.0724546236 +0.9640921779 0.0705262724 +0.9650923980 0.0685966633 +0.9660923668 0.0666655389 +0.9670928311 0.0647314561 +0.9680927779 0.0627963734 +0.9690928236 0.0608590993 +0.9700925336 0.0589204763 +0.9710924163 0.0569795191 +0.9720917842 0.0550375631 +0.9730915101 0.0530929130 +0.9740914078 0.0511459293 +0.9750907922 0.0491979469 +0.9760898892 0.0472485283 +0.9770885645 0.0452979371 +0.9780877027 0.0433444458 +0.9790863306 0.0413899573 +0.9800852744 0.0394328550 +0.9810837091 0.0374747557 +0.9820819259 0.0355150907 +0.9830801314 0.0335534553 +0.9840781166 0.0315902604 +0.9850755958 0.0296260706 +0.9860728806 0.0276602742 +0.9870696611 0.0256934842 +0.9880665739 0.0237244456 +0.9890629838 0.0217544141 +0.9900591295 0.0197829200 +0.9910547741 0.0178104347 +0.9920503191 0.0158361644 +0.9930453645 0.0138609040 +0.9940402226 0.0118840359 +0.9950345858 0.0099061731 +0.9960284521 0.0079273226 +0.9970219902 0.0059471511 +0.9980151238 0.0039658127 +0.9990078085 0.0019833986 +1.0000000000 0.0000000000 diff --git a/src/problems/ZDT/ZDT3.txt b/src/problems/ZDT/ZDT3.txt new file mode 100644 index 0000000..7cc4b0a --- /dev/null +++ b/src/problems/ZDT/ZDT3.txt @@ -0,0 +1,1000 @@ +0.0000000000 1.0000000000 +0.0001669867 0.9870767898 +0.0003556074 0.9811384730 +0.0005020830 0.9775848727 +0.0005936368 0.9756242656 +0.0008526856 0.9707763811 +0.0009594493 0.9689961054 +0.0015383844 0.9607034357 +0.0020570965 0.9545119258 +0.0026049104 0.9487487404 +0.0030767688 0.9442344352 +0.0034180675 0.9411694253 +0.0036717564 0.9389823762 +0.0038889639 0.9371644873 +0.0042634278 0.9341357353 +0.0045677159 0.9317619051 +0.0048025025 0.9299780777 +0.0049491266 0.9288835705 +0.0052231746 0.9268752322 +0.0056348254 0.9239422323 +0.0059965327 0.9214397209 +0.0062303750 0.9198555571 +0.0064301391 0.9185217235 +0.0066199433 0.9172701090 +0.0068214844 0.9159570195 +0.0072291603 0.9133477888 +0.0076741700 0.9105653571 +0.0080639223 0.9081795586 +0.0085268555 0.9054020802 +0.0088785809 0.9033292734 +0.0091366688 0.9018273795 +0.0093681110 0.9004935189 +0.0095528069 0.8994374843 +0.0096573496 0.8988429411 +0.0099784197 0.8970308931 +0.0102322266 0.8956126871 +0.0105317498 0.8939543318 +0.0107778336 0.8926036594 +0.0110849122 0.8909324019 +0.0114248107 0.8890999667 +0.0116816063 0.8877270886 +0.0119375977 0.8863679309 +0.0122450122 0.8847476272 +0.0124563098 0.8836411373 +0.0126694291 0.8825308265 +0.0128683452 0.8814995256 +0.0130583286 0.8805189165 +0.0131986790 0.8797971649 +0.0134103869 0.8787126395 +0.0136429688 0.8775268110 +0.0139332104 0.8760549727 +0.0141327011 0.8750482925 +0.0143068967 0.8741724532 +0.0144956544 0.8732266709 +0.0149293257 0.8710661595 +0.0153483399 0.8689943461 +0.0156313482 0.8676032942 +0.0158346655 0.8666079009 +0.0162010255 0.8648223436 +0.0166327204 0.8627311017 +0.0170537110 0.8607043403 +0.0173191595 0.8594325272 +0.0175344871 0.8584042124 +0.0177394099 0.8574283093 +0.0181096151 0.8556718157 +0.0185920954 0.8533947644 +0.0189556499 0.8516876796 +0.0192777942 0.8501810417 +0.0194690215 0.8492892820 +0.0198037163 0.8477330068 +0.0202974665 0.8454473371 +0.0206546959 0.8438009602 +0.0209831653 0.8422923698 +0.0212487014 0.8410763951 +0.0215018774 0.8399199344 +0.0217359231 0.8388533410 +0.0219358993 0.8379438680 +0.0221884994 0.8367974771 +0.0224118827 0.8357858922 +0.0225142106 0.8353231873 +0.0227053361 0.8344600970 +0.0228607177 0.8337595036 +0.0229579167 0.8333217372 +0.0230225099 0.8330310289 +0.0231956360 0.8322526674 +0.0232116861 0.8321805673 +0.0235123826 0.8308316289 +0.0238751954 0.8292086653 +0.0242269208 0.8276400578 +0.0245668626 0.8261283879 +0.0250313925 0.8240695616 +0.0254135798 0.8223815507 +0.0256564042 0.8213117880 +0.0258458064 0.8204788343 +0.0259543603 0.8200020095 +0.0261712464 0.8190505805 +0.0262662654 0.8186342762 +0.0265035580 0.8175960166 +0.0269069841 0.8158353717 +0.0272859376 0.8141866940 +0.0276270372 0.8127069664 +0.0279624818 0.8112557002 +0.0281386232 0.8104952023 +0.0281838469 0.8103001203 +0.0288243220 0.8075448957 +0.0293430341 0.8053239043 +0.0297674992 0.8035134265 +0.0301836989 0.8017443297 +0.0305296931 0.8002782929 +0.0307107548 0.7995127936 +0.0308331559 0.7989959623 +0.0312153919 0.7973854390 +0.0314860627 0.7962481634 +0.0317119832 0.7953009439 +0.0320680775 0.7938117197 +0.0323274831 0.7927297883 +0.0325584125 0.7917687206 +0.0327545581 0.7909539735 +0.0329089323 0.7903137492 +0.0330877498 0.7895732754 +0.0332574191 0.7888718023 +0.0334145865 0.7882229944 +0.0337083799 0.7870127140 +0.0339404353 0.7860591181 +0.0341096686 0.7853650013 +0.0344325575 0.7840437769 +0.0347528391 0.7827373008 +0.0349601076 0.7818940097 +0.0353433487 0.7803393361 +0.0355824439 0.7793724529 +0.0358127931 0.7784431724 +0.0360432832 0.7775155381 +0.0362240647 0.7767895244 +0.0362597010 0.7766465731 +0.0364984920 0.7756900814 +0.0366765299 0.7749785273 +0.0370172041 0.7736207936 +0.0375036794 0.7716907923 +0.0378698896 0.7702448701 +0.0382213553 0.7688628704 +0.0385632853 0.7675238068 +0.0388163408 0.7665362934 +0.0389235753 0.7661187323 +0.0392235353 0.7649536098 +0.0394193855 0.7641951960 +0.0397264145 0.7630099790 +0.0398992225 0.7623449129 +0.0400762209 0.7616652420 +0.0402551451 0.7609797537 +0.0405720649 0.7597695091 +0.0408019665 0.7588947413 +0.0409289064 0.7584128930 +0.0411088328 0.7577313321 +0.0411312365 0.7576465840 +0.0414266470 0.7565315470 +0.0417815920 0.7551978412 +0.0420921689 0.7540363331 +0.0423322940 0.7531418556 +0.0424672908 0.7526403583 +0.0427556349 0.7515725323 +0.0429379854 0.7508995993 +0.0433199764 0.7494959371 +0.0437319122 0.7479914750 +0.0440034342 0.7470051430 +0.0441726619 0.7463925646 +0.0445044030 0.7451965726 +0.0447799423 0.7442081408 +0.0450253475 0.7433316240 +0.0453463382 0.7421906230 +0.0456599823 0.7410818081 +0.0460450198 0.7397289095 +0.0463325491 0.7387246698 +0.0465637319 0.7379210202 +0.0468612153 0.7368919134 +0.0471432534 0.7359215072 +0.0474087176 0.7350128587 +0.0475834041 0.7344174548 +0.0476606316 0.7341548746 +0.0479047065 0.7333276034 +0.0480227605 0.7329288973 +0.0482432416 0.7321867712 +0.0486030764 0.7309826655 +0.0488902048 0.7300282123 +0.0490264087 0.7295774426 +0.0491226194 0.7292598080 +0.0492906317 0.7287066721 +0.0494557620 0.7281649519 +0.0494762709 0.7280978048 +0.0496805787 0.7274305171 +0.0499937537 0.7264134172 +0.0501414608 0.7259361441 +0.0503484317 0.7252700226 +0.0504477231 0.7249515612 +0.0507211686 0.7240782418 +0.0509941463 0.7232118873 +0.0514111655 0.7218990444 +0.0516993609 0.7209993629 +0.0519333555 0.7202734989 +0.0520138186 0.7200248592 +0.0523655440 0.7189438029 +0.0527094385 0.7178960327 +0.0530505014 0.7168659813 +0.0533247669 0.7160442935 +0.0535522030 0.7153674210 +0.0536961857 0.7149410436 +0.0539226786 0.7142736870 +0.0542729460 0.7132497722 +0.0545718753 0.7123838129 +0.0548422347 0.7116069183 +0.0549807337 0.7112112661 +0.0552522995 0.7104400938 +0.0554245608 0.7099541031 +0.0554642028 0.7098426148 +0.0557355095 0.7090831390 +0.0559251621 0.7085559256 +0.0562772464 0.7075852652 +0.0567959585 0.7061745652 +0.0572856348 0.7048641986 +0.0576507424 0.7039008251 +0.0578722749 0.7033220194 +0.0579826175 0.7030353467 +0.0583233699 0.7021569099 +0.0585107057 0.7016783979 +0.0586683163 0.7012782580 +0.0589152172 0.7006559391 +0.0591712059 0.7000165547 +0.0593313410 0.6996196213 +0.0595679261 0.6990374856 +0.0596879886 0.6987440297 +0.0597919273 0.6984910564 +0.0598532005 0.6983423927 +0.0601420422 0.6976462759 +0.0603736874 0.6970936087 +0.0605760782 0.6966148402 +0.0607647336 0.6961720225 +0.0608835727 0.6958947984 +0.0611481301 0.6952824352 +0.0613933597 0.6947207334 +0.0616252405 0.6941948726 +0.0617114801 0.6940006080 +0.0620790585 0.6931805939 +0.0623719468 0.6925365176 +0.0625860127 0.6920710273 +0.0630987308 0.6909742466 +0.0635061169 0.6901211399 +0.0637844296 0.6895477285 +0.0640918984 0.6889231656 +0.0644701284 0.6881677698 +0.0647023437 0.6877110775 +0.0650249530 0.6870855944 +0.0652330033 0.6866877833 +0.0653423543 0.6864804475 +0.0654488482 0.6862796926 +0.0656172300 0.6859646177 +0.0656567874 0.6858910156 +0.0658327234 0.6855655908 +0.0660074892 0.6852454527 +0.0661995406 0.6848972472 +0.0663074061 0.6847033331 +0.0665094730 0.6843432793 +0.0667699400 0.6838853547 +0.0671436157 0.6832406132 +0.0673621585 0.6828702314 +0.0676548746 0.6823819064 +0.0680478574 0.6817403361 +0.0683270518 0.6812943328 +0.0687335562 0.6806595643 +0.0690300965 0.6802074678 +0.0693293144 0.6797606892 +0.0695505216 0.6794364778 +0.0697532285 0.6791439326 +0.0700261347 0.6787569641 +0.0703917670 0.6782509315 +0.0707729007 0.6777386210 +0.0712916128 0.6770663438 +0.0716774616 0.6765849831 +0.0719773117 0.6762219633 +0.0722712346 0.6758755200 +0.0724960238 0.6756168535 +0.0728875441 0.6751793644 +0.0732364471 0.6748034735 +0.0735861732 0.6744399355 +0.0738379780 0.6741864037 +0.0740166562 0.6740106769 +0.0742215332 0.6738134542 +0.0745353683 0.6735201959 +0.0748324729 0.6732524483 +0.0752210672 0.6729167612 +0.0755965740 0.6726080145 +0.0758688632 0.6723937510 +0.0760783642 0.6722343998 +0.0762090398 0.6721374295 +0.0762720685 0.6720913239 +0.0764187907 0.6719856749 +0.0765747129 0.6718759756 +0.0766011447 0.6718576424 +0.0767497593 0.6717559818 +0.0768078496 0.6717168998 +0.0770485469 0.6715588866 +0.0774273984 0.6713229792 +0.0776993770 0.6711632724 +0.0782800840 0.6708492640 +0.0788525184 0.6705756699 +0.0792997562 0.6703867107 +0.0797034248 0.6702348093 +0.0799846997 0.6701394109 +0.0801524418 0.6700865978 +0.0804359408 0.6700042596 +0.0806711539 0.6699425386 +0.0809076056 0.6698865116 +0.0811192571 0.6698414733 +0.0814211472 0.6697855776 +0.0816908262 0.6697439295 +0.0819181881 0.6697148794 +0.0823765250 0.6696731419 +0.0828473667 0.6696536196 +0.1824747079 0.6682957828 +0.1827373042 0.6668379181 +0.1829934200 0.6654064856 +0.1832008830 0.6642401022 +0.1835325807 0.6623625566 +0.1840130923 0.6596151795 +0.1844136563 0.6573003083 +0.1846547945 0.6558960797 +0.1850327646 0.6536790223 +0.1855514767 0.6506049186 +0.1859032316 0.6484997804 +0.1862571443 0.6463652113 +0.1865781222 0.6444151024 +0.1867381357 0.6434379418 +0.1870567377 0.6414825070 +0.1873506813 0.6396669210 +0.1875908212 0.6381755498 +0.1877572846 0.6371374939 +0.1878386950 0.6366285640 +0.1882765200 0.6338774632 +0.1888441256 0.6302759901 +0.1892961923 0.6273799277 +0.1896479177 0.6251099884 +0.1899216837 0.6233332085 +0.1901596799 0.6217815704 +0.1905021558 0.6195374578 +0.1907437681 0.6179463286 +0.1908541931 0.6172169635 +0.1910015634 0.6162414722 +0.1910592217 0.6158591627 +0.1913795526 0.6137285628 +0.1916022091 0.6122410756 +0.1918542490 0.6105508918 +0.1920630625 0.6091454935 +0.1922707349 0.6077432472 +0.1923574812 0.6071561924 +0.1925399478 0.6059188204 +0.1927127826 0.6047436241 +0.1932256466 0.6012386596 +0.1937303630 0.5977640158 +0.1944123056 0.5930305273 +0.1949310177 0.5894011703 +0.1952907647 0.5868698611 +0.1955428228 0.5850895151 +0.1957338951 0.5837362693 +0.1959506900 0.5821970824 +0.1961476249 0.5807954737 +0.1963512801 0.5793426559 +0.1965346412 0.5780317096 +0.1968033756 0.5761054945 +0.1970607366 0.5742554420 +0.1974781249 0.5712441366 +0.1978230478 0.5687457361 +0.1983417599 0.5649722025 +0.1987585410 0.5619264912 +0.1990311925 0.5599276545 +0.1992358082 0.5584243672 +0.1993614322 0.5575000768 +0.1995662000 0.5559913203 +0.1997751609 0.5544489585 +0.1999667287 0.5530326194 +0.2002564937 0.5508860807 +0.2003811045 0.5499614639 +0.2006038409 0.5483065276 +0.2010021822 0.5453399268 +0.2012337900 0.5436111052 +0.2015290071 0.5414034185 +0.2018860370 0.5387276261 +0.2020864756 0.5372227120 +0.2024146698 0.5347545517 +0.2027721744 0.5320604855 +0.2029652911 0.5306029304 +0.2036494328 0.5254273064 +0.2037918467 0.5243476959 +0.2040759367 0.5221919202 +0.2042545974 0.5208347687 +0.2043734498 0.5199313558 +0.2046445322 0.5178691539 +0.2048561060 0.5162581076 +0.2054073512 0.5120547358 +0.2054972178 0.5113687330 +0.2056650614 0.5100869645 +0.2060618135 0.5070545512 +0.2063499033 0.5048506040 +0.2063806988 0.5046149187 +0.2065289984 0.5034797026 +0.2065386776 0.5034055960 +0.2067652829 0.5016701953 +0.2068756268 0.5008248564 +0.2072025889 0.4983189841 +0.2079865360 0.4923056583 +0.2080552744 0.4917781338 +0.2082324576 0.4904182206 +0.2082767918 0.4900779188 +0.2084572594 0.4886925802 +0.2084982003 0.4883782832 +0.2089079600 0.4852323538 +0.2090520981 0.4841256760 +0.2096320525 0.4796731020 +0.2097606455 0.4786859815 +0.2103218452 0.4743792398 +0.2105433294 0.4726802577 +0.2106133311 0.4721433877 +0.2112569439 0.4672101715 +0.2114660166 0.4656089731 +0.2123187022 0.4590871651 +0.2131713877 0.4525824143 +0.2140240733 0.4460991906 +0.2141744858 0.4449581302 +0.2147429805 0.4406531527 +0.2148767588 0.4396419800 +0.2150226572 0.4385400544 +0.2151610011 0.4374960306 +0.2155880417 0.4342787333 +0.2156715366 0.4336506749 +0.2157294444 0.4332152810 +0.2157694979 0.4329142234 +0.2158193744 0.4325394410 +0.2164019203 0.4281712993 +0.2165821300 0.4268236007 +0.2165868632 0.4267882264 +0.2166382981 0.4264039060 +0.2166716890 0.4261544874 +0.2168971922 0.4244716742 +0.2174348155 0.4204714516 +0.2177286617 0.4182923973 +0.2182875011 0.4141633474 +0.2191401866 0.4079037996 +0.2192092469 0.4073990920 +0.2193259541 0.4065469676 +0.2197739050 0.4032858086 +0.2198406810 0.4028009851 +0.2199928722 0.4016973140 +0.2200434960 0.4013306013 +0.2203664505 0.3989959983 +0.2208455577 0.3955483864 +0.2211857673 0.3931121154 +0.2216982433 0.3894614995 +0.2224841626 0.3839100178 +0.2225509288 0.3834411184 +0.2230708562 0.3798047124 +0.2234036144 0.3774916878 +0.2236749044 0.3756144141 +0.2241705672 0.3722046966 +0.2242562999 0.3716176274 +0.2247012462 0.3685838327 +0.2251089855 0.3658233284 +0.2254846966 0.3632966806 +0.2256380391 0.3622702351 +0.2259616710 0.3601131499 +0.2268143566 0.3544914153 +0.2269037613 0.3539072694 +0.2276670421 0.3489624078 +0.2281103951 0.3461256564 +0.2284526376 0.3439541530 +0.2285197277 0.3435303676 +0.2293200719 0.3385237273 +0.2293396461 0.3384024239 +0.2293724132 0.3381994876 +0.2294968854 0.3374300133 +0.2296800171 0.3363020183 +0.2297577720 0.3358245769 +0.2300275251 0.3341751270 +0.2302250988 0.3329739099 +0.2304780201 0.3314447659 +0.2309139435 0.3288321015 +0.2310777843 0.3278577220 +0.2316447522 0.3245183980 +0.2317466886 0.3239234228 +0.2319304699 0.3228549533 +0.2322646184 0.3209262765 +0.2322675102 0.3209096643 +0.2326165189 0.3189148858 +0.2327831554 0.3179695717 +0.2334122828 0.3144425877 +0.2336185363 0.3133009319 +0.2336358410 0.3132054792 +0.2344885265 0.3085665094 +0.2350785884 0.3054315538 +0.2353412121 0.3040564232 +0.2353574766 0.3039716723 +0.2357106365 0.3021433829 +0.2361494584 0.2999037148 +0.2361938976 0.2996789056 +0.2362157389 0.2995685501 +0.2362451566 0.2994200560 +0.2365222345 0.2980294084 +0.2365486157 0.2978977571 +0.2370465832 0.2954375624 +0.2372412379 0.2944887902 +0.2373547984 0.2939386609 +0.2374943975 0.2932658180 +0.2378992687 0.2913359166 +0.2387519543 0.2873774051 +0.2391475268 0.2855905375 +0.2395096834 0.2839825392 +0.2395801353 0.2836728516 +0.2396046398 0.2835653755 +0.2404573254 0.2799030828 +0.2411490497 0.2770443042 +0.2413100109 0.2763936863 +0.2414336135 0.2758978465 +0.2420882410 0.2733267747 +0.2421626965 0.2730402465 +0.2425730674 0.2714828065 +0.2430153820 0.2698457218 +0.2432027902 0.2691651976 +0.2433419448 0.2686649669 +0.2433651935 0.2685818156 +0.2433674014 0.2685739249 +0.2437105387 0.2673609416 +0.2437217900 0.2673216175 +0.2437320374 0.2672858265 +0.2438680676 0.2668129659 +0.2439830416 0.2664165644 +0.2447207531 0.2639447247 +0.2448928051 0.2633861641 +0.2449517244 0.2631964526 +0.2451769624 0.2624786152 +0.2452816039 0.2621491187 +0.2453810174 0.2618384393 +0.2455734387 0.2612436334 +0.2455736491 0.2612429878 +0.2458092287 0.2605265523 +0.2458778269 0.2603203767 +0.2463140002 0.2590353079 +0.2464141094 0.2587466935 +0.2464261242 0.2587122139 +0.2472788098 0.2563528720 +0.2473870886 0.2560657000 +0.2475759375 0.2555715859 +0.2480189656 0.2544461828 +0.2480891828 0.2542721739 +0.2481314953 0.2541678948 +0.2482020169 0.2539950606 +0.2486844706 0.2528451466 +0.2489841809 0.2521594483 +0.2492553014 0.2515581637 +0.2493371796 0.2513801353 +0.2493457504 0.2513615955 +0.2494104516 0.2512222219 +0.2494378405 0.2511635346 +0.2496888176 0.2506343931 +0.2497552029 0.2504970399 +0.2498368664 0.2503295748 +0.2498807861 0.2502401945 +0.2500901454 0.2498207203 +0.2505251969 0.2489839818 +0.2506895520 0.2486801906 +0.2510571995 0.2480251737 +0.2515422375 0.2472130838 +0.2516620739 0.2470216019 +0.2518406640 0.2467429910 +0.2522596072 0.2461212008 +0.2523115515 0.2460472180 +0.2523949231 0.2459299122 +0.2524376295 0.2458705099 +0.2525663442 0.2456942908 +0.2532476086 0.2448322009 +0.2535325365 0.2445069822 +0.2535639434 0.2444724130 +0.2535644347 0.2444718742 +0.2539076627 0.2441107097 +0.2541002942 0.2439213408 +0.2546621954 0.2434238529 +0.2549529797 0.2431985863 +0.2550488590 0.2431291323 +0.2551936932 0.2430287561 +0.2553742605 0.2429112738 +0.2558056653 0.2426650537 +0.2559100389 0.2426127938 +0.2564216354 0.2423979110 +0.2565766752 0.2423463457 +0.2566583508 0.2423217197 +0.2566588832 0.2423215649 +0.2570180981 0.2422341244 +0.2572989269 0.2421894148 +0.2575110364 0.2421694194 +0.4098582019 0.2348828551 +0.4100040285 0.2329368690 +0.4101417500 0.2311003352 +0.4101986798 0.2303415450 +0.4104141778 0.2274713125 +0.4108833219 0.2212344319 +0.4109944356 0.2197597237 +0.4111714943 0.2174118150 +0.4112404293 0.2164983809 +0.4113085988 0.2155954751 +0.4114829782 0.2132875875 +0.4118471211 0.2084766701 +0.4120396284 0.2059381324 +0.4126998067 0.1972592212 +0.4135524922 0.1861154077 +0.4139115213 0.1814471928 +0.4140105118 0.1801627115 +0.4141069858 0.1789119971 +0.4144051778 0.1750532381 +0.4151431065 0.1655519011 +0.4151986117 0.1648400932 +0.4152578633 0.1640806927 +0.4156037319 0.1596573475 +0.4156466759 0.1591092789 +0.4157214432 0.1581556824 +0.4158089490 0.1570406116 +0.4161105489 0.1532057175 +0.4165466837 0.1476836195 +0.4169632344 0.1424362181 +0.4178159200 0.1317800534 +0.4183217051 0.1255159076 +0.4186686055 0.1212450299 +0.4186787865 0.1211200063 +0.4186814505 0.1210872954 +0.4187573183 0.1201562445 +0.4195212911 0.1108388954 +0.4196912985 0.1087802178 +0.4197446990 0.1081347040 +0.4203739766 0.1005693330 +0.4212266622 0.0904439550 +0.4220793477 0.0804702970 +0.4228425261 0.0716783516 +0.4229320333 0.0706558123 +0.4229376574 0.0705916230 +0.4230191873 0.0696619194 +0.4231561604 0.0681034315 +0.4237847188 0.0610078653 +0.4240658757 0.0578643885 +0.4245002961 0.0530451040 +0.4246374044 0.0515337262 +0.4246507852 0.0513864762 +0.4254169068 0.0430308882 +0.4254393427 0.0427884507 +0.4254579173 0.0425878348 +0.4254900899 0.0422405649 +0.4259170918 0.0376570251 +0.4263427755 0.0331354455 +0.4271954610 0.0242253203 +0.4274585653 0.0215164472 +0.4277141542 0.0189035410 +0.4280481466 0.0155170246 +0.4287973840 0.0080371276 +0.4289008321 0.0070172706 +0.4290926681 0.0051344203 +0.4291478856 0.0045944951 +0.4292687761 0.0034155882 +0.4297050276 -0.0008021133 +0.4297535177 -0.0012673577 +0.4298439841 -0.0021334331 +0.4299046629 -0.0027129362 +0.4300707096 -0.0042929680 +0.4306062032 -0.0093304099 +0.4307991437 -0.0111234744 +0.4309630779 -0.0126377513 +0.4310458812 -0.0133993772 +0.4314191740 -0.0168057931 +0.4314588888 -0.0171655750 +0.4318711408 -0.0208701208 +0.4323115744 -0.0247666858 +0.4323640925 -0.0252270614 +0.4323778282 -0.0253473187 +0.4324984386 -0.0264005891 +0.4326632565 -0.0278321036 +0.4331642599 -0.0321277250 +0.4332164032 -0.0325699452 +0.4332559566 -0.0329047785 +0.4332908224 -0.0331994892 +0.4333819941 -0.0339681867 +0.4334426579 -0.0344780954 +0.4337340703 -0.0369100367 +0.4338258496 -0.0376699375 +0.4339001649 -0.0382831180 +0.4340169455 -0.0392428295 +0.4345476674 -0.0435446602 +0.4346628819 -0.0444655343 +0.4348478610 -0.0459342397 +0.4348696310 -0.0461062958 +0.4353749557 -0.0500527542 +0.4355632364 -0.0514998544 +0.4357223166 -0.0527125847 +0.4362539063 -0.0566986161 +0.4363378884 -0.0573189226 +0.4363807794 -0.0576347267 +0.4364646315 -0.0582501762 +0.4365750021 -0.0590563260 +0.4374276877 -0.0651323234 +0.4374529676 -0.0653083224 +0.4378940237 -0.0683402368 +0.4380374175 -0.0693101147 +0.4382803732 -0.0709355587 +0.4383534569 -0.0714201053 +0.4383787512 -0.0715873315 +0.4387398436 -0.0739478443 +0.4391330588 -0.0764611964 +0.4391332880 -0.0764626443 +0.4393852604 -0.0780416508 +0.4393888542 -0.0780639924 +0.4396288252 -0.0795444322 +0.4397822029 -0.0804788439 +0.4398085693 -0.0806385438 +0.4399857443 -0.0817045878 +0.4401025811 -0.0824008119 +0.4404724574 -0.0845692636 +0.4408384299 -0.0866612754 +0.4411810648 -0.0885713055 +0.4415263797 -0.0904484668 +0.4415561080 -0.0906078198 +0.4416911154 -0.0913269970 +0.4416966088 -0.0913561036 +0.4417812955 -0.0918032620 +0.4417851622 -0.0918236092 +0.4421658579 -0.0937970853 +0.4422985945 -0.0944712620 +0.4423032247 -0.0944946493 +0.4424199989 -0.0950815637 +0.4424415629 -0.0951893336 +0.4425438010 -0.0956976891 +0.4426833911 -0.0963848289 +0.4427447461 -0.0966843135 +0.4433964865 -0.0997694912 +0.4434666353 -0.1000910500 +0.4437950990 -0.1015694125 +0.4438830561 -0.1019576390 +0.4442000924 -0.1033300618 +0.4442491721 -0.1035387491 +0.4447257997 -0.1055125495 +0.4451018576 -0.1070020186 +0.4458893498 -0.1099259077 +0.4459545432 -0.1101560686 +0.4461220094 -0.1107389276 +0.4461342828 -0.1107811704 +0.4462568346 -0.1111994144 +0.4468072287 -0.1129978846 +0.4468862824 -0.1132454372 +0.4470300929 -0.1136888213 +0.4470858412 -0.1138582850 +0.4472320330 -0.1142962628 +0.4472735211 -0.1144188641 +0.4476087225 -0.1153819101 +0.4476167235 -0.1154042984 +0.4476599143 -0.1155246713 +0.4483596140 -0.1173609793 +0.4485125998 -0.1177338558 +0.4487221788 -0.1182279460 +0.4491526219 -0.1191819743 +0.4493652854 -0.1196230903 +0.4496493598 -0.1201810691 +0.4497353421 -0.1203428969 +0.4497536984 -0.1203770201 +0.4498039672 -0.1204697004 +0.4501515607 -0.1210798084 +0.4502179709 -0.1211902547 +0.4508104132 -0.1220884801 +0.4508762980 -0.1221786821 +0.4510706565 -0.1224334587 +0.4513843057 -0.1228089196 +0.4517361098 -0.1231775371 +0.4519233420 -0.1233510443 +0.4522228486 -0.1235958014 +0.4524547621 -0.1237575671 +0.4525470994 -0.1238152261 +0.4527760276 -0.1239415880 +0.4528032170 -0.1239550242 +0.4531242504 -0.1240884232 +0.4531581815 -0.1240998012 +0.4531961700 -0.1241119223 +0.4536287131 -0.1242039021 +0.6184020756 -0.1243106190 +0.6184454865 -0.1250679966 +0.6190497100 -0.1355538383 +0.6196671059 -0.1461578293 +0.6199023956 -0.1501687797 +0.6199587998 -0.1511277725 +0.6207550811 -0.1645600367 +0.6207934439 -0.1652020771 +0.6209983076 -0.1686226116 +0.6212508782 -0.1728208152 +0.6216077667 -0.1787169427 +0.6219727086 -0.1847017514 +0.6219876207 -0.1849453356 +0.6224604522 -0.1926289728 +0.6225746064 -0.1944723125 +0.6233131378 -0.2062857523 +0.6239825747 -0.2168220720 +0.6239839713 -0.2168438789 +0.6240710760 -0.2182024938 +0.6240967403 -0.2186022478 +0.6241658233 -0.2196770641 +0.6243192383 -0.2220574690 +0.6245378035 -0.2254332346 +0.6246631475 -0.2273609009 +0.6250185089 -0.2327928572 +0.6252210187 -0.2358662376 +0.6252555762 -0.2363890811 +0.6256415168 -0.2421959227 +0.6256591138 -0.2424592645 +0.6258711944 -0.2456232543 +0.6259532367 -0.2468423375 +0.6267238800 -0.2581585591 +0.6275765655 -0.2703892646 +0.6277270264 -0.2725151175 +0.6284292511 -0.2823060601 +0.6286961317 -0.2859699288 +0.6287325749 -0.2864677680 +0.6292819366 -0.2938998386 +0.6299394401 -0.3026135805 +0.6301346222 -0.3051617041 +0.6304099012 -0.3087251433 +0.6307546121 -0.3131368690 +0.6309873077 -0.3160829787 +0.6310487510 -0.3168565668 +0.6313051128 -0.3200646101 +0.6318399933 -0.3266552094 +0.6318999444 -0.3273851798 +0.6321276444 -0.3301415343 +0.6325151072 -0.3347727595 +0.6326926788 -0.3368701750 +0.6332478210 -0.3433248264 +0.6334204619 -0.3453002275 +0.6335453644 -0.3467198926 +0.6336573460 -0.3479858928 +0.6336971764 -0.3484346386 +0.6339773887 -0.3515684940 +0.6343980499 -0.3561966244 +0.6344388464 -0.3566405571 +0.6348607985 -0.3611808023 +0.6352507355 -0.3652928835 +0.6356154423 -0.3690655298 +0.6361034210 -0.3740014404 +0.6364452642 -0.3773822703 +0.6368583045 -0.3813819896 +0.6369561066 -0.3823153290 +0.6369705750 -0.3824529550 +0.6370845178 -0.3835327566 +0.6375080245 -0.3874830959 +0.6378087921 -0.3902278522 +0.6382020221 -0.3937398281 +0.6382194765 -0.3938936953 +0.6386614777 -0.3977325875 +0.6387380999 -0.3983867820 +0.6389638372 -0.4002946383 +0.6391918052 -0.4021917537 +0.6395141632 -0.4048233927 +0.6403668488 -0.4114944107 +0.6404651097 -0.4122359285 +0.6407627079 -0.4144471837 +0.6407638189 -0.4144553413 +0.6412195343 -0.4177400749 +0.6420292062 -0.4232721666 +0.6420722199 -0.4235551138 +0.6422532320 -0.4247336695 +0.6424991181 -0.4263030876 +0.6429249054 -0.4289345559 +0.6437775910 -0.4338737337 +0.6437796731 -0.4338852516 +0.6438234593 -0.4341268612 +0.6446302765 -0.4383682882 +0.6448007468 -0.4392131548 +0.6449820746 -0.4400921146 +0.6454829621 -0.4424141729 +0.6460598213 -0.4448949556 +0.6463356476 -0.4460076574 +0.6464264773 -0.4463636359 +0.6471883332 -0.4491453310 +0.6475091364 -0.4502071611 +0.6478721399 -0.4513301403 +0.6480410188 -0.4518241062 +0.6483680612 -0.4527291844 +0.6486736402 -0.4535133600 +0.6488937043 -0.4540412215 +0.6490445958 -0.4543852976 +0.6490769649 -0.4544572142 +0.6496691777 -0.4556546720 +0.6497141963 -0.4557365144 +0.6497463899 -0.4557942443 +0.6502262359 -0.4565758810 +0.6504014060 -0.4568243693 +0.6505990754 -0.4570810740 +0.6508915100 -0.4574147149 +0.6512142266 -0.4577189410 +0.6513561638 -0.4578314766 +0.6514517610 -0.4578999436 +0.6518148357 -0.4581062052 +0.6523044465 -0.4582494224 +0.8236942423 -0.4656399170 +0.8244611317 -0.4810280805 +0.8245469278 -0.4827307625 +0.8247849896 -0.4874350785 +0.8249379580 -0.4904421186 +0.8252764784 -0.4970524946 +0.8253052504 -0.4976115054 +0.8253996134 -0.4994417560 +0.8254900917 -0.5011921484 +0.8256108952 -0.5035222955 +0.8259901515 -0.5107859382 +0.8262522989 -0.5157603793 +0.8263781215 -0.5181343938 +0.8263998990 -0.5185443940 +0.8264879094 -0.5201986387 +0.8266323925 -0.5229049146 +0.8266609167 -0.5234378040 +0.8267493168 -0.5250863775 +0.8269624824 -0.5290434770 +0.8271049845 -0.5316743727 +0.8271058621 -0.5316905391 +0.8271631321 -0.5327445643 +0.8279576700 -0.5471717444 +0.8286341178 -0.5591619086 +0.8286675882 -0.5597480764 +0.8288103556 -0.5622407796 +0.8289117204 -0.5640031175 +0.8293682480 -0.5718628113 +0.8296630411 -0.5768700500 +0.8302180569 -0.5861507110 +0.8305157267 -0.5910484223 +0.8308126715 -0.5958781397 +0.8310499835 -0.5996973866 +0.8313684122 -0.6047650671 +0.8322210978 -0.6180094673 +0.8326425958 -0.6243788564 +0.8330737833 -0.6307714262 +0.8331690621 -0.6321670428 +0.8335579400 -0.6377991851 +0.8335962178 -0.6383479833 +0.8339264689 -0.6430410760 +0.8343756460 -0.6493032557 +0.8345459403 -0.6516407149 +0.8347791544 -0.6548088851 +0.8349253950 -0.6567760459 +0.8356318400 -0.6660656663 +0.8357570559 -0.6676751432 +0.8364845255 -0.6768025834 +0.8368088552 -0.6807482529 +0.8368332286 -0.6810416698 +0.8370031084 -0.6830746718 +0.8371853783 -0.6852324055 +0.8373372111 -0.6870111593 +0.8379621683 -0.6941530781 +0.8380928583 -0.6956098636 +0.8381898966 -0.6966832817 +0.8382094851 -0.6968991112 +0.8387351664 -0.7025835533 +0.8387982285 -0.7032514909 +0.8390425822 -0.7058112109 +0.8393742696 -0.7092132857 +0.8397852094 -0.7133118602 +0.8398312494 -0.7137629928 +0.8398952677 -0.7143875855 +0.8400976177 -0.7163410894 +0.8407479533 -0.7224054283 +0.8410918730 -0.7254797457 +0.8412498750 -0.7268611987 +0.8416006388 -0.7298581530 +0.8417113899 -0.7307843563 +0.8424533244 -0.7367395687 +0.8433060099 -0.7430438863 +0.8438789555 -0.7469530783 +0.8441586955 -0.7487657224 +0.8442747933 -0.7494994499 +0.8448382803 -0.7529055420 +0.8450113810 -0.7539001049 +0.8458139940 -0.7581921713 +0.8458640666 -0.7584424769 +0.8462369389 -0.7602417031 +0.8464098786 -0.7610374021 +0.8467167521 -0.7623887010 +0.8467297492 -0.7624442189 +0.8467865333 -0.7626851412 +0.8475694377 -0.7657350633 +0.8475873208 -0.7657987988 +0.8479958367 -0.7671824333 +0.8481982545 -0.7678166157 +0.8484221232 -0.7684782767 +0.8486716850 -0.7691666322 +0.8488883339 -0.7697220602 +0.8489466629 -0.7698649017 +0.8490424709 -0.7700933541 +0.8492748088 -0.7706154841 +0.8498940763 -0.7717863694 +0.8498956098 -0.7717888699 +0.8501274943 -0.7721442618 +0.8509801799 -0.7730626213 +0.8511956627 -0.7731978855 +0.8513782046 -0.7732818778 +0.8517201435 -0.7733636553 +0.8518328654 -0.7733690123 diff --git a/src/problems/ZDT/ZDT4.txt b/src/problems/ZDT/ZDT4.txt new file mode 100644 index 0000000..d9aedde --- /dev/null +++ b/src/problems/ZDT/ZDT4.txt @@ -0,0 +1,1000 @@ +0.0000000001 0.9999894726 +0.0002105478 0.9854897362 +0.0006312647 0.9748750180 +0.0011630803 0.9658960376 +0.0017746306 0.9578736358 +0.0024505398 0.9504970728 +0.0031768967 0.9436360339 +0.0039503274 0.9371483698 +0.0047628349 0.9309867048 +0.0056133085 0.9250779837 +0.0064844270 0.9194740603 +0.0073825092 0.9140784704 +0.0083046512 0.9088701410 +0.0092513217 0.9038162085 +0.0102235345 0.8988885045 +0.0112037024 0.8941524567 +0.0122063005 0.8895178727 +0.0132289862 0.8849826699 +0.0142533197 0.8806127324 +0.0152866946 0.8763606266 +0.0163381500 0.8721792270 +0.0173920785 0.8681209701 +0.0184482339 0.8641757241 +0.0195148773 0.8603043403 +0.0205965083 0.8564851634 +0.0216666513 0.8528040377 +0.0227383129 0.8492077161 +0.0238229080 0.8456532864 +0.0249019551 0.8421964667 +0.0259929519 0.8387767019 +0.0270660633 0.8354823314 +0.0281500276 0.8322203004 +0.0292333708 0.8290223089 +0.0303128734 0.8258940741 +0.0314021618 0.8227934486 +0.0324911066 0.8197471037 +0.0335765797 0.8167608674 +0.0346709704 0.8137985757 +0.0357370146 0.8109576380 +0.0368111297 0.8081377324 +0.0378895903 0.8053475139 +0.0389532784 0.8026341508 +0.0400243289 0.7999391870 +0.0410894955 0.7972945598 +0.0421616561 0.7946669628 +0.0432213442 0.7921025634 +0.0442876083 0.7895537876 +0.0453412088 0.7870652476 +0.0463909832 0.7846143384 +0.0474467646 0.7821772174 +0.0484983540 0.7797765817 +0.0495450062 0.7774129245 +0.0505853782 0.7750880658 +0.0516311551 0.7727751001 +0.0526673294 0.7705063631 +0.0537086508 0.7682487307 +0.0547368762 0.7660408665 +0.0557699761 0.7638433229 +0.0568037616 0.7616646026 +0.0578314646 0.7595182655 +0.0588637743 0.7573814221 +0.0598984973 0.7552583048 +0.0609298646 0.7531602451 +0.0619606711 0.7510809949 +0.0629836759 0.7490345126 +0.0640108688 0.7469963068 +0.0650299931 0.7449902099 +0.0660450761 0.7430076342 +0.0670640897 0.7410326474 +0.0680825901 0.7390735925 +0.0691035230 0.7371245105 +0.0701179135 0.7352021270 +0.0711359997 0.7332866714 +0.0721531501 0.7313866160 +0.0731706023 0.7294993488 +0.0741806823 0.7276386915 +0.0751924292 0.7257876203 +0.0762062164 0.7239452655 +0.0772233979 0.7221090179 +0.0782425560 0.7202812914 +0.0792510937 0.7184842922 +0.0802628607 0.7166929921 +0.0812759972 0.7149105453 +0.0822884477 0.7131403693 +0.0833012730 0.7113804009 +0.0843171957 0.7096257661 +0.0853334216 0.7078811516 +0.0863411931 0.7061612805 +0.0873519226 0.7044464133 +0.0883637196 0.7027396435 +0.0893732618 0.7010463885 +0.0903856712 0.6993579018 +0.0913949697 0.6976839903 +0.0924070702 0.6960146875 +0.0934200164 0.6943531181 +0.0944275417 0.6927093530 +0.0954377690 0.6910699610 +0.0964475333 0.6894399682 +0.0974559260 0.6878206830 +0.0984669407 0.6862055758 +0.0994732780 0.6846061542 +0.1004805510 0.6830133268 +0.1014903611 0.6814244813 +0.1024949925 0.6798516087 +0.1035020978 0.6782825809 +0.1045074114 0.6767239394 +0.1055120333 0.6751738415 +0.1065190579 0.6736274247 +0.1075236424 0.6720920215 +0.1085305843 0.6705601963 +0.1095359091 0.6690379038 +0.1105435514 0.6675190963 +0.1115512301 0.6660071407 +0.1125570012 0.6645048418 +0.1135639375 0.6630075113 +0.1145731157 0.6615134925 +0.1155784246 0.6600317301 +0.1165859290 0.6585531828 +0.1175892437 0.6570871193 +0.1185930860 0.6556265313 +0.1195990615 0.6541690275 +0.1206040643 0.6527190413 +0.1216111695 0.6512720695 +0.1226168930 0.6498330498 +0.1236222729 0.6484004083 +0.1246297053 0.6469706736 +0.1256343337 0.6455506613 +0.1266409786 0.6441334821 +0.1276471982 0.6427225193 +0.1286513413 0.6413200016 +0.1296564281 0.6399216362 +0.1306634703 0.6385259756 +0.1316668478 0.6371407329 +0.1326721441 0.6357581242 +0.1336779496 0.6343800476 +0.1346824492 0.6330089249 +0.1356853479 0.6316450789 +0.1366873372 0.6302874938 +0.1376911695 0.6289323922 +0.1386940586 0.6275834878 +0.1396967886 0.6262396642 +0.1407006623 0.6248991305 +0.1417038828 0.6235642382 +0.1427088852 0.6222317044 +0.1437113389 0.6209072159 +0.1447140663 0.6195869794 +0.1457185366 0.6182690258 +0.1467241957 0.6169540553 +0.1477281975 0.6156457395 +0.1487317722 0.6143424158 +0.1497370456 0.6130412870 +0.1507395611 0.6117480700 +0.1517437491 0.6104569997 +0.1527491415 0.6091686534 +0.1537521086 0.6078876327 +0.1547567167 0.6066086977 +0.1557592375 0.6053365516 +0.1567622432 0.6040678806 +0.1577668585 0.6028012356 +0.1587687449 0.6015420413 +0.1597722169 0.6002848303 +0.1607742633 0.5990333389 +0.1617765541 0.5977854377 +0.1627804021 0.5965394665 +0.1637844766 0.5952970514 +0.1647863012 0.5940612100 +0.1657896532 0.5928272441 +0.1667919637 0.5915982815 +0.1677957846 0.5903711624 +0.1687999261 0.5891473183 +0.1698025772 0.5879289173 +0.1708067129 0.5867123122 +0.1718093417 0.5855010957 +0.1728134375 0.5842916436 +0.1738186323 0.5830843822 +0.1748211768 0.5818837759 +0.1758239238 0.5806863659 +0.1768265821 0.5794924708 +0.1778306658 0.5783002658 +0.1788332145 0.5771132368 +0.1798358264 0.5759294559 +0.1808398397 0.5747473225 +0.1818418499 0.5735708149 +0.1828452443 0.5723959257 +0.1838468916 0.5712262933 +0.1848493707 0.5700588753 +0.1858532128 0.5688930379 +0.1868559327 0.5677316427 +0.1878592674 0.5665726503 +0.1888620073 0.5654174333 +0.1898660817 0.5642637475 +0.1908674683 0.5631161845 +0.1918701717 0.5619701247 +0.1928737645 0.5608260430 +0.1938761620 0.5596862914 +0.1948789191 0.5585490751 +0.1958829695 0.5574133198 +0.1968839484 0.5562839327 +0.1978851741 0.5551571355 +0.1988876695 0.5540317618 +0.1998903999 0.5529089579 +0.2008922998 0.5517898932 +0.2018954520 0.5506722221 +0.2028989078 0.5495569871 +0.2039007023 0.5484463462 +0.2049011516 0.5473399160 +0.2059028251 0.5462348348 +0.2069049004 0.5451319967 +0.2079081919 0.5440304923 +0.2089091658 0.5429341778 +0.2099113416 0.5418391749 +0.2109132670 0.5407470555 +0.2119152403 0.5396574750 +0.2129184008 0.5385691809 +0.2139198230 0.5374853267 +0.2149224200 0.5364027394 +0.2159250466 0.5353226425 +0.2169277369 0.5342449818 +0.2179315886 0.5331685651 +0.2189353258 0.5320947469 +0.2199402161 0.5310221582 +0.2209406566 0.5299567503 +0.2219422321 0.5288925472 +0.2229444987 0.5278300108 +0.2239468923 0.5267697259 +0.2249504102 0.5257106261 +0.2259511071 0.5246568533 +0.2269529145 0.5236042459 +0.2279546225 0.5225540632 +0.2289564315 0.5215060799 +0.2299583451 0.5204602779 +0.2309608549 0.5194161312 +0.2319644550 0.5183731164 +0.2329659947 0.5173344899 +0.2339686130 0.5162969785 +0.2349707108 0.5152622247 +0.2359718198 0.5142306929 +0.2369739928 0.5132002539 +0.2379751637 0.5121730186 +0.2389762694 0.5111480087 +0.2399774526 0.5101250643 +0.2409787263 0.5091041594 +0.2419805638 0.5080848002 +0.2429834403 0.5070664951 +0.2439855244 0.5060510913 +0.2449886396 0.5050367290 +0.2459906664 0.5040255386 +0.2469925755 0.5030165239 +0.2479955026 0.5020085316 +0.2489970506 0.5010039573 +0.2499996077 0.5000003923 +0.2510019167 0.4989990851 +0.2520038840 0.4980001156 +0.2530057956 0.4970031853 +0.2540087011 0.4960072410 +0.2550103471 0.4950145080 +0.2560129786 0.4940227489 +0.2570152630 0.4930332723 +0.2580171398 0.4920461244 +0.2590199910 0.4910599338 +0.2600208175 0.4900776358 +0.2610226089 0.4890962822 +0.2620252361 0.4881159935 +0.2630267801 0.4871386346 +0.2640292794 0.4861622052 +0.2650319605 0.4851874511 +0.2660333481 0.4842157931 +0.2670347118 0.4832459852 +0.2680357884 0.4822782712 +0.2690371011 0.4813121352 +0.2700393471 0.4803468973 +0.2710418231 0.4793832282 +0.2720440694 0.4784215597 +0.2730454143 0.4774625235 +0.2740471733 0.4765048488 +0.2750498495 0.4755480485 +0.2760526149 0.4745929055 +0.2770562927 0.4736386292 +0.2780569657 0.4726889289 +0.2790577919 0.4717407910 +0.2800595170 0.4707935025 +0.2810605780 0.4698485329 +0.2820625321 0.4689044040 +0.2830633674 0.4679630018 +0.2840650890 0.4670224310 +0.2850662377 0.4660840537 +0.2860682669 0.4651464996 +0.2870698581 0.4642109948 +0.2880712825 0.4632772759 +0.2890735788 0.4623443678 +0.2900757018 0.4614132365 +0.2910783508 0.4604832248 +0.2920798864 0.4595558434 +0.2930822820 0.4586292564 +0.2940842385 0.4577046575 +0.2950856983 0.4567820894 +0.2960870729 0.4558611640 +0.2970886374 0.4549416202 +0.2980910475 0.4540228508 +0.2990936425 0.4531054558 +0.3000950324 0.4521906971 +0.3010967550 0.4512771601 +0.3020993122 0.4503643824 +0.3031014386 0.4494535092 +0.3041029020 0.4485447416 +0.3051051913 0.4476367216 +0.3061067375 0.4467308635 +0.3071080050 0.4458267373 +0.3081100901 0.4449233476 +0.3091118903 0.4440216818 +0.3101127726 0.4431223001 +0.3111144638 0.4422236436 +0.3121167514 0.4413258988 +0.3131186269 0.4404299625 +0.3141199527 0.4395359488 +0.3151211702 0.4386434554 +0.3161229768 0.4377518547 +0.3171255784 0.4368609600 +0.3181264009 0.4359730495 +0.3191280118 0.4350858368 +0.3201301025 0.4341995913 +0.3211313107 0.4333155104 +0.3221333005 0.4324321182 +0.3231351783 0.4315501972 +0.3241358160 0.4306707315 +0.3251372272 0.4297919439 +0.3261379206 0.4289151372 +0.3271393827 0.4280390025 +0.3281401366 0.4271648260 +0.3291410306 0.4262918594 +0.3301426868 0.4254195559 +0.3311443335 0.4245485829 +0.3321446186 0.4236801074 +0.3331456580 0.4228122853 +0.3341469535 0.4219455445 +0.3351488093 0.4210796175 +0.3361510327 0.4202146667 +0.3371524512 0.4193516975 +0.3381546145 0.4184893685 +0.3391566314 0.4176284421 +0.3401593896 0.4167681511 +0.3411604553 0.4159105759 +0.3421620297 0.4150538233 +0.3431643380 0.4141976972 +0.3441651948 0.4133440576 +0.3451662555 0.4124914847 +0.3461676576 0.4116398572 +0.3471697849 0.4107888452 +0.3481709012 0.4099399173 +0.3491727381 0.4090915993 +0.3501746238 0.4082444560 +0.3511757655 0.4073991516 +0.3521774192 0.4065546199 +0.3531797861 0.4057106882 +0.3541826948 0.4048674982 +0.3551827727 0.4040278759 +0.3561835555 0.4031888443 +0.3571849903 0.4023504453 +0.3581857802 0.4015137594 +0.3591872702 0.4006776575 +0.3601882868 0.3998431148 +0.3611899999 0.3990091516 +0.3621908668 0.3981770470 +0.3631924261 0.3973455168 +0.3641936381 0.3965154202 +0.3651955391 0.3956858936 +0.3661969049 0.3948579465 +0.3671984667 0.3940309689 +0.3682007123 0.3932045548 +0.3692019399 0.3923801024 +0.3702038472 0.3915562087 +0.3712055375 0.3907336071 +0.3722079045 0.3899115601 +0.3732089877 0.3890916700 +0.3742100083 0.3882729299 +0.3752116992 0.3874547370 +0.3762133237 0.3866376897 +0.3772148257 0.3858218291 +0.3782157057 0.3850075564 +0.3792172488 0.3841938221 +0.3802181001 0.3833817225 +0.3812196110 0.3825701570 +0.3822206018 0.3817600775 +0.3832222488 0.3809505280 +0.3842235710 0.3801422978 +0.3852251764 0.3793348919 +0.3862274336 0.3785280106 +0.3872282277 0.3777233512 +0.3882296692 0.3769192113 +0.3892307415 0.3761164039 +0.3902324583 0.3753141123 +0.3912346802 0.3745124460 +0.3922368074 0.3737118814 +0.3932378133 0.3729132330 +0.3942394571 0.3721150925 +0.3952405845 0.3713183759 +0.3962423467 0.3705221635 +0.3972435960 0.3697273637 +0.3982454771 0.3689330645 +0.3992472187 0.3681398741 +0.4002480479 0.3673483992 +0.4012489559 0.3665578512 +0.4022496843 0.3657684301 +0.4032503529 0.3649800374 +0.4042516431 0.3641921335 +0.4052527434 0.3634053539 +0.4062544628 0.3626190599 +0.4072557686 0.3618340587 +0.4082576907 0.3610495398 +0.4092589953 0.3602664654 +0.4102609131 0.3594838698 +0.4112626065 0.3587024041 +0.4122636316 0.3579224100 +0.4132652652 0.3571428890 +0.4142674430 0.3563638893 +0.4152688799 0.3555864062 +0.4162709214 0.3548093915 +0.4172720122 0.3540340472 +0.4182737041 0.3532591677 +0.4192747583 0.3524857080 +0.4202764107 0.3517127097 +0.4212772980 0.3509412214 +0.4222787805 0.3501701911 +0.4232804027 0.3493999672 +0.4242813186 0.3486311962 +0.4252828255 0.3478628783 +0.4262837535 0.3470959079 +0.4272846573 0.3463298559 +0.4282856329 0.3455646457 +0.4292871941 0.3447998824 +0.4302888245 0.3440359579 +0.4312904321 0.3432729394 +0.4322910343 0.3425115710 +0.4332919868 0.3417508171 +0.4342935181 0.3409905023 +0.4352953978 0.3402307996 +0.4362973516 0.3394719146 +0.4372982381 0.3387147075 +0.4382996979 0.3379579335 +0.4393006265 0.3372024242 +0.4403021258 0.3364473451 +0.4413034896 0.3356932263 +0.4423054221 0.3349395350 +0.4433068964 0.3341870410 +0.4443085740 0.3334352440 +0.4453096867 0.3326847172 +0.4463107974 0.3319350351 +0.4473124701 0.3311857731 +0.4483130258 0.3304381837 +0.4493141404 0.3296910113 +0.4503155791 0.3289444292 +0.4513163666 0.3281991615 +0.4523176354 0.3274543618 +0.4533194590 0.3267099741 +0.4543204053 0.3259670592 +0.4553219036 0.3252245532 +0.4563237931 0.3244825738 +0.4573242750 0.3237424492 +0.4583253047 0.3230027292 +0.4593262806 0.3222638562 +0.4603278024 0.3215253856 +0.4613291449 0.3207878498 +0.4623310314 0.3200507141 +0.4633320623 0.3193150051 +0.4643336345 0.3185796932 +0.4653356544 0.3178448458 +0.4663361052 0.3171119380 +0.4673370931 0.3163794231 +0.4683378402 0.3156478683 +0.4693391225 0.3149167040 +0.4703402348 0.3141864431 +0.4713410174 0.3134571991 +0.4723423318 0.3127283420 +0.4733434528 0.3120003977 +0.4743451036 0.3112728380 +0.4753467082 0.3105460797 +0.4763473095 0.3098208135 +0.4773484369 0.3090959279 +0.4783495419 0.3083718182 +0.4793511712 0.3076480871 +0.4803522870 0.3069254824 +0.4813539248 0.3062032539 +0.4823555688 0.3054817722 +0.4833565520 0.3047615143 +0.4843580541 0.3040416291 +0.4853584322 0.3033232943 +0.4863589651 0.3026055886 +0.4873600131 0.3018882517 +0.4883612140 0.3011715418 +0.4893620785 0.3004558066 +0.4903634552 0.2997404372 +0.4913642855 0.2990261877 +0.4923653881 0.2983124712 +0.4933670001 0.2975991172 +0.4943688830 0.2968862944 +0.4953700904 0.2961746734 +0.4963718042 0.2954634117 +0.4973732519 0.2947530561 +0.4983752042 0.2940430578 +0.4993770732 0.2933338319 +0.5003793995 0.2926249937 +0.5013798719 0.2919181743 +0.5023808440 0.2912117072 +0.5033817843 0.2905059660 +0.5043832226 0.2898005755 +0.5053841880 0.2890962175 +0.5063856496 0.2883922081 +0.5073868334 0.2876890894 +0.5083877579 0.2869868459 +0.5093891756 0.2862849479 +0.5103907542 0.2855836269 +0.5113920834 0.2848831680 +0.5123939033 0.2841830518 +0.5133954642 0.2834838005 +0.5143963096 0.2827857296 +0.5153972877 0.2820882452 +0.5163983179 0.2813914015 +0.5173998337 0.2806948952 +0.5184013999 0.2799990278 +0.5194023355 0.2793042698 +0.5204032304 0.2786102091 +0.5214043454 0.2779166631 +0.5224054528 0.2772237879 +0.5234070402 0.2765312445 +0.5244083215 0.2758395748 +0.5254100811 0.2751482351 +0.5264109890 0.2744581411 +0.5274123732 0.2737683750 +0.5284133357 0.2730795534 +0.5294144273 0.2723912952 +0.5304153500 0.2717038034 +0.5314167455 0.2710166357 +0.5324178038 0.2703303461 +0.5334193331 0.2696443790 +0.5344202693 0.2689594612 +0.5354216747 0.2682748640 +0.5364229975 0.2675909630 +0.5374247881 0.2669073809 +0.5384256524 0.2662250670 +0.5394265638 0.2655433547 +0.5404279400 0.2648619585 +0.5414289726 0.2641814268 +0.5424304684 0.2635012095 +0.5434313875 0.2628220109 +0.5444327680 0.2621431250 +0.5454332114 0.2614654975 +0.5464341140 0.2607881805 +0.5474353065 0.2601112878 +0.5484366190 0.2594349326 +0.5494372200 0.2587596746 +0.5504379207 0.2580849640 +0.5514390766 0.2574105599 +0.5524403307 0.2567367017 +0.5534419480 0.2560632097 +0.5544431444 0.2553906095 +0.5554444467 0.2547185453 +0.5564456248 0.2540471699 +0.5574472537 0.2533760962 +0.5584478796 0.2527062963 +0.5594489541 0.2520367963 +0.5604499619 0.2513679395 +0.5614512555 0.2506994892 +0.5624529959 0.2500313367 +0.5634541722 0.2493641547 +0.5644550290 0.2486977779 +0.5654563297 0.2480316963 +0.5664573800 0.2473663707 +0.5674588728 0.2467013389 +0.5684603141 0.2460369279 +0.5694611285 0.2453735172 +0.5704623831 0.2447103979 +0.5714634373 0.2440479927 +0.5724649304 0.2433858775 +0.5734659813 0.2427246331 +0.5744674695 0.2420636772 +0.5754682081 0.2414037911 +0.5764693822 0.2407441919 +0.5774704071 0.2400852633 +0.5784718661 0.2394266202 +0.5794729710 0.2387687795 +0.5804745086 0.2381112229 +0.5814755874 0.2374545342 +0.5824770975 0.2367981280 +0.5834781770 0.2361425676 +0.5844796864 0.2354872883 +0.5854812475 0.2348325363 +0.5864819621 0.2341788968 +0.5874826373 0.2335258404 +0.5884833481 0.2328733168 +0.5894844847 0.2322210704 +0.5904856555 0.2315693554 +0.5914866485 0.2309183083 +0.5924878516 0.2302676754 +0.5934891833 0.2296175084 +0.5944909378 0.2289676156 +0.5954917979 0.2283188496 +0.5964925865 0.2276706748 +0.5974937953 0.2270227718 +0.5984953253 0.2263752038 +0.5994965587 0.2257283689 +0.6004982106 0.2250818039 +0.6015002183 0.2244355486 +0.6025013431 0.2237904000 +0.6035022941 0.2231458991 +0.6045033654 0.2225018550 +0.6055046739 0.2218581916 +0.6065063968 0.2212147942 +0.6075067706 0.2205727932 +0.6085075567 0.2199310565 +0.6095084202 0.2192897976 +0.6105096950 0.2186488018 +0.6115107578 0.2180084669 +0.6125122307 0.2173683940 +0.6135136639 0.2167288695 +0.6145149966 0.2160899308 +0.6155167376 0.2154512523 +0.6165178715 0.2148134798 +0.6175194122 0.2141759661 +0.6185202474 0.2135394178 +0.6195210710 0.2129033916 +0.6205222991 0.2122676222 +0.6215235142 0.2116323737 +0.6225247801 0.2109976045 +0.6235264489 0.2103630905 +0.6245270350 0.2097297709 +0.6255276077 0.2090969669 +0.6265285809 0.2084644159 +0.6275298171 0.2078322040 +0.6285311785 0.2072004172 +0.6295320318 0.2065694537 +0.6305332832 0.2059387409 +0.6315344158 0.2053086034 +0.6325354850 0.2046790051 +0.6335369506 0.2040496557 +0.6345379412 0.2034211017 +0.6355390288 0.2027929825 +0.6365405109 0.2021651105 +0.6375414081 0.2015380985 +0.6385422167 0.2009116340 +0.6395434177 0.2002854149 +0.6405441118 0.1996600024 +0.6415451971 0.1990348340 +0.6425464899 0.1984100238 +0.6435472938 0.1977860050 +0.6445484870 0.1971622287 +0.6455498066 0.1965388581 +0.6465509890 0.1959160560 +0.6475520639 0.1952938027 +0.6485535260 0.1946717899 +0.6495552002 0.1940501255 +0.6505561784 0.1934293717 +0.6515571679 0.1928090883 +0.6525585422 0.1921890430 +0.6535599267 0.1915694670 +0.6545608471 0.1909506523 +0.6555621504 0.1903320740 +0.6565630740 0.1897142023 +0.6575643794 0.1890965660 +0.6585650162 0.1884798116 +0.6595656632 0.1878635194 +0.6605666900 0.1872474608 +0.6615674655 0.1866320233 +0.6625684896 0.1860168984 +0.6635698921 0.1854020058 +0.6645709906 0.1847877634 +0.6655724665 0.1841737523 +0.6665742784 0.1835599970 +0.6675753583 0.1829471508 +0.6685768138 0.1823345343 +0.6695776224 0.1817227717 +0.6705788052 0.1811112376 +0.6715797575 0.1805003005 +0.6725807373 0.1798898018 +0.6735820898 0.1792795301 +0.6745834687 0.1786696957 +0.6755850054 0.1780602179 +0.6765862213 0.1774513867 +0.6775878078 0.1768427806 +0.6785892295 0.1762347243 +0.6795910208 0.1756268922 +0.6805918094 0.1750201158 +0.6815929661 0.1744135623 +0.6825942324 0.1738073878 +0.6835950796 0.1732019112 +0.6845962934 0.1725966561 +0.6855974192 0.1719918967 +0.6865989106 0.1713873579 +0.6875995449 0.1707837768 +0.6886002694 0.1701805802 +0.6896013578 0.1695776028 +0.6906025356 0.1689750090 +0.6916034324 0.1683730209 +0.6926046915 0.1677712505 +0.6936054767 0.1671701995 +0.6946062606 0.1665695826 +0.6956072227 0.1659692915 +0.6966085451 0.1653692163 +0.6976100449 0.1647694660 +0.6986105718 0.1641707281 +0.6996114572 0.1635722044 +0.7006121260 0.1629742382 +0.7016131523 0.1623764854 +0.7026143784 0.1617790396 +0.7036156464 0.1611819945 +0.7046166041 0.1605855588 +0.7056179175 0.1599893349 +0.7066188136 0.1593937821 +0.7076197944 0.1587986006 +0.7086211294 0.1582036295 +0.7096225483 0.1576090288 +0.7106241994 0.1570147099 +0.7116252814 0.1564211469 +0.7126263761 0.1558279938 +0.7136278225 0.1552350490 +0.7146287960 0.1546427998 +0.7156301202 0.1540507579 +0.7166316652 0.1534589997 +0.7176326872 0.1528679636 +0.7186340584 0.1522771335 +0.7196350244 0.1516869537 +0.7206363388 0.1510969792 +0.7216369658 0.1505078189 +0.7226379399 0.1499188628 +0.7236388529 0.1493303503 +0.7246401122 0.1487420413 +0.7256407605 0.1481544973 +0.7266416984 0.1475671883 +0.7276429812 0.1469800816 +0.7286443305 0.1463933397 +0.7296457222 0.1458069760 +0.7306471410 0.1452209987 +0.7316479446 0.1446357825 +0.7326490906 0.1440507663 +0.7336502408 0.1434661473 +0.7346517328 0.1428817277 +0.7356528242 0.1422979397 +0.7366542565 0.1417143503 +0.7376554901 0.1411312731 +0.7386560386 0.1405489900 +0.7396569262 0.1399669040 +0.7406577527 0.1393852472 +0.7416589175 0.1388037869 +0.7426598805 0.1382228359 +0.7436611811 0.1376420806 +0.7446621188 0.1370619264 +0.7456633931 0.1364819671 +0.7466643144 0.1359026013 +0.7476655714 0.1353234296 +0.7486667367 0.1347446986 +0.7496678093 0.1341664078 +0.7506692164 0.1335883101 +0.7516700907 0.1330109051 +0.7526712983 0.1324336923 +0.7536726537 0.1318567781 +0.7546736671 0.1312804439 +0.7556750126 0.1307043008 +0.7566759716 0.1301287615 +0.7576772617 0.1295534125 +0.7586783077 0.1289785837 +0.7596796842 0.1284039444 +0.7606807290 0.1278298738 +0.7616821035 0.1272559920 +0.7626835892 0.1266824236 +0.7636844218 0.1261096054 +0.7646855826 0.1255369747 +0.7656866915 0.1249647484 +0.7666881279 0.1243927091 +0.7676890053 0.1238213622 +0.7686898894 0.1232503839 +0.7696910995 0.1226795913 +0.7706921334 0.1221092702 +0.7716934926 0.1215391343 +0.7726940395 0.1209698301 +0.7736949106 0.1204007102 +0.7746957206 0.1198319930 +0.7756964987 0.1192636611 +0.7766975999 0.1186955124 +0.7776986208 0.1181277753 +0.7786999640 0.1175602208 +0.7797013908 0.1169929837 +0.7807028390 0.1164260988 +0.7817032335 0.1158601731 +0.7827038182 0.1152945020 +0.7837047229 0.1147290116 +0.7847058172 0.1141637752 +0.7857067437 0.1135989939 +0.7867076609 0.1130345774 +0.7877088967 0.1124703404 +0.7887101225 0.1119064675 +0.7897110968 0.1113430939 +0.7907121409 0.1107800380 +0.7917135020 0.1102171602 +0.7927145190 0.1096548315 +0.7937158522 0.1090926803 +0.7947168235 0.1085310866 +0.7957181102 0.1079696697 +0.7967194474 0.1074085776 +0.7977202934 0.1068481129 +0.7987214536 0.1062878240 +0.7997222983 0.1057280624 +0.8007234564 0.1051684760 +0.8017248350 0.1046091161 +0.8027255034 0.1040505018 +0.8037264838 0.1034920615 +0.8047276559 0.1029338620 +0.8057284549 0.1023762175 +0.8067295650 0.1018187460 +0.8077305471 0.1012616915 +0.8087314389 0.1007050323 +0.8097326406 0.1001485453 +0.8107340433 0.0995922905 +0.8117355382 0.0990363280 +0.8127364320 0.0984810418 +0.8137376341 0.0979259265 +0.8147389434 0.0973710932 +0.8157398773 0.0968168085 +0.8167411185 0.0962626938 +0.8177419646 0.0957091372 +0.8187431170 0.0951557499 +0.8197441544 0.0946027643 +0.8207451668 0.0940501301 +0.8217464845 0.0934976644 +0.8227473602 0.0929457788 +0.8237482445 0.0923942241 +0.8247494330 0.0918428368 +0.8257506293 0.0912917799 +0.8267520451 0.0907409362 +0.8277530787 0.0901906361 +0.8287544152 0.0896405022 +0.8297557396 0.0890907073 +0.8307573662 0.0885410781 +0.8317586416 0.0879919729 +0.8327598709 0.0874432232 +0.8337614014 0.0868946384 +0.8347625903 0.0863465699 +0.8357636924 0.0857988775 +0.8367650944 0.0852513490 +0.8377664088 0.0847041960 +0.8387670887 0.0841577163 +0.8397680672 0.0836113994 +0.8407691192 0.0830653681 +0.8417702211 0.0825196345 +0.8427716209 0.0819740630 +0.8437722831 0.0814292171 +0.8447732422 0.0808845327 +0.8457744425 0.0803400397 +0.8467755021 0.0797959454 +0.8477768577 0.0792520119 +0.8487777194 0.0787086675 +0.8497788763 0.0781654832 +0.8507800883 0.0776225890 +0.8517815949 0.0770798545 +0.8527822920 0.0765378773 +0.8537832828 0.0759960591 +0.8547841926 0.0754546022 +0.8557852306 0.0749133929 +0.8567865615 0.0743723419 +0.8577873019 0.0738319257 +0.8587883345 0.0732916670 +0.8597894874 0.0727516582 +0.8607903014 0.0722121463 +0.8617914065 0.0716727913 +0.8627922701 0.0711338793 +0.8637934242 0.0705951236 +0.8647943790 0.0700567872 +0.8657955010 0.0695186724 +0.8667969127 0.0689807130 +0.8677978471 0.0684433205 +0.8687990703 0.0679060829 +0.8697998649 0.0673693845 +0.8708007436 0.0668329498 +0.8718016519 0.0662968074 +0.8728028478 0.0657608188 +0.8738040727 0.0652251219 +0.8748049300 0.0646899284 +0.8758060737 0.0641548880 +0.8768071610 0.0636201834 +0.8778082382 0.0630857893 +0.8788096010 0.0625515475 +0.8798105006 0.0620178570 +0.8808113618 0.0614844904 +0.8818125074 0.0609512753 +0.8828136140 0.0604183835 +0.8838146098 0.0598858528 +0.8848155274 0.0593536651 +0.8858167283 0.0588216278 +0.8868175377 0.0582900990 +0.8878186297 0.0577587200 +0.8888199055 0.0572275431 +0.8898209001 0.0566968143 +0.8908221764 0.0561662348 +0.8918229674 0.0556362103 +0.8928240393 0.0551063344 +0.8938248923 0.0545768713 +0.8948256992 0.0540477289 +0.8958267862 0.0535187344 +0.8968278265 0.0529900600 +0.8978288316 0.0524616992 +0.8988301158 0.0519334856 +0.8998311310 0.0514057079 +0.9008324247 0.0508780770 +0.9018335024 0.0503508530 +0.9028343789 0.0498240274 +0.9038355329 0.0492973478 +0.9048368316 0.0487708837 +0.9058381419 0.0482447048 +0.9068391628 0.0477189686 +0.9078400350 0.0471936004 +0.9088411833 0.0466683771 +0.9098423648 0.0461434255 +0.9108431288 0.0456189813 +0.9118440801 0.0450947272 +0.9128453063 0.0445706168 +0.9138461746 0.0440469810 +0.9148473171 0.0435234885 +0.9158485399 0.0430002404 +0.9168497027 0.0424773096 +0.9178508027 0.0419546970 +0.9188520076 0.0414323145 +0.9198534854 0.0409100744 +0.9208542194 0.0403885060 +0.9218552254 0.0398670793 +0.9228562900 0.0393459051 +0.9238575408 0.0388249167 +0.9248584690 0.0383043782 +0.9258596681 0.0377839806 +0.9268606115 0.0372639970 +0.9278618253 0.0367441538 +0.9288627097 0.0362247618 +0.9298638640 0.0357055097 +0.9308651963 0.0351864448 +0.9318666150 0.0346676142 +0.9328674020 0.0341493894 +0.9338684575 0.0336313035 +0.9348693830 0.0331135625 +0.9358705765 0.0325959600 +0.9368714974 0.0320787752 +0.9378726857 0.0315617285 +0.9388740816 0.0310448506 +0.9398748957 0.0305285483 +0.9408758181 0.0300124650 +0.9418770069 0.0294965189 +0.9428783036 0.0289807913 +0.9438793675 0.0284654574 +0.9448803501 0.0279504385 +0.9458814245 0.0274356451 +0.9468827639 0.0269209878 +0.9478839160 0.0264066989 +0.9488853326 0.0258925457 +0.9498863156 0.0253788861 +0.9508875625 0.0248653618 +0.9518884093 0.0243523129 +0.9528895194 0.0238393988 +0.9538907769 0.0233266785 +0.9548920663 0.0228142110 +0.9558929996 0.0223021941 +0.9568941951 0.0217903113 +0.9578951777 0.0212788049 +0.9588964219 0.0207674322 +0.9598976316 0.0202563439 +0.9608986212 0.0197456345 +0.9618998716 0.0192350579 +0.9629009653 0.0187248269 +0.9639023193 0.0182147285 +0.9649038050 0.0177048280 +0.9659050567 0.0171953110 +0.9669065681 0.0166859260 +0.9679076734 0.0161770112 +0.9689090376 0.0156682279 +0.9699104799 0.0151596678 +0.9709121808 0.0146512390 +0.9719141140 0.0141429546 +0.9729154699 0.0136352247 +0.9739169262 0.0131277052 +0.9749186401 0.0126203161 +0.9759204079 0.0121131604 +0.9769224329 0.0116061347 +0.9779241666 0.0110995163 +0.9789260691 0.0105930720 +0.9799281993 0.0100867718 +0.9809305859 0.0095806010 +0.9819330847 0.0090746321 +0.9829355173 0.0085689549 +0.9839382056 0.0080634065 +0.9849410844 0.0075580197 +0.9859437889 0.0070529778 +0.9869466316 0.0065481231 +0.9879497292 0.0060433967 +0.9889528489 0.0055389153 +0.9899562232 0.0050345618 +0.9909597362 0.0045303942 +0.9919633539 0.0040264291 +0.9929672257 0.0035225915 +0.9939712250 0.0030189445 +0.9949754780 0.0025154247 +0.9959799285 0.0020120600 +0.9969846132 0.0015088317 +0.9979894950 0.0010057583 +0.9989946210 0.0005028159 +1.0000000000 0.0000000000 diff --git a/src/problems/ZDT/ZDT6.txt b/src/problems/ZDT/ZDT6.txt new file mode 100644 index 0000000..71cf12c --- /dev/null +++ b/src/problems/ZDT/ZDT6.txt @@ -0,0 +1,1000 @@ +0.2807753191 0.9211652202 +0.2814990682 0.9207582746 +0.2822222294 0.9203506133 +0.2829444640 0.9199424303 +0.2836657932 0.9195337178 +0.2843873868 0.9191238143 +0.2851090310 0.9187128404 +0.2858297620 0.9183013472 +0.2865498629 0.9178891761 +0.2872696154 0.9174761681 +0.2879897830 0.9170618849 +0.2887090502 0.9166470843 +0.2894296667 0.9162304680 +0.2901500283 0.9158129611 +0.2908694956 0.9153949365 +0.2915887137 0.9149760220 +0.2923081531 0.9145559436 +0.2930283871 0.9141343644 +0.2937477359 0.9137122677 +0.2944686574 0.9132882098 +0.2951886965 0.9128636335 +0.2959092187 0.9124377343 +0.2966288636 0.9120113173 +0.2973486046 0.9115838073 +0.2980687980 0.9111549917 +0.2987889944 0.9107251368 +0.2995087588 0.9102945034 +0.3002276584 0.9098633531 +0.3009485794 0.9094299526 +0.3016692216 0.9089956808 +0.3023890030 0.9085608909 +0.3031093708 0.9081247093 +0.3038288826 0.9076880101 +0.3045484000 0.9072502720 +0.3052688710 0.9068109164 +0.3059884919 0.9063710428 +0.3067086687 0.9059297926 +0.3074280000 0.9054880248 +0.3081481037 0.9050447462 +0.3088673660 0.9046009502 +0.3095875091 0.9041555742 +0.3103068146 0.9037096808 +0.3110269959 0.9032622078 +0.3117467791 0.9028139457 +0.3124657314 0.9023651667 +0.3131855124 0.9019148348 +0.3139057114 0.9014632044 +0.3146260227 0.9010104659 +0.3153455094 0.9005572097 +0.3160651118 0.9001028451 +0.3167855450 0.8996469184 +0.3175051591 0.8991904740 +0.3182256463 0.8987324380 +0.3189453180 0.8982738841 +0.3196653185 0.8978140842 +0.3203854336 0.8973531739 +0.3211047395 0.8968917463 +0.3218255490 0.8964283160 +0.3225455513 0.8959643673 +0.3232654163 0.8954994706 +0.3239847460 0.8950338844 +0.3247054027 0.8945664015 +0.3254252596 0.8940984004 +0.3261461526 0.8936286872 +0.3268662488 0.8931584554 +0.3275857368 0.8926875850 +0.3283053726 0.8922155824 +0.3290261297 0.8917418060 +0.3297460975 0.8912675112 +0.3304663686 0.8907919792 +0.3311867047 0.8903153667 +0.3319062574 0.8898382363 +0.3326254653 0.8893602998 +0.3333458929 0.8888805157 +0.3340655420 0.8884002136 +0.3347857558 0.8879184977 +0.3355051949 0.8874362642 +0.3362254101 0.8869524736 +0.3369448539 0.8864681655 +0.3376647811 0.8859824956 +0.3383839408 0.8854963086 +0.3391042500 0.8850083076 +0.3398242021 0.8845195116 +0.3405445374 0.8840294180 +0.3412641108 0.8835388067 +0.3419831543 0.8830475222 +0.3427033174 0.8825544363 +0.3434237715 0.8820601132 +0.3441437123 0.8815651053 +0.3448629001 0.8810695801 +0.3455825476 0.8805727028 +0.3463021370 0.8800748299 +0.3470224033 0.8795754516 +0.3477430093 0.8790747995 +0.3484628686 0.8785736292 +0.3491830692 0.8780711842 +0.3499030062 0.8775678863 +0.3506225462 0.8770638301 +0.3513413480 0.8765592572 +0.3520618447 0.8760524575 +0.3527822893 0.8755446564 +0.3535019983 0.8750363372 +0.3542229553 0.8745260979 +0.3549431787 0.8740153399 +0.3556629548 0.8735038626 +0.3563825690 0.8729914645 +0.3571025403 0.8724777757 +0.3578231915 0.8719625637 +0.3585431169 0.8714468333 +0.3592634354 0.8709297840 +0.3599830318 0.8704122168 +0.3607027073 0.8698935570 +0.3614216648 0.8693743802 +0.3621420657 0.8688531243 +0.3628623050 0.8683309476 +0.3635818296 0.8678082532 +0.3643011961 0.8672846385 +0.3650204511 0.8667600703 +0.3657405850 0.8662338245 +0.3664600099 0.8657070611 +0.3671795890 0.8651791494 +0.3679004541 0.8646492559 +0.3686206718 0.8641188003 +0.3693408003 0.8635873732 +0.3700602269 0.8630554285 +0.3707799355 0.8625222394 +0.3714989456 0.8619885334 +0.3722182638 0.8614535641 +0.3729368870 0.8609180783 +0.3736579327 0.8603797493 +0.3743782827 0.8598409014 +0.3750981475 0.8593013797 +0.3758179965 0.8587608335 +0.3765371560 0.8582197702 +0.3772581153 0.8576763144 +0.3779783857 0.8571323399 +0.3786980305 0.8565878017 +0.3794175516 0.8560423215 +0.3801382362 0.8554949214 +0.3808582376 0.8549470028 +0.3815790568 0.8543974234 +0.3822997011 0.8538469385 +0.3830196662 0.8532959353 +0.3837394596 0.8527440272 +0.3844598890 0.8521905938 +0.3851796433 0.8516366424 +0.3858993552 0.8510816877 +0.3866183959 0.8505262160 +0.3873376386 0.8499695537 +0.3880574538 0.8494114126 +0.3887771485 0.8488523288 +0.3894961770 0.8482927281 +0.3902162679 0.8477312643 +0.3909361552 0.8471689225 +0.3916553797 0.8466060635 +0.3923760036 0.8460410718 +0.3930959657 0.8454755618 +0.3938168295 0.8449083048 +0.3945370336 0.8443405291 +0.3952574482 0.8437715497 +0.3959773500 0.8432019383 +0.3966973406 0.8426312199 +0.3974166779 0.8420599841 +0.3981367187 0.8414871532 +0.3988565577 0.8409134464 +0.3995757472 0.8403392223 +0.4002952696 0.8397636971 +0.4010157076 0.8391864023 +0.4017360769 0.8386081245 +0.4024558003 0.8380293288 +0.4031754576 0.8374495504 +0.4038957197 0.8368682476 +0.4046156350 0.8362861879 +0.4053351080 0.8357034502 +0.4060539424 0.8351201959 +0.4067746522 0.8345343823 +0.4074947236 0.8339480502 +0.4082149745 0.8333605346 +0.4089345900 0.8327725011 +0.4096543402 0.8321833216 +0.4103750895 0.8315922859 +0.4110955980 0.8310004093 +0.4118154751 0.8304080145 +0.4125357176 0.8298142817 +0.4132556326 0.8292197822 +0.4139759287 0.8286239305 +0.4146955982 0.8280275609 +0.4154156792 0.8274298134 +0.4161359398 0.8268308796 +0.4168555769 0.8262314280 +0.4175758225 0.8256304325 +0.4182959856 0.8250284684 +0.4190155288 0.8244259866 +0.4197356963 0.8238219453 +0.4204556855 0.8232170165 +0.4211750583 0.8226115703 +0.4218951128 0.8220045138 +0.4226149810 0.8213965778 +0.4233350181 0.8207874625 +0.4240544428 0.8201778295 +0.4247740379 0.8195670167 +0.4254945300 0.8189544050 +0.4262144120 0.8183412750 +0.4269344998 0.8177269329 +0.4276543475 0.8171117591 +0.4283735893 0.8164960680 +0.4290925939 0.8158795459 +0.4298128945 0.8152608757 +0.4305332794 0.8146410954 +0.4312530616 0.8140207969 +0.4319729298 0.8133993879 +0.4326929082 0.8127768472 +0.4334127928 0.8121533510 +0.4341323320 0.8115291183 +0.4348523102 0.8109034683 +0.4355716924 0.8102773008 +0.4362915142 0.8096497146 +0.4370114625 0.8090209816 +0.4377314683 0.8083911616 +0.4384514632 0.8077603144 +0.4391708669 0.8071289497 +0.4398914795 0.8064954862 +0.4406115019 0.8058615044 +0.4413321519 0.8052259317 +0.4420523419 0.8045897270 +0.4427723130 0.8039526788 +0.4434916987 0.8033151132 +0.4442122201 0.8026755036 +0.4449321570 0.8020353756 +0.4456517440 0.8013945231 +0.4463719076 0.8007521201 +0.4470920801 0.8001086719 +0.4478119674 0.7994644419 +0.4485322737 0.7988187994 +0.4492525001 0.7981721911 +0.4499721492 0.7975250649 +0.4506924144 0.7968763476 +0.4514128145 0.7962264709 +0.4521326398 0.7955760760 +0.4528531164 0.7949240550 +0.4535730198 0.7942715157 +0.4542928659 0.7936179920 +0.4550123930 0.7929637222 +0.4557317919 0.7923085339 +0.4564515473 0.7916519850 +0.4571716388 0.7909940927 +0.4578911632 0.7903356827 +0.4586102372 0.7896766503 +0.4593303281 0.7890156497 +0.4600498545 0.7883541313 +0.4607701063 0.7876909092 +0.4614897951 0.7870271691 +0.4622097775 0.7863621216 +0.4629295537 0.7856962283 +0.4636496779 0.7850289762 +0.4643692428 0.7843612063 +0.4650895898 0.7836916734 +0.4658093790 0.7830216224 +0.4665294545 0.7823502681 +0.4672489743 0.7816783961 +0.4679691586 0.7810048666 +0.4686894119 0.7803302351 +0.4694091118 0.7796550857 +0.4701288822 0.7789788341 +0.4708481705 0.7783020004 +0.4715686236 0.7776230333 +0.4722890871 0.7769430182 +0.4730094404 0.7762620693 +0.4737292452 0.7755806023 +0.4744495231 0.7748976500 +0.4751700634 0.7742134108 +0.4758900574 0.7735286532 +0.4766099258 0.7728429787 +0.4773299031 0.7721561636 +0.4780493374 0.7714688310 +0.4787688821 0.7707803576 +0.4794891935 0.7700901134 +0.4802089638 0.7693993511 +0.4809292340 0.7687070719 +0.4816489649 0.7680142746 +0.4823688992 0.7673202451 +0.4830890552 0.7666249647 +0.4838086745 0.7659291665 +0.4845292173 0.7652314376 +0.4852495068 0.7645329161 +0.4859692618 0.7638338766 +0.4866887396 0.7631340707 +0.4874087623 0.7624326984 +0.4881282532 0.7617308085 +0.4888477781 0.7610278498 +0.4895672547 0.7603239032 +0.4902871640 0.7596184968 +0.4910074998 0.7589116351 +0.4917273072 0.7582042553 +0.4924475871 0.7574953740 +0.4931673402 0.7567859746 +0.4938872506 0.7560753837 +0.4946073802 0.7553635394 +0.4953278463 0.7546503247 +0.4960477883 0.7539365917 +0.4967681530 0.7532214022 +0.4974879954 0.7525056944 +0.4982080396 0.7517887492 +0.4989275636 0.7510712863 +0.4996469268 0.7503529485 +0.5003672351 0.7496326300 +0.5010872988 0.7489115190 +0.5018072564 0.7481894774 +0.5025266975 0.7474669183 +0.5032460344 0.7467434288 +0.5039665115 0.7460177553 +0.5046869068 0.7452911261 +0.5054067880 0.7445639786 +0.5061264450 0.7438360217 +0.5068461670 0.7431069630 +0.5075665046 0.7423762434 +0.5082863309 0.7416450058 +0.5090058345 0.7409130605 +0.5097259023 0.7401795045 +0.5104454615 0.7394454308 +0.5111652901 0.7387100462 +0.5118846119 0.7379741441 +0.5126049237 0.7372361921 +0.5133252710 0.7364971661 +0.5140453835 0.7357573437 +0.5147656997 0.7350162744 +0.5154855121 0.7342746869 +0.5162058432 0.7335315274 +0.5169256718 0.7327878498 +0.5176453130 0.7320433299 +0.5183651464 0.7312975750 +0.5190844799 0.7305513027 +0.5198049085 0.7298028571 +0.5205249908 0.7290537339 +0.5212452963 0.7283033411 +0.5219651041 0.7275524301 +0.5226851358 0.7268002488 +0.5234050484 0.7260471553 +0.5241244659 0.7252935443 +0.5248444325 0.7245383217 +0.5255645614 0.7237818917 +0.5262841970 0.7230249439 +0.5270034717 0.7222673409 +0.5277238579 0.7215075298 +0.5284437525 0.7207472005 +0.5291634061 0.7199860896 +0.5298839437 0.7192230062 +0.5306039914 0.7184594043 +0.5313237776 0.7176950433 +0.5320435301 0.7169296821 +0.5327632502 0.7161633192 +0.5334834468 0.7153954120 +0.5342036586 0.7146264511 +0.5349233850 0.7138569722 +0.5356433433 0.7130862088 +0.5363628178 0.7123149277 +0.5370834134 0.7115414070 +0.5378035746 0.7107673151 +0.5385232536 0.7099927053 +0.5392435519 0.7092163917 +0.5399633692 0.7084395599 +0.5406841037 0.7076607000 +0.5414044614 0.7068812091 +0.5421243399 0.7061012001 +0.5428439770 0.7053204166 +0.5435631904 0.7045390581 +0.5442835200 0.7037554498 +0.5450033730 0.7029713234 +0.5457234746 0.7021858893 +0.5464435527 0.7013994437 +0.5471631564 0.7006124803 +0.5478830807 0.6998241299 +0.5486025320 0.6990352619 +0.5493225900 0.6982446921 +0.5500421761 0.6974536045 +0.5507624228 0.6966607536 +0.5514821986 0.6958673847 +0.5522019002 0.6950730614 +0.5529222531 0.6942769820 +0.5536421368 0.6934803843 +0.5543624929 0.6926822264 +0.5550823810 0.6918835503 +0.5558026852 0.6910833751 +0.5565225227 0.6902826817 +0.5572423527 0.6894809603 +0.5579623525 0.6886780132 +0.5586818878 0.6878745483 +0.5594016781 0.6870697626 +0.5601210053 0.6862644594 +0.5608410932 0.6854572681 +0.5615612694 0.6846489408 +0.5622809837 0.6838400954 +0.5630012083 0.6830296395 +0.5637214336 0.6822181453 +0.5644411988 0.6814061331 +0.5651609659 0.6805930827 +0.5658815721 0.6797780463 +0.5666017196 0.6789624914 +0.5673214448 0.6781463783 +0.5680414563 0.6773289040 +0.5687610114 0.6765109119 +0.5694809629 0.6756914329 +0.5702009041 0.6748709290 +0.5709203907 0.6740499074 +0.5716398683 0.6732278610 +0.5723600084 0.6724040208 +0.5730802102 0.6715790726 +0.5737999595 0.6707536064 +0.5745202005 0.6699265392 +0.5752404531 0.6690984211 +0.5759602548 0.6682697849 +0.5766805417 0.6674395528 +0.5774003789 0.6666088025 +0.5781207176 0.6657764359 +0.5788406075 0.6649435511 +0.5795606178 0.6641094903 +0.5802801809 0.6632749117 +0.5809999913 0.6624390101 +0.5817195652 0.6616023475 +0.5824386939 0.6607651678 +0.5831592491 0.6599252902 +0.5838793591 0.6590848940 +0.5845996542 0.6582432444 +0.5853195055 0.6574010765 +0.5860394054 0.6565578153 +0.5867588632 0.6557140364 +0.5874792607 0.6548681182 +0.5881992165 0.6540216817 +0.5889192043 0.6531741708 +0.5896388234 0.6523260580 +0.5903589673 0.6514762897 +0.5910786721 0.6506260034 +0.5917980249 0.6497750977 +0.5925178026 0.6489226536 +0.5932383267 0.6480682877 +0.5939584133 0.6472134033 +0.5946785809 0.6463573854 +0.5953983126 0.6455008494 +0.5961184062 0.6446428458 +0.5968386041 0.6437836807 +0.5975583674 0.6429239975 +0.5982786461 0.6420626616 +0.5989984913 0.6412008075 +0.5997185778 0.6403376274 +0.6004386868 0.6394733834 +0.6011583640 0.6386086214 +0.6018783330 0.6377424723 +0.6025978714 0.6368758054 +0.6033178491 0.6360075730 +0.6040373972 0.6351388228 +0.6047571169 0.6342688296 +0.6054765079 0.6333981983 +0.6061972873 0.6325248489 +0.6069176382 0.6316509805 +0.6076376926 0.6307764345 +0.6083577064 0.6299009010 +0.6090776041 0.6290244722 +0.6097977013 0.6281467635 +0.6105173733 0.6272685369 +0.6112372454 0.6263890298 +0.6119573665 0.6255081816 +0.6126774577 0.6246263328 +0.6133971258 0.6237439661 +0.6141169374 0.6228603872 +0.6148363272 0.6219762908 +0.6155566476 0.6210900136 +0.6162765465 0.6202032182 +0.6169966257 0.6193151639 +0.6177165894 0.6184262152 +0.6184361335 0.6175367488 +0.6191562255 0.6166455684 +0.6198758989 0.6157538700 +0.6205958158 0.6148608334 +0.6213162428 0.6139661264 +0.6220366679 0.6130703838 +0.6227569013 0.6121738418 +0.6234767183 0.6112767817 +0.6241969342 0.6103781873 +0.6249167347 0.6094790748 +0.6256361485 0.6085794096 +0.6263561775 0.6076779389 +0.6270758762 0.6067758455 +0.6277953706 0.6058729727 +0.6285151297 0.6049687318 +0.6292344767 0.6040639734 +0.6299540887 0.6031578461 +0.6306743052 0.6022499208 +0.6313941104 0.6013414773 +0.6321144403 0.6004313344 +0.6328343597 0.5995206732 +0.6335545093 0.5986086837 +0.6342745561 0.5976957875 +0.6349950220 0.5967813220 +0.6357150792 0.5958663381 +0.6364353898 0.5949499947 +0.6371555351 0.5940328241 +0.6378752735 0.5931151355 +0.6385950657 0.5921963421 +0.6393144522 0.5912770312 +0.6400336516 0.5903569248 +0.6407539188 0.5894344156 +0.6414738017 0.5885113617 +0.6421940438 0.5875868101 +0.6429138820 0.5866617404 +0.6436340793 0.5857351719 +0.6443539131 0.5848080347 +0.6450739684 0.5838795752 +0.6457940691 0.5829500203 +0.6465137683 0.5820199474 +0.6472337655 0.5810884528 +0.6479533622 0.5801564404 +0.6486738154 0.5792222813 +0.6493939433 0.5782875063 +0.6501136720 0.5773522134 +0.6508332792 0.5764160427 +0.6515537377 0.5754777269 +0.6522737979 0.5745388926 +0.6529938173 0.5735990745 +0.6537134398 0.5726587387 +0.6544335756 0.5717166951 +0.6551533153 0.5707741335 +0.6558734667 0.5698299956 +0.6565932228 0.5688853397 +0.6573130176 0.5679395969 +0.6580329040 0.5669926972 +0.6587529885 0.5660445002 +0.6594726793 0.5650957852 +0.6601926480 0.5641456675 +0.6609122242 0.5631950319 +0.6616318052 0.5622433544 +0.6623517813 0.5612901179 +0.6630717484 0.5603358565 +0.6637921402 0.5593799947 +0.6645121410 0.5584236144 +0.6652319562 0.5574664445 +0.6659518938 0.5565080752 +0.6666714422 0.5555491882 +0.6673913968 0.5545887235 +0.6681109630 0.5536277411 +0.6688313419 0.5526646361 +0.6695513328 0.5517010128 +0.6702709451 0.5507368602 +0.6709910465 0.5497710155 +0.6717107616 0.5488046528 +0.6724308805 0.5478367110 +0.6731513504 0.5468672595 +0.6738716051 0.5458970599 +0.6745914748 0.5449263421 +0.6753111307 0.5439548768 +0.6760311021 0.5429819489 +0.6767506902 0.5420085033 +0.6774711204 0.5410328810 +0.6781913842 0.5400564464 +0.6789112655 0.5390794936 +0.6796312006 0.5381014312 +0.6803507544 0.5371228510 +0.6810708573 0.5361424873 +0.6817905796 0.5351616056 +0.6825101891 0.5341798417 +0.6832304223 0.5331961901 +0.6839502757 0.5322120203 +0.6846705176 0.5312262824 +0.6853903806 0.5302400262 +0.6861106120 0.5292522281 +0.6868304654 0.5282639117 +0.6875505019 0.5272743074 +0.6882706788 0.5262834728 +0.6889904789 0.5252921200 +0.6897104199 0.5242995367 +0.6904301616 0.5233061919 +0.6911498808 0.5223118422 +0.6918700377 0.5213158509 +0.6925899260 0.5203191944 +0.6933094401 0.5193220203 +0.6940291111 0.5183235929 +0.6947492452 0.5173234862 +0.6954690061 0.5163228615 +0.6961892740 0.5153204947 +0.6969091694 0.5143176096 +0.6976294392 0.5133131655 +0.6983493609 0.5123081701 +0.6990695134 0.5113018154 +0.6997892950 0.5102949426 +0.7005093077 0.5092867098 +0.7012294810 0.5082772150 +0.7019494236 0.5072670067 +0.7026689971 0.5062562806 +0.7033889333 0.5052440085 +0.7041088861 0.5042306765 +0.7048284709 0.5032168266 +0.7055483281 0.5022015568 +0.7062680573 0.5011854312 +0.7069874199 0.5001687882 +0.7077076588 0.4991498697 +0.7084275312 0.4981304331 +0.7091478574 0.4971093164 +0.7098682030 0.4960871344 +0.7105881831 0.4950644341 +0.7113083272 0.4940404636 +0.7120281068 0.4930159751 +0.7127478884 0.4919904476 +0.7134678376 0.4909636447 +0.7141874236 0.4899363239 +0.7149074533 0.4889073332 +0.7156276836 0.4878770185 +0.7163475514 0.4868461856 +0.7170676867 0.4858139326 +0.7177876267 0.4847809230 +0.7185072056 0.4837473955 +0.7192273635 0.4827119996 +0.7199473773 0.4816757739 +0.7206674670 0.4806384020 +0.7213871970 0.4796005120 +0.7221072699 0.4785610907 +0.7228269838 0.4775211515 +0.7235469640 0.4764797909 +0.7242665860 0.4754379124 +0.7249868992 0.4743939960 +0.7257068545 0.4733495613 +0.7264266556 0.4723043140 +0.7271468324 0.4712574841 +0.7278666526 0.4702101360 +0.7285864734 0.4691617507 +0.7293059386 0.4681128479 +0.7300261037 0.4670618879 +0.7307463976 0.4660097023 +0.7314663366 0.4649569985 +0.7321865760 0.4639028180 +0.7329064611 0.4628481192 +0.7336260877 0.4617927634 +0.7343462725 0.4607355520 +0.7350661042 0.4596778225 +0.7357860871 0.4586188341 +0.7365063252 0.4575584329 +0.7372263975 0.4564972388 +0.7379462953 0.4554352652 +0.7386658419 0.4543727740 +0.7393856459 0.4533088666 +0.7401050995 0.4522444417 +0.7408252424 0.4511779602 +0.7415452445 0.4501106504 +0.7422652220 0.4490423402 +0.7429848503 0.4479735122 +0.7437049028 0.4469030176 +0.7444246067 0.4458320049 +0.7451444102 0.4447598079 +0.7458643206 0.4436864152 +0.7465843437 0.4426118177 +0.7473041778 0.4415364658 +0.7480236652 0.4404605962 +0.7487438310 0.4393826755 +0.7494641180 0.4383035359 +0.7501840588 0.4372238780 +0.7509045014 0.4361424297 +0.7516245985 0.4350604629 +0.7523448935 0.4339771613 +0.7530648436 0.4328933413 +0.7537851005 0.4318080223 +0.7545050132 0.4307221850 +0.7552250702 0.4296350934 +0.7559452401 0.4285467939 +0.7566655525 0.4274572417 +0.7573855220 0.4263671711 +0.7581054373 0.4252761459 +0.7588250108 0.4241846029 +0.7595446221 0.4230919671 +0.7602645552 0.4219978060 +0.7609844179 0.4209027157 +0.7617045887 0.4198061195 +0.7624244191 0.4187090052 +0.7631440889 0.4176110996 +0.7638639016 0.4165119398 +0.7645836183 0.4154118906 +0.7653029962 0.4143113240 +0.7660233826 0.4132081772 +0.7667434303 0.4121045120 +0.7674632302 0.4110001902 +0.7681828732 0.4098950734 +0.7689032031 0.4087878643 +0.7696231956 0.4076801368 +0.7703434003 0.4065710457 +0.7710632683 0.4054614363 +0.7717833008 0.4043505365 +0.7725029975 0.4032391188 +0.7732231120 0.4021260191 +0.7739428912 0.4010124012 +0.7746627350 0.3998976470 +0.7753828112 0.3987814961 +0.7761029323 0.3976642385 +0.7768227193 0.3965464628 +0.7775425517 0.3954275802 +0.7782623628 0.3943076947 +0.7789822031 0.3931867273 +0.7797017108 0.3920652423 +0.7804218564 0.3909417260 +0.7811419884 0.3898171940 +0.7818617884 0.3886921438 +0.7825819105 0.3875655533 +0.7833020847 0.3864378441 +0.7840219278 0.3853096167 +0.7847421200 0.3841798050 +0.7854619818 0.3830494751 +0.7861818099 0.3819181617 +0.7869019836 0.3807852681 +0.7876221980 0.3796512732 +0.7883420831 0.3785167599 +0.7890617585 0.3773815412 +0.7897813435 0.3762454295 +0.7905014234 0.3751074995 +0.7912211754 0.3739690516 +0.7919411977 0.3728291395 +0.7926610027 0.3716885347 +0.7933807013 0.3705470629 +0.7941004800 0.3694044276 +0.7948208839 0.3682597625 +0.7955409613 0.3671145790 +0.7962610153 0.3659683955 +0.7969811363 0.3648210684 +0.7977009319 0.3636732232 +0.7984207949 0.3625242342 +0.7991410558 0.3613735729 +0.7998611314 0.3602221705 +0.8005813064 0.3590695719 +0.8013011574 0.3579164551 +0.8020211083 0.3567621419 +0.8027408959 0.3556070540 +0.8034609458 0.3544505085 +0.8041806731 0.3532934450 +0.8049006140 0.3521350017 +0.8056203791 0.3509758048 +0.8063403053 0.3498153120 +0.8070599102 0.3486543014 +0.8077796764 0.3474919943 +0.8084999692 0.3463277999 +0.8092199410 0.3451630870 +0.8099397717 0.3439975663 +0.8106599806 0.3428303958 +0.8113798696 0.3416627071 +0.8120998833 0.3404937796 +0.8128195778 0.3393243340 +0.8135391027 0.3381541285 +0.8142591218 0.3369820826 +0.8149790796 0.3358090998 +0.8156987194 0.3346355991 +0.8164183952 0.3334610039 +0.8171385539 0.3322845838 +0.8178583951 0.3311076455 +0.8185785261 0.3299291966 +0.8192986947 0.3287496488 +0.8200185468 0.3275695829 +0.8207381323 0.3263889181 +0.8214584471 0.3252060197 +0.8221784461 0.3240226028 +0.8228985981 0.3228378973 +0.8236186938 0.3216522473 +0.8243384746 0.3204660792 +0.8250581998 0.3192789669 +0.8257778827 0.3180908884 +0.8264981981 0.3169007285 +0.8272181996 0.3157100502 +0.8279382728 0.3145182164 +0.8286580329 0.3133258645 +0.8293777385 0.3121325668 +0.8300976355 0.3109379155 +0.8308172204 0.3097427464 +0.8315377029 0.3085450486 +0.8322578733 0.3073468323 +0.8329779310 0.3061477664 +0.8336979931 0.3049476563 +0.8344177441 0.3037470283 +0.8351375001 0.3025453560 +0.8358576647 0.3013419643 +0.8365775191 0.3001380545 +0.8372976172 0.2989327002 +0.8380175773 0.2977265401 +0.8387372281 0.2965198622 +0.8394573693 0.2953113251 +0.8401772016 0.2941022699 +0.8408974576 0.2928914658 +0.8416174052 0.2916801433 +0.8423371703 0.2904680916 +0.8430568787 0.2892550993 +0.8437770792 0.2880402406 +0.8444970735 0.2868246928 +0.8452167610 0.2856086270 +0.8459370934 0.2843904340 +0.8466571628 0.2831716486 +0.8473769261 0.2819523452 +0.8480968712 0.2807316970 +0.8488165108 0.2795105310 +0.8495366200 0.2782875313 +0.8502564239 0.2770640135 +0.8509765722 0.2758388736 +0.8516966670 0.2746127874 +0.8524164574 0.2733861832 +0.8531364033 0.2721582774 +0.8538560454 0.2709298537 +0.8545756644 0.2697004339 +0.8552959489 0.2684688398 +0.8560159302 0.2672367273 +0.8567357685 0.2660038229 +0.8574553685 0.2647702911 +0.8581754563 0.2635348862 +0.8588952420 0.2622989633 +0.8596154269 0.2610613179 +0.8603353101 0.2598231542 +0.8610553354 0.2585837094 +0.8617754763 0.2573430284 +0.8624955528 0.2561014215 +0.8632153286 0.2548592964 +0.8639350406 0.2536162455 +0.8646553356 0.2523711506 +0.8653753306 0.2511255372 +0.8660953514 0.2498788422 +0.8668150730 0.2486316292 +0.8675352658 0.2473825626 +0.8682554825 0.2461324171 +0.8689754005 0.2448817533 +0.8696951640 0.2436303217 +0.8704149170 0.2423778723 +0.8711351117 0.2411236172 +0.8718552522 0.2398684191 +0.8725750954 0.2386127029 +0.8732949565 0.2373559189 +0.8740145210 0.2360986172 +0.8747342740 0.2348399499 +0.8754543919 0.2335796077 +0.8761746912 0.2323179106 +0.8768946943 0.2310556951 +0.8776145736 0.2297926602 +0.8783346712 0.2285282053 +0.8790546531 0.2272629169 +0.8797743401 0.2259971105 +0.8804939120 0.2247304709 +0.8812138446 0.2234621601 +0.8819337161 0.2221929204 +0.8826535948 0.2209226316 +0.8833731799 0.2196518251 +0.8840929474 0.2183796604 +0.8848132759 0.2171054668 +0.8855336076 0.2158302299 +0.8862536463 0.2145544745 +0.8869734963 0.2132780168 +0.8876933734 0.2120004748 +0.8884133130 0.2107217854 +0.8891329608 0.2094425781 +0.8898530169 0.2081616083 +0.8905731261 0.2068795070 +0.8912929442 0.2055968875 +0.8920131251 0.2043125847 +0.8927330152 0.2030277635 +0.8934529241 0.2017418725 +0.8941730851 0.2004544939 +0.8948929561 0.1991665971 +0.8956128046 0.1978777042 +0.8963327750 0.1965875565 +0.8970527813 0.1952963075 +0.8977724988 0.1940045404 +0.8984924094 0.1927113902 +0.8992125684 0.1914167569 +0.8999325260 0.1901214486 +0.9006521957 0.1888256224 +0.9013716648 0.1875291219 +0.9020917071 0.1862305520 +0.9028114621 0.1849314639 +0.9035313368 0.1836311235 +0.9042514045 0.1823293975 +0.9049711855 0.1810271534 +0.9056912515 0.1797233570 +0.9064110312 0.1784190425 +0.9071314180 0.1771125904 +0.9078515188 0.1758056198 +0.9085715015 0.1744978266 +0.9092916706 0.1731886578 +0.9100115925 0.1718789016 +0.9107316949 0.1705677798 +0.9114515127 0.1692561399 +0.9121715956 0.1679429801 +0.9128913943 0.1666293022 +0.9136109934 0.1653149527 +0.9143309149 0.1639989781 +0.9150508896 0.1626818694 +0.9157705811 0.1613642428 +0.9164906707 0.1600448506 +0.9172108055 0.1587243383 +0.9179309281 0.1574028113 +0.9186507682 0.1560807660 +0.9193705967 0.1547577059 +0.9200905249 0.1534334261 +0.9208101714 0.1521086283 +0.9215305408 0.1507814624 +0.9222506286 0.1494537780 +0.9229708262 0.1481248540 +0.9236907427 0.1467954119 +0.9244106520 0.1454649464 +0.9251306075 0.1441333591 +0.9258505602 0.1428007402 +0.9265702329 0.1414676034 +0.9272899034 0.1401334351 +0.9280100090 0.1387974231 +0.9287298353 0.1374608930 +0.9294498354 0.1361230034 +0.9301695567 0.1347845958 +0.9308898667 0.1334440560 +0.9316098981 0.1321029978 +0.9323298397 0.1307610700 +0.9330496743 0.1294183052 +0.9337696518 0.1280742373 +0.9344893518 0.1267296514 +0.9352095347 0.1253831262 +0.9359296283 0.1240357309 +0.9366497522 0.1226872416 +0.9373695994 0.1213382342 +0.9380893274 0.1199884138 +0.9388092215 0.1186372456 +0.9395292431 0.1172848013 +0.9402489889 0.1159318389 +0.9409686707 0.1145779608 +0.9416885002 0.1132227687 +0.9424086551 0.1118659268 +0.9431285349 0.1105085666 +0.9438485784 0.1091498611 +0.9445685689 0.1077902186 +0.9452882851 0.1064300581 +0.9460079488 0.1050689608 +0.9467280640 0.1037059728 +0.9474482126 0.1023418845 +0.9481680874 0.1009772779 +0.9488879960 0.0996115710 +0.9496083099 0.0982440577 +0.9503283507 0.0968760259 +0.9510483007 0.0955071297 +0.9517679782 0.0941377157 +0.9524880536 0.0927665077 +0.9532078569 0.0913947816 +0.9539280500 0.0900212754 +0.9546482500 0.0886467188 +0.9553681782 0.0872716440 +0.9560881137 0.0858955189 +0.9568080998 0.0845182601 +0.9575278150 0.0831404834 +0.9582479488 0.0817608687 +0.9589679894 0.0803803954 +0.9596877596 0.0789994040 +0.9604074374 0.0776175543 +0.9611276344 0.0762336704 +0.9618476359 0.0748491252 +0.9625673680 0.0734640621 +0.9632875712 0.0720770552 +0.9640075052 0.0706895300 +0.9647272650 0.0693013042 +0.9654473401 0.0679114335 +0.9661671467 0.0665210446 +0.9668871452 0.0651292484 +0.9676068757 0.0637369341 +0.9683268611 0.0623430901 +0.9690465788 0.0609487281 +0.9697663836 0.0595531612 +0.9704859373 0.0581570455 +0.9712052242 0.0567604125 +0.9719258029 0.0553602336 +0.9726461145 0.0539595359 +0.9733664680 0.0525577189 +0.9740865550 0.0511553833 +0.9748066103 0.0497520726 +0.9755266577 0.0483477401 +0.9762464394 0.0469428896 +0.9769663969 0.0455366594 +0.9776863258 0.0441294483 +0.9784061080 0.0427214878 +0.9791256255 0.0413130095 +0.9798456390 0.0399025237 +0.9805655893 0.0384911251 +0.9812857853 0.0370782076 +0.9820057169 0.0356647719 +0.9827258942 0.0342498168 +0.9834460511 0.0328338646 +0.9841659443 0.0314173941 +0.9848857478 0.0300000638 +0.9856057979 0.0285812112 +0.9863255849 0.0271618406 +0.9870451228 0.0257419255 +0.9877653545 0.0243196044 +0.9884853237 0.0228967649 +0.9892051324 0.0214732061 +0.9899251805 0.0200481371 +0.9906449667 0.0186225500 +0.9913647890 0.0171958551 +0.9920848096 0.0157677306 +0.9928045688 0.0143390881 +0.9935245161 0.0129090360 +0.9942442024 0.0114784659 +0.9949642472 0.0100461467 +0.9956841510 0.0086130714 +0.9964038065 0.0071794544 +0.9971233996 0.0057449260 +0.9978427330 0.0043098803 +0.9985620044 0.0028739234 +0.9992811316 0.0014372201 +1.0000000000 0.0000000000 From 8a08e080529b68ad1777fb3c9cdfd1c54f918538 Mon Sep 17 00:00:00 2001 From: Sergio Vieira Date: Thu, 13 Jun 2019 12:22:08 -0300 Subject: [PATCH 29/29] - Adds Barros problems --- src/problems/SIGA/BarrosF1F2.cpp | 2 +- src/problems/SIGA/BarrosF1F3.cpp | 6 +++--- src/problems/SIGA/BarrosF1F5.cpp | 2 +- src/problems/SIGA/BarrosF5F3.cpp | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/problems/SIGA/BarrosF1F2.cpp b/src/problems/SIGA/BarrosF1F2.cpp index 3fbb330..1df1e2c 100644 --- a/src/problems/SIGA/BarrosF1F2.cpp +++ b/src/problems/SIGA/BarrosF1F2.cpp @@ -18,7 +18,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with this program. If not, see . -#include "problems/SIGA/BarrosF1F2.h" +#include "BarrosF1F2.h" /** * Class constructor diff --git a/src/problems/SIGA/BarrosF1F3.cpp b/src/problems/SIGA/BarrosF1F3.cpp index 70c5dc5..86c87ef 100644 --- a/src/problems/SIGA/BarrosF1F3.cpp +++ b/src/problems/SIGA/BarrosF1F3.cpp @@ -1,5 +1,5 @@ //#include "BarrosF1_F3.h" -#include "problems/SIGA/BarrosF1F3.h" +#include "BarrosF1F3.h" BarrosF1F3::BarrosF1F3(string solutionType, int numberOfVariables, int numberOfObjectives) { @@ -51,8 +51,8 @@ void BarrosF1F3::evaluate(Solution * solution) double x2 = vars->getValue(1); delete vars; double f1 = x1; - double a = std::exp(-pow ( (x2 - 0.2) / 0.004, 2.0)); - double b = std::exp(-pow ( (x2 - 0.6) / 0.4, 2.0)); + double a = exp(-pow ( (x2 - 0.2) / 0.004, 2.0)); + double b = exp(-pow ( (x2 - 0.6) / 0.4, 2.0)); double f3 = (2.0 - a - 0.8 * b) / x1; solution->setObjective(0, f1); solution->setObjective(1, f3); diff --git a/src/problems/SIGA/BarrosF1F5.cpp b/src/problems/SIGA/BarrosF1F5.cpp index ca25c76..9a81b1a 100644 --- a/src/problems/SIGA/BarrosF1F5.cpp +++ b/src/problems/SIGA/BarrosF1F5.cpp @@ -18,7 +18,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with this program. If not, see . -#include "problems/SIGA/BarrosF1F5.h" +#include "BarrosF1F5.h" /** * Class constructor diff --git a/src/problems/SIGA/BarrosF5F3.cpp b/src/problems/SIGA/BarrosF5F3.cpp index 6201f5d..e649093 100644 --- a/src/problems/SIGA/BarrosF5F3.cpp +++ b/src/problems/SIGA/BarrosF5F3.cpp @@ -18,7 +18,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with this program. If not, see . -#include "problems/SIGA/BarrosF5F3.h" +#include "BarrosF5F3.h" /** * Class constructor @@ -102,8 +102,8 @@ void BarrosF5F3::evaluate(Solution *solution) double value4 = -(value2 * sin(2.0 * PI * q * x[0])); double value5 = value3 - value4; fx[0] = value1 * value5; - double a = std::exp(-pow((x[1] - 0.2) / 0.004, 2.0)); - double b = std::exp(-pow((x[1] - 0.6) / 0.4, 2.0)); + double a = exp(-pow((x[1] - 0.2) / 0.004, 2.0)); + double b = exp(-pow((x[1] - 0.6) / 0.4, 2.0)); fx[1] = (2.0 - a - 0.8 * b) / x[0]; solution->setObjective(0, fx[0]); solution->setObjective(1, fx[1]);